Re: Site optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

on 12/28/2004 02:50 PM veditio@xxxxxxxxxxx said the following:
While my PHP/MySQL-based sites work quickly on my development
computer, as well on servers where I know the traffic load is low,
I'm concerned about how they'll perform under heavy loads, and
whether or not I need to simplify MySQL queries or PHP code in order
to speed up page delivery.

Does anyone have any suggestions as to how to simulate site
performance under heavy traffic load, and then, should results be
poor, how to optimize code to perform better?

You may want to try the ab program that comes with Apache.

This may sound curious, but the best way to speedup database driven sites is to avoid database accesses as much as possible.

What I do to reduce the eventual performance penalty as the site audience increases is to determine which pages lead to more repeated SELECT queries and use server side caches to reduce the need to execute such queries.

For instance, if you have a content site, the content page scripts tend to execute the same queries over and over again. This is the kind of queries that can be optimized away by employing a server side cache system.

I use this generic cache class to store cached the pages in server side files. Since the class can store generic data I can cache either full pages, just some parts of the pages or even the contents of variables or query result sets arrays by using the PHP serialize/unserialize functions to store the variables data as a single string.

The class lets me set a expiry period or a date to determine when the cached data is no longer valid and forcing the cached data to be regenerated next time it is accessed.

However, I use a more efficient way manage cached data that consists in calling a function of the cache class named voidcache that simply removes the cache data in a safe way, when the site executes some operation that updates cached content in the database.

This class is very robust as it employs safe locking to prevent that simultaneous accesses attempt to update the cache file at the same time, thus avoiding eventual corruption.

I started using this class because I have a site that started growing so much in popularity, that I had to save as much queries as possible on every content page. Currently, this site uses over 35,000 cache files to save as much database queries as possible.

The class and its support forum is available here:

http://www.phpclasses.org/filecache

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux