Performance


Performance on the web is straightforward: a relatively small amount of servers must be able to support a potentially unlimited number of clients. Any code running on the server must be clean and fast.

When inspecting code for performance issues, I look at two things: 1) database queries, and 2) disk reads. Database queries are a critical part of most applications. Optimizing databases is a topic unto itself and I can\'t possibly cover it here, but I can give some coding tips in order to ease database optimization.

• Number your queries in your code. This will help you keep track of how many queries are involved in a certain process, and will save you time when trying to optimize your scripts.

• Create proper indexes. Optimized indexes are key to database speed. Any fields which are routinely queried against should have indexes. Don\'t create too many indexes, as unnecessary indexes will slow INSERTs and increase the database size unnecessarily.

• Test, test, and test again. Poorly written queries can kill a database server. Take the time to gauge the performance of your queries and understand what the database needs to do in order to execute them.

After database queries, disk reads are your next largest performance worry. It is common in scripted languages (like PHP or Perl) to keep groups of functions and variables in separate files in order to ease maintenance and make code more readable. While doing so has it advantages, we have to remember that every include() or require() statement involves a disk read, and every disk read increases load on the web server.

Basically, we want to design our applications to have a minimal number of included files, or perhaps include the code explicitly when our application has become relatively stable.

No comments

Enter your email address:

Delivered by FeedBurner

OR

 Subscribe in a reader

 
jQuery UI provides a comprehen
 
Program Plan   I drafted a p
 
I present to you my skills, ac
 
Introduction One of the issue
 
If you are a PHP developer and
 
cURL is a great tool to help y
 
cformsII cforms is a powerful
 
  The lack of Unicode su
 
History PHP-GTK was origina
 
Performance on the web is stra
 
Listen t
 
What\'s the number one cost in
 
When you\'re discussing the In
 
Classe
 
A service-oriented architectur
 
Introduc
 
PHP Crons and Linux Linux has
 
Cross site scripting (XSS) is
 
What Makes a Web 2.0 Applicati
 
As you develop web application
 
Cryptogr
 
Posting
 
Have you
 
Resources The Google API - ht
 
Get Started
 
Output B
 
If you r
 
PHP has some really sweet new
 
There were some new php.ini di
 
In PHP 5 there are some new fu
 
The following code implements
 
The following code snippet imp
 
A fine implementation of the o
 
Exception handling PHP 5 adds
 
Support for dereferencing obje
 
Static members Classes defini
 
Explicit object cloning In or
 
final methods The final keywo
 
Interfaces Gives the ability
 
The new object oriented featur
 
Sometimes its the little thing
 
Consider your file is at locat
 
# If a method can be static, d