100% CPU usage while uploading large files

apache-2.2central-processing-unitfastcgi

please, help me to resolve the issue. I have an images processing website on the dedicated server. After moving to more powerful server I met strange problems.

First server configuration was:

Core 2 Quad 6600
4G DDR2 RAM
2x500GB SATA + Hardware Raid0
Fedora 32bit + PAE

New server configuration is:

Core 2 Quad 6600
8G DDR2 RAM
2x300GB SAS + Hardware Raid0
CentOS 64bit

engine uses Nginx + Apache + fastcgi + perl
Nginx – frontend, serves static content.
Apache – backend, serves dynamic content using fastcgi.

The reason why I had to upgrade server is high disk utilization, almost 90..100%
Now there is no problem with disk, but new problem arisen.
Now all fastcgi processes together use almost 100% CPU.

I also noticed, that process uses alot of CPU when website's user uploads large file to the server.
And after file has been uploaded CPU usage becomes normal again.

Here are first rows from the top

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

18306 apache    15   0  427m  45m 5576 S 97.4  0.6   0:23.83 index.fcgi  
18294 apache    16   0  440m  58m 5312 S 68.8  0.7   0:22.81 index.fcgi  
17612 apache    16   0  465m  82m 5728 R 59.8  1.0   1:03.95 index.fcgi  
18164 apache    15   0  397m  79m 5628 S 40.9  1.0   0:35.59 index.fcgi  

I've never seen anything like that on the old server.
Do you have any ideas what can cause such problem ?
Let me know if you need some additional server info

Thanks in advance!

Best Answer

It is natural that when you remove one bottleneck (disk IO), the system will speed up to the point of hitting another bottleneck (in this case, apparently, CPU). You should improve the efficiency of your code (so that it utilises a single core better), parallelise your code (so that it can utilise multiple cores simultaneously), obtain better CPUs, or learn to live with it. Is your site running slower than is acceptable for your situation?

Related Topic