You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alexey Vlasov <re...@renton.name> on 2008/11/05 22:19:28 UTC

[users@httpd] High CPU usage with MPM Worker/Event

Hi.

Working with Apache I noticed one strange thing such as high consumption
of CPU.

It looks like this.
server status:
Parent Server Generation: 2
Server uptime: 27 minutes 54 seconds
Total accesses: 137589 - Total Traffic: 6.1 GB
CPU Usage: u80.91 s52.19 cu0 cs0 - 7.95% CPU load
82.2 requests/sec - 3.7 MB/second - 46.2 kB/request
62 requests currently being processed, 38 idle workers

Especially remarkable is that Top gives - 9999%
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  11978 www       20   0  458m 111m 2000 S 9999  0.7   0:01.66
  /opt/apache/2.2.9/sbin/httpd -k start
  18151 www       20   0  453m 106m 1996 S    4  0.7   0:00.30
  /opt/apache/2.2.9/sbin/httpd -k start
  18911 www       20   0  333m 100m 1984 S    3  0.6   0:00.09
  /opt/apache/2.2.9/sbin/httpd -k start
  18942 www       20   0  421m 101m 1996 S    2  0.6   0:00.07
  /opt/apache/2.2.9/sbin/httpd -k start

Accounting also shows high consumption of CPU.

I don't know how it really should be, but I think it's not quite normal.
Can it be peculiarity or feature of my configuration? Well I really need
some advice from those who use worker/event. Thanks in advance.

Configuration of my box:
2 x Quad-core CPUs Intel Xeon E5345 linux-2.6.25, gcc-4.1.2, libc-2.6.1

Apache-2.2.9 make options:
CFLAGS="-O3 -march=nocona -pipe -fPIC -fomit-frame-pointer -ftracer
-mfpmath=sse"

mpm config:
<IfModule mpm_event_module>
    ServerLimit          48
    StartServers          4
    MaxClients         1200
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

Example of my virtualhost:
<VirtualHost *>
    <IfModule fcgid_module>
        FCGIWrapper /path_to_phpwrapper
    </IfModule>
    CustomLog path_to_log combined
    ErrorLog path_to_log
    DocumentRoot /path_to_docroot
    SetEnv PHPRC /path_to_php.ini
    <IfModule php5_module>
        php_admin_value *** ***
    </IfModule>
    ServerName example.com
    ServerAlias www.example.com
    ServerAlias www1.example.com
    AddHandler server-parsed .htm
    AddHandler server-parsed .html
    AddHandler server-parsed .shtm
    AddHandler server-parsed .shtml
    RewriteEngine On
    RewriteCond *** *** 
    # some rules for backend
    RewriteRule *** *** [NC,L,P]
    SuexecUserGroup user group
</VirtualHost>

Total number of virtual hosts is about 2000.

-- 
BRGDS. Alexey Vlasov.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] High CPU usage with MPM Worker/Event

Posted by Alexey Vlasov <re...@renton.name>.
Frankly speaking I don't know how many processes should be and how many
I need. I want to learn  - why is CPU worker usage so high?

Constantly ~300-500 ESTAB
connections. My server-status you have seen. The number of processes is
~20-25.

On other server I have tried to use the following settings:
    ServerLimit           5
    ThreadLimit         125
    StartServers          4
    MaxClients          500
    MinSpareThreads      25
    MaxSpareThreads     125
    ThreadsPerChild     100
    MaxRequestsPerChild   0
The number of processes: ~10-15.
But the situation with CPU is the same.

