Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Sun T5140 server with 8GB of memory and two 4-core T-Series CPU's (128 max threads). This server is a dedicated web server. Based on the premise that I'm willing to allocate 1/2 of the servers physical memory to Apache (4GB), how do I calculate the following Apache settings to obtain the full potential of that 4GB of memory? I cannot find a clear way to calculate this on the web. PS, I'm using Apache 2.2.22 on Solaris 10 OS.

StartServers         ??
MinSpareServers      ??
MaxSpareServers      ??
ServerLimit          ??
MaxClients           ??
MaxRequestsPerChild  ??


(XXXXXXXXXXXX)-root> ps -elf | head -n 1 ; ps -elf | grep http
 F S      UID   PID  PPID   C PRI NI     ADDR     SZ    WCHAN    STIME TTY         TIME CMD
 0 S  webuser 29751 12656   0  40 20        ?  25288        ? 10:53:17 ?           0:03 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser   420 12656   0  45 20        ?  24136        ? 10:53:22 ?           0:02 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser 18563 12656   0  40 20        ?  27952        ? 10:51:51 ?           0:12 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser 18837 12656   0  40 20        ?  24160        ? 10:51:53 ?           0:08 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser  2357 12656   0  48 20        ?  22976        ? 10:53:37 ?           0:01 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser 18838 12656   0  40 20        ?  24176        ? 10:51:53 ?           0:06 /usr/local/apache2/bin/httpd -k sta
 0 S  webuser 29750 12656   0  40 20        ?  23016        ? 10:53:17 ?           0:02 /usr/local/apache2/bin/httpd -k sta



   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
  9555 webuser   243M  142M sleep   50    0   0:00:44 1.0% httpd/1
 19131 webuser   229M  118M cpu102  30    0   0:00:20 0.9% httpd/1
  9538 webuser   232M  130M cpu74    0    0   0:00:46 0.8% httpd/1
  9550 webuser   230M  128M cpu24   39    0   0:00:55 0.6% httpd/1
  9534 webuser   232M  130M cpu69    0    0   0:00:34 0.6% httpd/1
  9556 webuser   245M  142M cpu2    24    0   0:00:47 0.6% httpd/1
  2259 webuser   232M  122M cpu87    9    0   0:01:08 0.5% httpd/1
 19038 webuser   229M  118M sleep   59    0   0:00:16 0.5% httpd/1
  2149 webuser   232M  121M sleep   59    0   0:01:13 0.5% httpd/1
 19036 webuser   232M  120M sleep   59    0   0:00:16 0.5% httpd/1
  9526 webuser   230M  118M sleep   59    0   0:00:34 0.5% httpd/1
 19034 webuser   208M   97M cpu22    0    0   0:00:09 0.4% httpd/1
  9563 webuser   232M  129M sleep   59    0   0:00:26 0.4% httpd/1
  4101 webuser   234M  132M sleep   39    0   0:01:04 0.4% httpd/1
 15735 webuser   232M  120M sleep   39    0   0:00:28 0.4% httpd/1
  2042 webuser   232M  122M sleep   59    0   0:00:49 0.3% httpd/1
 26119 webuser   232M  131M cpu99    9    0   0:01:42 0.3% httpd/1
 19035 webuser   229M  117M sleep   39    0   0:00:12 0.3% httpd/1
 19134 webuser   229M  116M sleep   39    0   0:00:09 0.2% httpd/1
  9553 webuser   229M  126M sleep   39    0   0:00:40 0.2% httpd/1
 18942 webuser   229M  117M sleep   39    0   0:00:07 0.2% httpd/1
  9308 webuser   230M  127M sleep   49    0   0:00:32 0.2% httpd/1
  9564 webuser   246M  133M sleep   59    0   0:00:33 0.2% httpd/1
  7154 webuser   229M  127M sleep   59    0   0:00:29 0.2% httpd/1
 19040 webuser   229M  116M sleep   59    0   0:00:08 0.2% httpd/1
  1275 root     3368K 2608K cpu13    0    0   0:25:42 0.2% http_services.s/1
  9531 webuser   232M  129M sleep   49    0   0:00:19 0.2% httpd/1
 19146 webuser   198M   85M cpu5    39    0   0:00:03 0.2% httpd/1
 19135 webuser   203M   91M sleep   49    0   0:00:05 0.1% httpd/1
  9545 webuser   232M  128M sleep   59    0   0:00:21 0.1% httpd/1
  9543 webuser   230M  117M sleep   59    0   0:00:13 0.1% httpd/1
  9301 webuser   229M  128M sleep   59    0   0:00:16 0.1% httpd/1
  6685 tomcat    615M  289M sleep   59    0   0:10:55 0.1% jsvc/58
  9410 webuser   232M  121M sleep   59    0   0:00:16 0.0% httpd/1
 17811 webuser   156M   11M sleep   39    0   0:00:00 0.0% httpd/1
