Skip to main content

performance tuning - Apache HTTPD configuration for high load

Good day,




I want to be able to serve at least 7000 (preferably 10k) concurrent requests from my Apache Httpd. I have configured my httpd.conf with MPM worker with the following setup



ServerLimit          330
StartServers 25
ThreadsPerChild 25
MaxClients 7500


My Apache Httpd server does nothing except do a reverse proxy against a cluster of java app servers and some (disk) caching on some static items like HTML/CSS/JS.




While trying to pound my system using JMeter (with about 1k concurrent requests), in a couple of minutes, my server starts to crash but it shows no additional information.



My /etc/security/limits.conf is configured to



*                soft    nofile          10000
* hard nofile 30000
apache soft nproc 8192
apache hard nproc 12288
* soft stack 512

* hard stack 1024


Any ideas how I can reach 7k (or preferably 10k) concurrent requests



[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread

[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48

[Mon Apr 09 21:47:42 2012] [alert] Child 15139 returned a Fatal error... Apache is exiting!
[Mon Apr 09 21:47:42 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Mon Apr 09 21:47:46 2012] [warn] child process 14004 still did not exit, sending a SIGTERM


EDIT (Additional Info):



This is me trying to see how many active httpd processes that I have while the test is running (each command is about 1second apart - i.e. me pressing the up key on my keyboard and then pressing enter)



[franz@webserver ~]$ ps -ef | grep httpd | wc -l

5
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
5
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
8
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
8
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
8
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

9
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
10
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
10
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
10
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
10
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

10
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
11
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
11
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
13
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
13
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

17
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
17
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
25
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
25
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
41
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

41
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
39
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
37
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
37
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l

36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
36
[franz@webserver ~]$ ps -ef | grep httpd | wc -l
1
[franz@webserver ~]$ ps -ef | grep httpd | wc -l


Update:
If I add ThreadStackTrace, it does not crash anymore:

ServerLimit 330
StartServers 25
ThreadsPerChild 25
MaxClients 7500
ThreadStackSize 512



Note: I had stack entries in my limits.conf before adding ThreadStackSize, but I guess that wasn't enough. I had to add both the stack entries in limits.conf and ThreadStackSize in apache httpd.cofn.



However, it still cannot process 7500 concurrent requests. When I do a ps -ef | grep httpd | wc -l, the highest that I see is 42 only (and since one of that process is the grep command, that means it's about 41 apache httpd processes). But I've configured my apache to reach up to 330.




So to see if my apache configuration can really go beyond 40 processes, I tried modifying my StartServers into 50.



ServerLimit          330
StartServers 50
ThreadsPerChild 25
MaxClients 7500
ThreadStackSize 512


The result is the following:




[Wed Apr 11 03:33:40 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Apr 11 03:33:40 2012] [notice] Digest: generating secret for digest authentication ...
[Wed Apr 11 03:33:40 2012] [notice] Digest: done
[Wed Apr 11 03:33:40 2012] [warn] pid file /etc/httpd/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48

[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Wed Apr 11 03:33:40 2012] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.0-fips configured -- resuming normal operations
[Wed Apr 11 03:33:40 2012] [alert] Child 55663 returned a Fatal error... Apache is exiting!



So I guess the main problem is that I cannot spawn more than 40 processes.



Update2:
Since I cannot seem to be able to increase the number of processes, I tried increasing the number of threads. I can go only as far as 30 ThreadsPerChild (from the original ThreadsPerChild). After that, Apache is not able to start because it cannot seem to create worker thread.



Anybody out there has some ideas how to reach 10k concurrent requests with Apache HTTPd?



Why this is not a duplicate:
Pardon, I am not sure why this was marked as duplicate. If the answer to my question is in Can you help me with my capacity planning?, can you kindly highlight how & where? That question is generic in nature while mine is very specific and a more "show me how to specifically reach c10k with apache httpd or point out what's wrong with my setup".




Thanks,



Franz

Comments

Popular posts from this blog

iLO 3 Firmware Update (HP Proliant DL380 G7)

The iLO web interface allows me to upload a .bin file ( Obtain the firmware image (.bin) file from the Online ROM Flash Component for HP Integrated Lights-Out. ) The iLO web interface redirects me to a page in the HP support website ( http://www.hp.com/go/iLO ) where I am supposed to find this .bin firmware, but no luck for me. The support website is a mess and very slow, badly categorized and generally unusable. Where can I find this .bin file? The only related link I am able to find asks me about my server operating system (what does this have to do with the iLO?!) and lets me download an .iso with no .bin file And also a related question: what is the latest iLO 3 version? (for Proliant DL380 G7, not sure if the iLO is tied to the server model)

linux - How can I get my mediawiki to stop thinking I have cookies disabled?

I've searched half a day for how to resolve this issue, and can't figure it out. Shortly after I made my wiki a simple private wiki according to the instructions at Mediawiki's website, it started giving me this weird login error message: Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again. If I remove those private wiki settings, the error disappears, even if I try logging in. But I need it to be a private wiki for only my team. So what do I do? Here's what I've done so far. Just to be safe, after ever change, I try rebooting Apache using: sudo /etc/init.d/apache2 restart In my php.ini file, I have the following set: session.save_path = "/var/lib/php5" session.cookie_secure = secure session.cookie_path = /tmp session.cookie_domain = my server's internal URL (should I even set this? this field was blank before, but not commented out) session.referer_check = Off I ran the following to ensure that the fold...

linux - Awstats - outputting stats for merged Access_logs only producing stats for one server's log

I've been attempting this for two weeks and I've accessed countless number of sites on this issue and it seems there is something I'm not getting here and I'm at a lost. I manged to figure out how to merge logs from two servers together. (Taking care to only merge the matching domains together) The logs from the first server span from 15 Dec 2012 to 8 April 2014 The logs from the second server span from 2 Mar 2014 to 9 April 2014 I was able to successfully merge them using the logresolvemerge.pl script simply enermerating each log and > out_putting_it_to_file Looking at the two logs from each server the format seems exactly the same. The problem I'm having is producing the stats page for the logs. The command I've boiled it down to is /usr/share/awstats/tools/awstats_buildstaticpages.pl -configdir=/home/User/Documents/conf/ -config=example.com awstatsprog=/usr/share/awstats/wwwroot/cgi-bin/awstats.pl dir=/home/User/Documents/parced -month=all -year=all...