|
PHP Caching - A Great Way To Super Charge Your Server
By
Steven Kay
Article Word Count: 409 [View Summary] Comments (0) |
|
To run a high performance PHP/MySQL server, one has to keep a close eye on the server load. A high performance mechanism to drastically reduce loads is caching. A system that effectively employs caching exhibits much higher performance and less downtime. MySQL includes mechanisms for caching via MySQL's Query Cache. At the same time, this caching system does not improve performance if any of the rows in a large table are altered, so there is no 'row level' caching in MySQL, only 'table level' caching.
So how do we deal with this issue? The solution lies in using one of the caching systems available to PHP. One that I have used to great satisfaction is Cache Lite, which, under PHP program control, caches data to hard disk for a period of time as specified by the program.
So lets take a look at Cache Lite and see how it is incorporated into the overall PHP script design. First, search for and download Cache Lite. Then save the files under 'Lite' directory to a subdirectory under your webserver's root (e.g. 'Cache/Lite'). After that, you can refer to the example file in the downloaded documentation (the file is called 'examples'), which provides a working example, and that information is not repeated here.
Here I will concentrate on cases of use. Take a bulletin board, for example. Moderator information is kept in users table, and that table can get large. Normally the moderator information does not change often. In this case, table-level caching available in MySQL does not provide performance improvements when any changes are made in the users table. Instead, a cache can be set up with PHP to cache all the moderator information for say 24 hours.
The above approach works great, but there is a tradeoff. What if a moderator is added or dropped, or some other information related to this moderator is changed. In this case, we have to add PHP code to delete/refresh the cache, or to make the cache timeout reasonable short (say 10 minutes).
Another point to keep in mind is with Linux directory access control, we need to do a 'chmod 777' for the directory that keeps the cache data. This will enable PHP to read/write from/to that directory.
In summary, PHP can easily be supercharged to deliver performance in demanding environments. PHP can also overcome for the current shortcoming of MySQL which is lack of row-level caching.
|
Visit dbFreaks for php, MySQL, and other database discussions. The following threads are of interest: PHP Installation Problems on XP discusses issues with PHP installation on Windows XP computers. MySQL Join Queries and PHP Security Questions are other interesting threads related to MySQL/PHP installs. Article Source: http://EzineArticles.com/?expert=Steven_Kay |
|
This article has been viewed 72 time(s).
Article Submitted On: May 20, 2008
-
MLA Style Citation:
Kay, Steven "PHP Caching - A Great Way To Super Charge Your Server." PHP Caching - A Great Way To Super Charge Your Server. 20 May. 2008 EzineArticles.com. 22 Nov. 2009 <http://ezinearticles.com/?PHP-Caching-A-Great-Way-To-Super-Charge-Your-Server&id=1190850>.
-
APA Style Citation:
Kay, S. (2008, May 20). PHP Caching - A Great Way To Super Charge Your Server. Retrieved November 22, 2009, from http://ezinearticles.com/?PHP-Caching-A-Great-Way-To-Super-Charge-Your-Server&id=1190850
-
Chicago Style Citation:
Kay, Steven "PHP Caching - A Great Way To Super Charge Your Server." PHP Caching - A Great Way To Super Charge Your Server EzineArticles.com. http://ezinearticles.com/?PHP-Caching-A-Great-Way-To-Super-Charge-Your-Server&id=1190850