On Mon, Nov 10, 2008 at 01:01:49PM +0530, Arnab Ganguly wrote:
> Hi ,
> Can you please tell me about your requirements like for example how many
> processes do you want to create for handling the request, it seems to me the
> number of processes are very high, you can try out increasing the number of
> threads per process that way you can reduce the number of processes, also
> introduce ThreadLimit param in order to increase the ThreadsPerChild.Let me
> know if I can help you.
> Thanks
> -A
> 
> On Sun, Nov 9, 2008 at 10:31 PM, Alexey Vlasov <re...@renton.name> wrote:
> 
> > Hi.
> >
> > I set MaxRequestPerChild = 400 (400 is average quantity of ESTABLISHED
> > connections), but it was only worse.
> >
> > On Thu, Nov 06, 2008 at 12:01:00PM +0530, Arnab Ganguly wrote:
> > > Hi,
> > > Can you try with Non-zero MaxRequestPerChild value.Keep a value which is
> > > equal to number of request are particular process you want to handle.Once
> > it
> > > is done the process will be killed and a new process is going to be
> > > started.I guess your CPU usage should come down.
> > > Thanks
> > > -A
> > >
> > > On Thu, Nov 6, 2008 at 2:49 AM, Alexey Vlasov <re...@renton.name>
> > wrote:
> > >
> > > > Hi.
> > > >
> > > > Working with Apache I noticed one strange thing such as high
> > consumption
> > > > of CPU.
> > > >
> > > > It looks like this.
> > > > server status:
> > > > Parent Server Generation: 2
> > > > Server uptime: 27 minutes 54 seconds
> > > > Total accesses: 137589 - Total Traffic: 6.1 GB
> > > > CPU Usage: u80.91 s52.19 cu0 cs0 - 7.95% CPU load
> > > > 82.2 requests/sec - 3.7 MB/second - 46.2 kB/request
> > > > 62 requests currently being processed, 38 idle workers
> > > >
> > > > Especially remarkable is that Top gives - 9999%
> > > >  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> > > >  11978 www       20   0  458m 111m 2000 S 9999  0.7   0:01.66
> > > >  /opt/apache/2.2.9/sbin/httpd -k start
> > > >  18151 www       20   0  453m 106m 1996 S    4  0.7   0:00.30
> > > >  /opt/apache/2.2.9/sbin/httpd -k start
> > > >  18911 www       20   0  333m 100m 1984 S    3  0.6   0:00.09
> > > >  /opt/apache/2.2.9/sbin/httpd -k start
> > > >  18942 www       20   0  421m 101m 1996 S    2  0.6   0:00.07
> > > >  /opt/apache/2.2.9/sbin/httpd -k start
> > > >
> > > > Accounting also shows high consumption of CPU.
> > > >
> > > > I don't know how it really should be, but I think it's not quite
> > normal.
> > > > Can it be peculiarity or feature of my configuration? Well I really
> > need
> > > > some advice from those who use worker/event. Thanks in advance.
> > > >
> > > > Configuration of my box:
> > > > 2 x Quad-core CPUs Intel Xeon E5345 linux-2.6.25, gcc-4.1.2, libc-2.6.1
> > > >
> > > > Apache-2.2.9 make options:
> > > > CFLAGS="-O3 -march=nocona -pipe -fPIC -fomit-frame-pointer -ftracer
> > > > -mfpmath=sse"
> > > >
> > > > mpm config:
> > > > <IfModule mpm_event_module>
> > > >    ServerLimit          48
> > > >    StartServers          4
> > > >    MaxClients         1200
> > > >    MinSpareThreads      25
> > > >    MaxSpareThreads      75
> > > >    ThreadsPerChild      25
> > > >    MaxRequestsPerChild   0
> > > > </IfModule>
> > > >
> > > > Example of my virtualhost:
> > > > <VirtualHost *>
> > > >    <IfModule fcgid_module>
> > > >        FCGIWrapper /path_to_phpwrapper
> > > >    </IfModule>
> > > >    CustomLog path_to_log combined
> > > >    ErrorLog path_to_log
> > > >    DocumentRoot /path_to_docroot
> > > >    SetEnv PHPRC /path_to_php.ini
> > > >    <IfModule php5_module>
> > > >        php_admin_value *** ***
> > > >    </IfModule>
> > > >    ServerName example.com
> > > >    ServerAlias www.example.com
> > > >    ServerAlias www1.example.com
> > > >    AddHandler server-parsed .htm
> > > >    AddHandler server-parsed .html
> > > >    AddHandler server-parsed .shtm
> > > >    AddHandler server-parsed .shtml
> > > >    RewriteEngine On
> > > >    RewriteCond *** ***
> > > >    # some rules for backend
> > > >    RewriteRule *** *** [NC,L,P]
> > > >    SuexecUserGroup user group
> > > > </VirtualHost>
> > > >
> > > > Total number of virtual hosts is about 2000.
> > > >
> > > > --
> > > > BRGDS. Alexey Vlasov.
> > > >
> > > > ---------------------------------------------------------------------
> > > > The official User-To-User support forum of the Apache HTTP Server
> > Project.
> > > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > > >   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > > For additional commands, e-mail: users-help@httpd.apache.org
> > > >
> > > >
> >
> > --
> > BRGDS. Alexey Vlasov.
> >

