0

I am not into sys administration but I know when the server is maxed-out. All http requests take too much time to complete. I am attaching the "top" processes running at my server.

Is this normal? What am I doing wrong?

(I can paste more files if requested.)

Please, note that the server is for testing purposes and the only user who accesses it, is me at the moment.

running 'top' shows too many Apache process

Also, this is my apache2.conf file:

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>


<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

DefaultType None

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

Include mods-enabled/*.load
Include mods-enabled/*.conf

Include ports.conf

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include conf.d/

Include sites-enabled/

This is the output of server-status:

Apache Server Status for localhost

Server Version: Apache/2.2.22 (Debian) PHP/5.4.39-0+deb7u2 mod_wsgi/3.3 Python/
    2.7.3
Server Built: Jul 24 2014 15:34:00

-------------------------------------------------------------------------------

Current Time: Tuesday, 23-Jun-2015 11:38:02 BST
Restart Time: Tuesday, 23-Jun-2015 11:33:36 BST
Parent Server Generation: 0
Server uptime: 4 minutes 25 seconds
Total accesses: 54 - Total Traffic: 58 kB
CPU Usage: u25.08 s1.64 cu0 cs0 - 10.1% CPU load
.204 requests/sec - 224 B/second - 1099 B/request
4 requests currently being processed, 3 idle workers

W_WW__..W.......................................................
................................................................
................................................................
................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process


Srv   PID  Acc M CPU   SS   Req  Conn Child Slot    Client            VHost                                      Request
0-0  13852 0/4 _ 5.07 2218 90    0.0  0.00  0.00 11.11.11.111 server1.project NULL
           /4
           22/

1-0  13854 22/ W 5.87 2235 0     42.2 0.04  0.04 11.11.11.111 server2.project2   GET /ajax/period_stats/?object_id=16106&period_unit=month&perio
           22

2-0  13855 0/9 _ 4.87 2211 460   0.0  0.00  0.00 11.11.11.111 server1.project NULL
           /9

3-0  13857 0/8 _ 4.54 2218 341   0.0  0.01  0.01 11.11.11.111 server1.project NULL
           /8

4-0  13858 6/6 W 4.61 2224 0     1.6  0.00  0.00 11.11.11.111 server2.project2   GET /ajax/period_stats/?object_id=16110&period_unit=month&perio
           /6

5-0  13878 3/3 W 4.28 2224 0     0.5  0.00  0.00 11.11.11.111 server2.project2   GET /ajax/period_stats/?object_id=16104&period_unit=hour&period
           /3

6-0  13881 0/0 W 0.00 2203 0     0.0  0.00  0.00 11.11.11.111 server2.project2   GET /ajax/period_stats/?object_id=16104&period_unit=hour&period
           /0

7-0  13882 0/2 _ 5.27 2193 12446 0.0  0.00  0.00 11.11.11.111 server1.project NULL
           /2

8-0  13885 0/1 _ 0.01 1086 1     0.0  0.00  0.00 localhost    server1.project GET /server-status HTTP/1.0
           /1

9-0  13886 0/0 W 0.00 0    0     0.0  0.00  0.00 ::1          server1.project GET /server-status HTTP/1.0
           /0

10-0 13887 0/1 _ 5.92 1317 14928 0.0  0.00  0.00 11.11.11.111 server2.project2   POST /core/user/exits/ HTTP/1.1
           /1

11-0 13888 0/1 _ 0.00 62   1     0.0  0.00  0.00 localhost    server1.project GET /server-status HTTP/1.0
           /1
5
  • 1
    One thing you need to know is which multi processor module you are using, as you are using Ubuntu you can get that information running /usr/sbin/apache2 -V | grep MPM, that would allow you to know if you are using prefork, worker or event. Another thing you can do is enable the extended status (detailed description in rackspace.com/knowledge_center/article/… ). That will help you guessing what's happening. Jun 22 '15 at 16:43
  • thanks. I did as you said and I got this: Server MPM: Prefork -D APACHE_MPM_DIR="server/mpm/prefork". Does that say anything to you?
    – xpanta
    Jun 23 '15 at 8:59
  • Please don't paste pictures of text. Run top in a terminal, copy and paste the output instead.
    – Jenny D
    Jun 23 '15 at 9:51
  • 1
    You don't say what sort of web application you are running on top of Apache. If you are running a Python web application, based on mod_wsgi being shown in server tokens, go read blog.dscpl.com.au/2012/10/… Jun 23 '15 at 22:58
  • Thanks. Switching Apache to Daemon mode, seems to resolve the issue. Make your comment an answer so I can accept it.
    – xpanta
    Jul 6 '15 at 9:27
1

As you are using the prefork module and the server is just for testing you could change the values: seeing that you have 2GB of RAM I would put it a little smaller values:

<IfModule mpm_prefork_module>
    StartServers          2
    MinSpareServers       2
    MaxSpareServers       4
    MaxClients           16
    MaxRequestsPerChild  50
</IfModule>

Those are "random" numbers as I don't know your application or the data you are managing, but it should be enough to do testing with less impact. If you are going to go live and expect more users you will need to tune that configuration.

You can see in Apache documentation the explanation of those values, but the short version is that with prefork MPM Apache will create a pool of processes to serve the requests, with the suggested configuration that pool will be smaller.

1
  • thanks that normalized the thing in some way. I have also updated my question with the server-status output.
    – xpanta
    Jun 23 '15 at 10:36

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