Where's my web server bottleneck?

Christopher Murtagh yellowdog-general@lists.terrasoftsolutions.com
Wed Nov 20 21:47:01 2002


On Wed, 20 Nov 2002, bronto wrote:
>>How many users are we talking here on average?
>
>At the moment typically only a few at a time.  But I am expecting a
>barrage towards the end of the month.  Not hundreds at a time, mind you,
>but certainly dozens.

 If you are only getting a few hits at a time, and your machine is bogged
down, then it would seem that there is something not right. The first
thing I would look at is a test of your bandwidth. How long does it take
to fetch a 100k image from your server? Compare that to your 100k PHP
file, but do it without rendering the HTML or image (ie. do a save this
link as or use a sucking tool like wget). If the difference is
significant, then the problem is likely in the PHP programming. There are
lots of ways do optimize that depending on what sort of code is being
used:

 - avoid unnecessary function calls. PHP doesn't do them very efficiently.
 - check your database connections and DB performance.
 - if you are including global files, check to see that you aren't
   including things you don't need. Including the entire library of code
   would be bad.

 In general PHP isn't that bad in terms of performance, but you can easily
write code that is a resource hog and very inefficient (like any language
I guess). My central web server (a G4 867 w/896MB of RAM) takes on about
350k page hits (no images) per day, all PHP driven and they are big -
about 120k each.  For the most part, it handles it without any problems,
but at peak hours it is starting to show.

Cheers,

Chris

-- 

Christopher Murtagh
Webmaster / Sysadmin
Web Communications Group
McGill University
Montreal, Quebec
Canada

Tel.: (514) 398-3122
Fax:  (514) 398-2017