-- 
BRGDS. Alexey Vlasov.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] High CPU usage with MPM Worker/Event

Posted by Arnab Ganguly <ag...@gmail.com>.
Hi ,
Can you please tell me about your requirements like for example how many
processes do you want to create for handling the request, it seems to me the
number of processes are very high, you can try out increasing the number of
threads per process that way you can reduce the number of processes, also
introduce ThreadLimit param in order to increase the ThreadsPerChild.Let me
know if I can help you.
Thanks
-A

On Sun, Nov 9, 2008 at 10:31 PM, Alexey Vlasov <re...@renton.name> wrote:

> Hi.
>
> I set MaxRequestPerChild = 400 (400 is average quantity of ESTABLISHED
> connections), but it was only worse.
>
> On Thu, Nov 06, 2008 at 12:01:00PM +0530, Arnab Ganguly wrote:
> > Hi,
> > Can you try with Non-zero MaxRequestPerChild value.Keep a value which is
> > equal to number of request are particular process you want to handle.Once
> it
> > is done the process will be killed and a new process is going to be
> > started.I guess your CPU usage should come down.
> > Thanks
> > -A
> >
> > On Thu, Nov 6, 2008 at 2:49 AM, Alexey Vlasov <re...@renton.name>
> wrote:
> >
> > > Hi.
> > >
> > > Working with Apache I noticed one strange thing such as high
> consumption
> > > of CPU.
> > >
> > > It looks like this.
> > > server status:
> > > Parent Server Generation: 2
> > > Server uptime: 27 minutes 54 seconds
> > > Total accesses: 137589 - Total Traffic: 6.1 GB
> > > CPU Usage: u80.91 s52.19 cu0 cs0 - 7.95% CPU load
> > > 82.2 requests/sec - 3.7 MB/second - 46.2 kB/request
> > > 62 requests currently being processed, 38 idle workers
> > >
> > > Especially remarkable is that Top gives - 9999%
> > >  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> > >  11978 www       20   0  458m 111m 2000 S 9999  0.7   0:01.66
> > >  /opt/apache/2.2.9/sbin/httpd -k start
> > >  18151 www       20   0  453m 106m 1996 S    4  0.7   0:00.30
> > >  /opt/apache/2.2.9/sbin/httpd -k start
> > >  18911 www       20   0  333m 100m 1984 S    3  0.6   0:00.09
> > >  /opt/apache/2.2.9/sbin/httpd -k start
> > >  18942 www       20   0  421m 101m 1996 S    2  0.6   0:00.07
> > >  /opt/apache/2.2.9/sbin/httpd -k start
> > >
> > > Accounting also shows high consumption of CPU.
> > >
> > > I don't know how it really should be, but I think it's not quite
> normal.
> > > Can it be peculiarity or feature of my configuration? Well I really
> need
> > > some advice from those who use worker/event. Thanks in advance.
> > >
> > > Configuration of my box:
> > > 2 x Quad-core CPUs Intel Xeon E5345 linux-2.6.25, gcc-4.1.2, libc-2.6.1
> > >
> > > Apache-2.2.9 make options:
> > > CFLAGS="-O3 -march=nocona -pipe -fPIC -fomit-frame-pointer -ftracer
> > > -mfpmath=sse"
> > >
> > > mpm config:
> > > <IfModule mpm_event_module>
> > >    ServerLimit          48
> > >    StartServers          4
> > >    MaxClients         1200
> > >    MinSpareThreads      25
> > >    MaxSpareThreads      75
> > >    ThreadsPerChild      25
> > >    MaxRequestsPerChild   0
> > > </IfModule>
> > >
> > > Example of my virtualhost:
> > > <VirtualHost *>
> > >    <IfModule fcgid_module>
> > >        FCGIWrapper /path_to_phpwrapper
> > >    </IfModule>
> > >    CustomLog path_to_log combined
> > >    ErrorLog path_to_log
> > >    DocumentRoot /path_to_docroot
> > >    SetEnv PHPRC /path_to_php.ini
> > >    <IfModule php5_module>
> > >        php_admin_value *** ***
> > >    </IfModule>
> > >    ServerName example.com
> > >    ServerAlias www.example.com
> > >    ServerAlias www1.example.com
> > >    AddHandler server-parsed .htm
> > >    AddHandler server-parsed .html
> > >    AddHandler server-parsed .shtm
> > >    AddHandler server-parsed .shtml
> > >    RewriteEngine On
> > >    RewriteCond *** ***
> > >    # some rules for backend
> > >    RewriteRule *** *** [NC,L,P]
> > >    SuexecUserGroup user group
> > > </VirtualHost>
> > >
> > > Total number of virtual hosts is about 2000.
> > >
> > > --
> > > BRGDS. Alexey Vlasov.
> > >
> > > ---------------------------------------------------------------------
> > > The official User-To-User support forum of the Apache HTTP Server
> Project.
> > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > >   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > For additional commands, e-mail: users-help@httpd.apache.org
> > >
> > >
>
> --
> BRGDS. Alexey Vlasov.
>

