Friday, 9 February 2007
Five Tips for Creating Web Application in PHP |
| |
|
| |
Justin Silverton in a new entry over his blog gives you five tips that can help in the performance when writing PHP applications. He also says that this can be applied to other languages too.
Justin explains the five tips. They include:
1) Use multi resultset queries to your database rather than many small ones
He tells the users to look through their database code to see if there are requests that go to the database more than once. Each of these will decrease the number of requests per second the users application can serve. By returning multiple resultsets in a single database request, the users can not only cut the total time spent communicating with the database but also make their applications more scalable by cutting down on the work the database server is doing to manage requests.
2) Page/object caching
He divides the template caching into two parts:
PHP Object caching
- ion cube (commercial): this one is unique because you don’t have to have server extensions installed
- Alternative PHP cache (free): will be included with PHP 6.
- Turck MMCache (free): includes an encoder and loader, so you can distribute your scripts without the source
Database Object caching
- memcached : used by livejournal and slashdot.org.
3) gzip compression
Enabling this may increase CPU utilization as it takes more processing power to gzip a file, he says. But it decreases the number of bytes sent from the user’s server, saves your bandwidth, and generally makes the site faster to the visitors.
He adds the following in php.ini to enable gzip compression:
zlib.output_compression = 1 (requires PHP 4.0.5 or above) zlib.output_compression_level = X (X=0 through 7.
He also adds that higher the number, the more the output will be compressed. He tells you to be careful when choosing higher numbers as it will take much more processing power (requires PHP 4.3.0 or above) 4) Tune your web server
He gives a list of Apache version 2.0 performance tips here. It says Apache v.2 is a general-purpose web server, designed to provide a balance of flexibility, portability, and performance. You can have a detail description of the performance tips here.
5) Don’t save performance testing for the end of the project
It says it is always better to do performance testing before as it may already be too late and might take too much time to make the necessary architectural changes. Tests can be performed on individual pieces of your application or the application as a whole, he informs.
|
| |
|
More info
|
| |
|
|
| |
|
|
| |
|