Total: 98 processes, 338 lwps, load averages: 14.38, 12.06, 8.03

Detail into what each process is doing - for example this one:

 20225 webuser   189M   89M sleep   59    0   0:00:38 0.2% httpd/1

is shown here using the pmap command:

(XXXXXXXXX-01)-root> pmap -x 20225
20225:  /usr/local/apache2/bin/httpd -k start
20225:  /usr/local/apache2/bin/httpd -k start
20225:  /usr/local/apache2/bin/httpd -k start
20225:  /usr/local/apache2/bin/httpd -k start
20225:  /usr/local/apache2/bin/httpd -k start
 Address  Kbytes     RSS    Anon  Locked Mode   Mapped File
00010000     648     648       -       - r-x--  httpd
000C0000      32      32      32       - rwx--  httpd
000C8000      32      32      16       - rwx--    [ heap ]
000D0000   37440   37376   36864       - rwx--    [ heap ]
F5400000  131072   50088       -       - rw-s-  dev:361,5 ino:45405806
FD630000      64      64       -       - rw-s-    [ anon ]
FD650000       8       8       -       - rw-s-    [ anon ]
FD690000       8       8       -       - rw-s-  dev:256,65544 ino:282776
FD6A0000       8       8       -       - r-x--  mod_expires.so
FD6B0000       8       8       -       - rwx--  mod_expires.so
FD6C0000      96      96       -       - r-x--  xcache.so
FD6E6000       8       8       8       - rwx--  xcache.so
FD6E8000       8       8       8       - rwx--  xcache.so
FD6F0000      64      64      64       - rwx--    [ anon ]
FD710000      64      64       -       - rwx--    [ anon ]
FD730000      16      16       -       - r-x--  mod_deflate.so
FD742000      16      16       -       - rwx--  mod_deflate.so
FD750000     368     352       -       - r-x--  mod_jk-1.2.31-httpd-2.2.X.so
FD7BA000      16      16       8       - rwx--  mod_jk-1.2.31-httpd-2.2.X.so
FD7BE000       8       8       8       - rwx--  mod_jk-1.2.31-httpd-2.2.X.so
FD7D0000       8       8       -       - r-x--  libavl.so.1
FD7E2000       8       8       -       - rwx--  libavl.so.1
FD7F0000      16      16       -       - r-x--  libmp.so.2
FD804000       8       8       -       - rwx--  libmp.so.2
FD810000      32      32       -       - r-x--  libuutil.so.1
FD828000       8       8       8       - rwx--  libuutil.so.1
FD830000       8       8       -       - r-x--  libdoor.so.1
FD842000       8       8       -       - rwx--  libdoor.so.1
FD850000      96      96       -       - r-x--  libscf.so.1
FD878000       8       8       -       - rwx--  libscf.so.1
FD880000       8       8       -       - rwx--    [ anon ]
FD890000       8       8       -       - r-x--  libmd_psr.so.1
FD8A2000       8       8       -       - rwx--  libmd_psr.so.1
FD8B0000     192      64       -       - r-x--  libfontconfig.so.1.4.4
FD8EE000      16      16       -       - rwx--  libfontconfig.so.1.4.4
FD900000    1248     320       -       - r-x--  libcrypto.so.0.9.8
FDA46000      96      96       -       - rwx--  libcrypto.so.0.9.8
FDA5E000       8       -       -       - rwx--  libcrypto.so.0.9.8
FDA70000     120      64       -       - r-x--  libjpeg.so.62.0.0
FDA9C000       8       8       -       - rwx--  libjpeg.so.62.0.0
FDAA0000     264     128       -       - r-x--  libssl.so.0.9.8
FDAF2000      24      24       -       - rwx--  libssl.so.0.9.8
FDB00000    1288     904       -       - r-x--  libxml2.so.2.7.7
FDC50000      56      56       8       - rwx--  libxml2.so.2.7.7
FDC70000      56      48       -       - r-x--  libsec.so.1
FDC8E000      16      16       -       - rwx--  libsec.so.1
FDC92000       8       -       -       - rwx--  libsec.so.1
FDCA0000     128     128       -       - r-x--  libssh2.so.1.0.1
FDCCE000      16      16       -       - rwx--  libssh2.so.1.0.1
FDCE0000      24      24       -       - r-x--  libgen.so.1
FDCF6000       8       8       -       - rwx--  libgen.so.1
FDD00000      88      72       -       - r-x--  libsasl2.so.2.0.21
FDD24000       8       8       -       - rwx--  libsasl2.so.2.0.21
FDD30000     192     192       -       - r-x--  libidn.so.11.6.2
FDD6E000      16      16       -       - rwx--  libidn.so.11.6.2
FDD80000    1296     200       -       - r-x--  libX11.so.4
FDED4000      24      24       -       - rwx--  libX11.so.4
FDEE0000       8       -       -       - rw---  libX11.so.4
FDF00000     440     392       -       - r-x--  libfreetype.so.6.6.0
FDF7C000      24      24       -       - rwx--  libfreetype.so.6.6.0
FDF90000     328     320       -       - r-x--  libcurl.so.4.2.0
FDFF0000      24      24       8       - rwx--  libcurl.so.4.2.0
FE000000    8832    8768       -       - r-x--  libphp5.so
FE8AE000     376     376      72       - rwx--  libphp5.so
FE90C000      16       8       -       - rwx--  libphp5.so
FE910000      64      64      64       - rwx--  libphp5.so
FE920000       8       8       8       - rwx--  libphp5.so
FE930000     248      80       -       - r-x--  libjpeg.so.8.0.1
FE97C000       8       8       -       - rwx--  libjpeg.so.8.0.1
FE980000      80      80       -       - r-x--  libz.so.1.2.5
FE9A2000       8       8       -       - rwx--  libz.so.1.2.5
FE9B0000     144     136       -       - r-x--  libpng12.so.0.44.0
FE9E2000       8       8       -       - rwx--  libpng12.so.0.44.0
FE9F0000     120     112       -       - r-x--  libgd.so.2.0.0
FEA1C000     128      24       -       - rwx--  libgd.so.2.0.0
FEA3C000       8       -       -       - rwx--  libgd.so.2.0.0
FEA40000     240     216       -       - r-x--  libldap-2.4.so.2.5.6
FEA8A000      16      16       8       - rwx--  libldap-2.4.so.2.5.6
FEA90000     240     240       -       - r-x--  libmysqlclient.so.15.0.0
FEADA000     160     160      72       - rwx--  libmysqlclient.so.15.0.0
FEB10000       8       8       -       - rw-s-    [ anon ]
FEB20000      56      16       -       - r-x--  libXpm.so.4.11
FEB3C000       8       8       -       - rwx--  libXpm.so.4.11
FEB40000      40      32       -       - r-x--  libintl.so.8.0.2
FEB58000       8       8       -       - rwx--  libintl.so.8.0.2
FEB60000       8       8       -       - rwx--    [ anon ]
FEB70000      40      40       -       - r-x--  liblber-2.4.so.2.5.6
FEB88000       8       8       -       - rwx--  liblber-2.4.so.2.5.6
FEBA0000     240     240       -       - r-x--  libresolv.so.2
FEBE0000       8       8       -       - rwx--    [ anon ]
FEBEC000      16      16       -       - rwx--  libresolv.so.2
FEC00000    1216    1168       -       - r-x--  libc.so.1
FED30000      40      40      32       - rwx--  libc.so.1
FED3A000       8       8       -       - rwx--  libc.so.1
FED40000       8       8       -       - rw-s-    [ anon ]
FED50000      80      80       -       - r-x--  libmd.so.1
FED70000       8       8       -       - rwx--    [ anon ]
FED74000       8       8       -       - rwx--  libmd.so.1
FED80000     584     584       -       - r-x--  libnsl.so.1
FEE22000      40      40      16       - rwx--  libnsl.so.1
FEE2C000      24      16      16       - rwx--  libnsl.so.1
FEE40000      64      64       -       - rwx--    [ anon ]
FEE60000      32      32       -       - r-x--  libaio.so.1
FEE70000       8       8       -       - rwx--    [ anon ]
FEE78000       8       8       8       - rwx--  libaio.so.1
FEE80000      40      32       -       - r-x--  libgcc_s.so.1
FEE90000       8       8       -       - rwx--    [ anon ]
FEE98000       8       8       -       - rwx--  libgcc_s.so.1
FEEA0000      48      48       -       - r-x--  libsocket.so.1
FEEB0000       8       8       -       - rwx--    [ anon ]
FEEBC000       8       8       -       - rwx--  libsocket.so.1
FEEC0000      24      24       -       - r-x--  librt.so.1
FEED0000       8       8       -       - r--s-  dev:361,6 ino:57121908
FEED6000       8       8       -       - rwx--  librt.so.1
FEEE0000       8       8       -       - r-x--  libsendfile.so.1
FEEF2000       8       8       -       - rwx--  libsendfile.so.1
FEF00000     912      64       -       - r-x--  libiconv.so.2.5.0
FEFF2000       8       8       -       - rwx--  libiconv.so.2.5.0
FF000000     144     144       -       - r-x--  libapr-1.so.0.4.5
FF032000      16      16       8       - rwx--  libapr-1.so.0.4.5
FF040000     128      64       -       - r-x--  libexpat.so.1.5.2
FF06E000      16      16       -       - rwx--  libexpat.so.1.5.2
FF080000     608     328       -       - r-x--  libm.so.2
FF126000      24      24       -       - rwx--  libm.so.2
FF130000      16      16       -       - r-x--  libuuid.so.1
FF140000       8       8       -       - rwx--    [ anon ]
FF144000       8       8       -       - rwx--  libuuid.so.1
FF150000     112     104       -       - r-x--  libaprutil-1.so.0.4.1
FF170000      24      16      16       - rwx--    [ anon ]
FF17A000       8       8       8       - rwx--  libaprutil-1.so.0.4.1
FF180000    1432    1352       -       - r-x--  libcrypto.so.1.0.0
FF2F0000       8       8       -       - rwx--    [ anon ]
FF2F4000      88      88      16       - rwx--  libcrypto.so.1.0.0
FF30A000       8       8       8       - rwx--  libcrypto.so.1.0.0
FF310000       8       8       -       - r-x--  libc_psr.so.1
FF320000       8       8       -       - r-x--  libdl.so.1
FF32E000       8       8       -       - rwxs-    [ anon ]
FF332000       8       8       -       - rwx--  libdl.so.1
FF340000     296     296       -       - r-x--  libssl.so.1.0.0
FF390000       8       8       -       - rwx--    [ anon ]
FF398000      24      24       -       - rwx--  libssl.so.1.0.0
FF3A0000      16      16       -       - r-x--  libpthread.so.1
FF3B0000     208     208       -       - r-x--  ld.so.1
FF3F0000       8       8       -       - rwx--    [ anon ]
FF3F4000       8       8       8       - rwx--  ld.so.1
FF3F6000       8       8       8       - rwx--  ld.so.1
FFBF0000      64      64      64       - rwx--    [ stack ]
-------- ------- ------- ------- -------
total Kb  193920  108232   37464       -
share|improve this question

