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?
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 asphp5
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".
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?
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)