Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Need some assistance in analyzing apache and php process running on linux server. Its a 8-core intel processor with 4GB ram. When the website on it runs the top displays like this.

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
23459 username1 16   0  151m  27m 8388 S 11.3  0.7   0:11.71 php5
23730 username1 16   0  151m  28m 8388 S 11.3  0.7   0:03.87 php5
23458 username1 16   0  151m  28m 8388 S  3.0  0.7   0:19.20 php5
16202 mysql     15   0  459m  38m 4624 S  0.7  1.0  62:33.81 mysqld
24141 nobody    15   0  311m 5832 2304 S  0.3  0.1   0:00.03 httpd

Why does the command say php5 when the website is accessed. Both apache and php was preconfigured so not sure whats done there. Tried setting up the same site and db on a different server but on it the process shows httpd always and not php5. The site uses mysql db.

The problem is server load seems to go till about 5.x when the website was access by about 16users. When the free -m command was given the output shows

             total       used       free     shared    buffers     cached
Mem:          3941       3727        213          0        236       2734
-/+ buffers/cache:        756       3184
Swap:         4095          0       4095

Lots of memory seems to be in cache and free memory is less. Even when the website is not accessed that is leaving it very much idle for about 2days the free memory showed just 190. When the site is accessed the free memory seems to be go till 90mb then it increases to about 150mb. It always seems to remain just about 200mb. Is it somehow related to the server load showing 5.x. Will adding some more RAM resolve the load issue?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Why does the command say php5 when the website is accessed. Both apache and php was preconfigured so not sure whats done there. Tried setting up the same site and db on a different server but on it the process shows httpd always and not php5

Because on the first server, the PHP is running as a CGI or as fast CGI, and on the second server its running as an apache module.

The virtual size of your httpd processes looks enourmous - how many servers do you have running?

The problem is server load seems to go till about 5.x when the website was access by about 16users.

Without knowing a lot more about the code and the pattern of usage, its hard to make generalizations, however given the spec the machine and this number of users, I would not expect to see to see any significant impact on load. (I used to worry when the load on a farm of 1GHz / 512Mb LAMP boxes, each handling around 120 concurrent requests rose above 0.8).

I suspect there's something very wrong with the configuration of this monster machine. Certainly if its running a CGI interface then you really should address that immediately.

I'm confused as to why its behaving so badly - you've not set the CPU affinity on the httpd process by any chance? (man taskset)

share|improve this answer
    
how many servers do you have running? - Do you mean web servers? Just one apache. –  zapping Feb 21 '11 at 13:51
    
you've not set the CPU affinity on the httpd process by any chance? - Not sure what you mean here. –  zapping Feb 21 '11 at 13:53
    
@zapping: as I said - try man taskset - or linux.die.net/man/1/taskset –  symcbean Feb 22 '11 at 11:52
add comment

For the first issue, when PHP scripts are accessed via mod_php they will appear as httpd since they run within the webserver. When they are accessed via CGI or FCGI they show up as php5 since a separate process runs in those cases.

As for the second issue, there are lots and lots and lots of duplicates for that on this site; I invite you to search for them. I will leave it at "you do not have a memory problem".

share|improve this answer
    
linuxatemyram.com –  jamespo Feb 21 '11 at 13:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.