closed as not constructive by Michael Hampton, SvW, longneck, mgorven, Tim Brigham Feb 11 '13 at 19:35

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Figure out how much RAM your average Apache process uses. Divide 4GB by that amount. Set that as the ServerLimit. –  ceejayoz Feb 11 '13 at 15:45
    
I've added that information to my question, looks like its around 25k per httpd process, that seems low. Based on that the calculation would be 163,840 MaxClients?!!! That cant be right... –  CocoaNoob Feb 11 '13 at 16:00
    
PS - why the -1 already? –  CocoaNoob Feb 11 '13 at 16:02
    
Open-ended questions that don't demonstrate an existing problem that you are trying to solve are generally frowned upon. Basically, anything that solicits extended discussion because it does not have a cut and dry "answer" (or any topic you could write/buy a book about) isn't good for Q&A format. "How do I set up X" is one of the common cases. –  Andrew B Feb 11 '13 at 19:18
add comment

2 Answers 2

According to the ps man page, the SZ column is:

The size (in  pages) of  the  swappable
process's image in main memory.

You can use the pagesize command to get the default page size on your system, but it would be more helpful to see the RSS column in the ps output.

In any event, this will give you some idea how much RAM each Apache process is using, but due to shared memory and depending on your configuration, the actual total usage may be very different.