Re: [users@httpd] High CPU usage with MPM Worker/Event

Posted by Alexey Vlasov <re...@renton.name>.
Hi.

I set MaxRequestPerChild = 400 (400 is average quantity of ESTABLISHED
connections), but it was only worse.

On Thu, Nov 06, 2008 at 12:01:00PM +0530, Arnab Ganguly wrote:
> Hi,
> Can you try with Non-zero MaxRequestPerChild value.Keep a value which is
> equal to number of request are particular process you want to handle.Once it
> is done the process will be killed and a new process is going to be
> started.I guess your CPU usage should come down.
> Thanks
> -A
> 
> On Thu, Nov 6, 2008 at 2:49 AM, Alexey Vlasov <re...@renton.name> wrote:
> 
> > Hi.
> >
> > Working with Apache I noticed one strange thing such as high consumption
> > of CPU.
> >
> > It looks like this.
> > server status:
> > Parent Server Generation: 2
> > Server uptime: 27 minutes 54 seconds
> > Total accesses: 137589 - Total Traffic: 6.1 GB
> > CPU Usage: u80.91 s52.19 cu0 cs0 - 7.95% CPU load
> > 82.2 requests/sec - 3.7 MB/second - 46.2 kB/request
> > 62 requests currently being processed, 38 idle workers
> >
> > Especially remarkable is that Top gives - 9999%
> >  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> >  11978 www       20   0  458m 111m 2000 S 9999  0.7   0:01.66
> >  /opt/apache/2.2.9/sbin/httpd -k start
> >  18151 www       20   0  453m 106m 1996 S    4  0.7   0:00.30
> >  /opt/apache/2.2.9/sbin/httpd -k start
> >  18911 www       20   0  333m 100m 1984 S    3  0.6   0:00.09
> >  /opt/apache/2.2.9/sbin/httpd -k start
> >  18942 www       20   0  421m 101m 1996 S    2  0.6   0:00.07
> >  /opt/apache/2.2.9/sbin/httpd -k start
> >
> > Accounting also shows high consumption of CPU.
> >
> > I don't know how it really should be, but I think it's not quite normal.
> > Can it be peculiarity or feature of my configuration? Well I really need
> > some advice from those who use worker/event. Thanks in advance.
> >
> > Configuration of my box:
> > 2 x Quad-core CPUs Intel Xeon E5345 linux-2.6.25, gcc-4.1.2, libc-2.6.1
> >
> > Apache-2.2.9 make options:
> > CFLAGS="-O3 -march=nocona -pipe -fPIC -fomit-frame-pointer -ftracer
> > -mfpmath=sse"
> >
> > mpm config:
> > <IfModule mpm_event_module>
> >    ServerLimit          48
> >    StartServers          4
> >    MaxClients         1200
> >    MinSpareThreads      25
> >    MaxSpareThreads      75
> >    ThreadsPerChild      25
> >    MaxRequestsPerChild   0
> > </IfModule>
> >
> > Example of my virtualhost:
> > <VirtualHost *>
> >    <IfModule fcgid_module>
> >        FCGIWrapper /path_to_phpwrapper
> >    </IfModule>
> >    CustomLog path_to_log combined
> >    ErrorLog path_to_log
> >    DocumentRoot /path_to_docroot
> >    SetEnv PHPRC /path_to_php.ini
> >    <IfModule php5_module>
> >        php_admin_value *** ***
> >    </IfModule>
> >    ServerName example.com
> >    ServerAlias www.example.com
> >    ServerAlias www1.example.com
> >    AddHandler server-parsed .htm
> >    AddHandler server-parsed .html
> >    AddHandler server-parsed .shtm
> >    AddHandler server-parsed .shtml
> >    RewriteEngine On
> >    RewriteCond *** ***
> >    # some rules for backend
> >    RewriteRule *** *** [NC,L,P]
> >    SuexecUserGroup user group
> > </VirtualHost>
> >
> > Total number of virtual hosts is about 2000.
> >
> > --
> > BRGDS. Alexey Vlasov.
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >

