January 3, 2004
"Better"
Whoever left the anonymous comment yesterday, SHOW YOURSELF! Actually, they made a good point.
"How can the scripting be better if it's CPU intensive?"
Good question. Here's the answer.
In general, Tabulas was a hodgepodge of different scripting styles with various "global" variables being used. This meant that things were not consistent when you looked at code; your userid variable should be stored as one variable throughout the site; it was stored as two previously.
Now, specifically regarding the entry display engine, I had to rewrite it because it was a mess. There was one massive function that specifically handled displaying entries. It was over 600 lines long. This made troubleshooting that function almost impossible.
Now, I split up the function (as described) into two logical functions: the first one determined which entryids to pull based on your privacy settings, while the second one took an array of entryids and displayed them.
Now, although this is a cleaner and more logical method of doing things, there is an extra layer of abstraction; before the entryids and display were on one layer. However, now the database is (essentially) hit twice; once to determine the IDs and once to grab those entry based on their entryid.
However, both of these queries are extremely fast; I've tried to minimize the amount of work the database has to do.
You see, when you develop database-driven sites, there are two primary methods of handling the workload:
1.) Make the PHP do most of the work while mySQL just serves up data
2.) Make the mySQL database do most of the work while the PHP does simple outputting
The problem with the old method is that it placed a lot of work on my database; and I'm trying to move away from that.
PHP is much easier to do load-balancing than mySQL servers; you just buy more servers, send up a round-robin DNS system, and let things loose. mySQL servers are harder to set up across multiple servers; so you want to minimize the amount of work mySQL has to do while mazimixing the amount PHP does.
So the more CPU intensive basically means PHP is doing more work to output the same data, but there's less work being done on the mySQL end of things.
"How can the scripting be better if it's CPU intensive?"
Good question. Here's the answer.
In general, Tabulas was a hodgepodge of different scripting styles with various "global" variables being used. This meant that things were not consistent when you looked at code; your userid variable should be stored as one variable throughout the site; it was stored as two previously.
Now, specifically regarding the entry display engine, I had to rewrite it because it was a mess. There was one massive function that specifically handled displaying entries. It was over 600 lines long. This made troubleshooting that function almost impossible.
Now, I split up the function (as described) into two logical functions: the first one determined which entryids to pull based on your privacy settings, while the second one took an array of entryids and displayed them.
Now, although this is a cleaner and more logical method of doing things, there is an extra layer of abstraction; before the entryids and display were on one layer. However, now the database is (essentially) hit twice; once to determine the IDs and once to grab those entry based on their entryid.
However, both of these queries are extremely fast; I've tried to minimize the amount of work the database has to do.
You see, when you develop database-driven sites, there are two primary methods of handling the workload:
1.) Make the PHP do most of the work while mySQL just serves up data
2.) Make the mySQL database do most of the work while the PHP does simple outputting
The problem with the old method is that it placed a lot of work on my database; and I'm trying to move away from that.
PHP is much easier to do load-balancing than mySQL servers; you just buy more servers, send up a round-robin DNS system, and let things loose. mySQL servers are harder to set up across multiple servers; so you want to minimize the amount of work mySQL has to do while mazimixing the amount PHP does.
So the more CPU intensive basically means PHP is doing more work to output the same data, but there's less work being done on the mySQL end of things.
Comment with Facebook
Want to comment with Tabulas?. Please login.
yuhoo7
kdb003
....so its less CPU intensive?
roy
And in any case, the main point is that with the database and PHP on separate servers, I'm moving more of the load onto the PHP servers rather than the mySQL servers ;D
MacDaddyTatsu (guest)
roy
It's much easier with the changes I've made to spread Tabulas across several servers now (since PHP is easier to load balance than mySQL).