It would be helpful to know: 1) what is Apache doing? 2) If it's a dedicated machine (Apache only), why reserve 4GB of RAM?

Regardless, you really only need to worry about ServerLimit and MaxClients. The other settings are designed to minimize Apache killing and starting new servers, which takes resources.

If you assume 80MB of RAM per process (which would be absurd, but not impossible -- a Drupal site + mod_php + no caching for example could use that much):

StartServers         30
MinSpareServers      10
MaxSpareServers      20
ServerLimit          50
MaxClients           50
MaxRequestsPerChild  1000

Try that, watch memory usage with top or free (ignore buffers and cache), and gradually increase MaxClients and ServerLimit (keep them the same). Keep in mind that this approach errs heavily on the side of being too conservative -- that is a much lower value for MaxClients than is probably safe. Visitors will see errors once MaxClients is hit, so if the site is very busy, start higher -- you have plenty of RAM and swap to spare.

share|improve this answer
    
thanks for the info, right now we dont have MaxClients or ServerLimit specified in the conf file so they are using the default limits. I.E. 256 for MaxClients, not sure what the default is for ServerLimit. Either way, the error we're getting is [Mon Feb 11 09:38:06 2013] [error] server reached MaxClients setting, consider raising the MaxClients setting - this said I'm guessing that specifying it with a setting of 500 is a good starting point. And as per your recommendation we'll set ServerLimit to 500 as well - sound like a good plan to you? –  CocoaNoob Feb 11 '13 at 18:22
    