-- 
BRGDS. Alexey Vlasov.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] High CPU usage with MPM Worker/Event

Posted by Arnab Ganguly <ag...@gmail.com>.
Hi,
Can you try with Non-zero MaxRequestPerChild value.Keep a value which is
equal to number of request are particular process you want to handle.Once it
is done the process will be killed and a new process is going to be
started.I guess your CPU usage should come down.
Thanks
-A

On Thu, Nov 6, 2008 at 2:49 AM, Alexey Vlasov <re...@renton.name> wrote:

> Hi.
>
> Working with Apache I noticed one strange thing such as high consumption
> of CPU.
>
> It looks like this.
> server status:
> Parent Server Generation: 2
> Server uptime: 27 minutes 54 seconds
> Total accesses: 137589 - Total Traffic: 6.1 GB
> CPU Usage: u80.91 s52.19 cu0 cs0 - 7.95% CPU load
> 82.2 requests/sec - 3.7 MB/second - 46.2 kB/request
> 62 requests currently being processed, 38 idle workers
>
> Especially remarkable is that Top gives - 9999%
>  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
>  11978 www       20   0  458m 111m 2000 S 9999  0.7   0:01.66
>  /opt/apache/2.2.9/sbin/httpd -k start
>  18151 www       20   0  453m 106m 1996 S    4  0.7   0:00.30
>  /opt/apache/2.2.9/sbin/httpd -k start
>  18911 www       20   0  333m 100m 1984 S    3  0.6   0:00.09
>  /opt/apache/2.2.9/sbin/httpd -k start
>  18942 www       20   0  421m 101m 1996 S    2  0.6   0:00.07
>  /opt/apache/2.2.9/sbin/httpd -k start
>
> Accounting also shows high consumption of CPU.
>
> I don't know how it really should be, but I think it's not quite normal.
> Can it be peculiarity or feature of my configuration? Well I really need
> some advice from those who use worker/event. Thanks in advance.
>
> Configuration of my box:
> 2 x Quad-core CPUs Intel Xeon E5345 linux-2.6.25, gcc-4.1.2, libc-2.6.1
>
> Apache-2.2.9 make options:
> CFLAGS="-O3 -march=nocona -pipe -fPIC -fomit-frame-pointer -ftracer
> -mfpmath=sse"
>
> mpm config:
> <IfModule mpm_event_module>
>    ServerLimit          48
>    StartServers          4
>    MaxClients         1200
>    MinSpareThreads      25
>    MaxSpareThreads      75
>    ThreadsPerChild      25
>    MaxRequestsPerChild   0
> </IfModule>
>
> Example of my virtualhost:
> <VirtualHost *>
>    <IfModule fcgid_module>
>        FCGIWrapper /path_to_phpwrapper
>    </IfModule>
>    CustomLog path_to_log combined
>    ErrorLog path_to_log
>    DocumentRoot /path_to_docroot
>    SetEnv PHPRC /path_to_php.ini
>    <IfModule php5_module>
>        php_admin_value *** ***
>    </IfModule>
>    ServerName example.com
>    ServerAlias www.example.com
>    ServerAlias www1.example.com
>    AddHandler server-parsed .htm
>    AddHandler server-parsed .html
>    AddHandler server-parsed .shtm
>    AddHandler server-parsed .shtml
>    RewriteEngine On
>    RewriteCond *** ***
>    # some rules for backend
>    RewriteRule *** *** [NC,L,P]
>    SuexecUserGroup user group
> </VirtualHost>
>
> Total number of virtual hosts is about 2000.
>
> --
> BRGDS. Alexey Vlasov.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>