Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing overhead of php scripts

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
We have an apache server on a shared machine with WHM and SSH access (often called a virtual personal server). A few weeks ago I had to rebuild apache to add the gd library, and I also updated the site adding some PHP/Mysql generated content.

The problem we have is that our mysql server keeps shutting itself down. Some investigation has shown that it's our 128MB of RAM that is maxing out at peak times that is causing this. This is however a new development. It's only started over the last few days, but is now happening 3 or 4 times a day. Our site only gets about 600 visitors a day on average and this shouldn't be too much for the server to cope with.

The only possible cause I can come up with is that some php scripts may be using large amounts of RAM. Is there any way to test this? I've used the 'top' command from the command line to view the processes that are using the most resources on the server, but all that gives is an ever changing list of values by PID (process id) which gives me no detail of the processes other than that they're httpd requests, and some of them are using upto 16% of the allocated RAM.

Do you guys ever test the server resources that your scripts use? If yes, how do you do it?

TIA,

Chris.
 
I never tested the memory usage of my scripts, but there may be a quick fix for the problem. PHP can be invoked as an apache module, as CGI or with FastCGI. The CGI option will force PHP to be reloaded for each page. This is a bit slower, but for a moderate you describe site you should not be able to tell the difference.

If there are memory leaks, they may come from PHP itself (which sounds unlikely, as more people should then have the same problem) or from the use or even improper use of an extension. So my guess would be to look for special extension functions (like image handling, for instance) and see if you did not forget some destructor function. For the found extensions, you could test the use of the extension apart from the normal site and see which extension consumes much memory.

There is probably a command-line way to measure the memory usage.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top