PS - pagesize returns 8192. I dont see an RSS column for ps on Solaris, researching more on this now. –  CocoaNoob Feb 11 '13 at 18:28
    
RSS is reported using the prstat command - I've included that information in my question above. –  CocoaNoob Feb 11 '13 at 18:29
    
It seems that, in fact, your Apache processes /are/ using an insanely high amount of RAM. Is there a reason for this? What's Apache doing? –  xofer Feb 11 '13 at 18:36
    
Serving a production website, about 1 million page views per month. Running Apache, PHP, WordPress, and Tomacat is hosting a few Java based web applications on the site. –  CocoaNoob Feb 11 '13 at 18:47
add comment

The answer, and probably why you're being downvoted, is "it depends on what you're trying to do". You did not specify what type of content you were hosting (static? dynamic? php? proxying?), what type of load you're expecting, etc. It's sort of like asking what type of RAID is the best given X number of hard drives at Y speed without specifying what work the server is performing and what your requirements are. As an example, you have mod_jk and jsvc loaded without even mentioning that this is an application server, assuming that they're not just sitting there and doing nothing.

There are any number of answers you can receive that will exhaustively cover one potential approach and/or MPM, but unless you focus your question on a specific use case, it will end up being a very open ended discussion that doesn't lend itself to having a "right" answer.

share|improve this answer
add comment

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