BBS水木清华站∶精华区

发信人: althea (痛并快乐着), 信区: Linux        
标  题: [转载] Web Server Tuning 
发信站: BBS 水木清华站 (Tue Nov  9 02:32:02 1999) 
 
           Web Server Tuning 
 
 
 
 Servers 
 
 Apache 
 
 Homepage: apache.org 
 Tuning: the Apache performance tuning guide by Dean Gaudet 
 
 {Min,Max}SpareServers, MaxClients 
 
 As you may know, Apache uses a separate process for every 
 concurrent connection and each of those processes is reused 
 for a (large) number of connections before a new one is 
 forked. This causes the interesting phenomenon that Apache 
 can use a lot of memory during peak loads and shrink again 
 during quiet periods.  
 
 You have to make sure that there are more Apache processes 
 than simultaneous users, otherwise people will have to wait a 
 bit or they can't get a connection to the server at all. 
 Note, however, that it doesn't make sense to set MaxClients 
 higher than your machine can properly support, otherwise your 
 whole machine will go down the drain and nobody will get 
 decent performance... If you increase it above 256, you'll 
 have to increase the HARD_SERVER_LIMIT in include/httpd.h or 
 add -DHARD_SERVER_LIMIT=xxx to CFLAGS in Configuration. 
 You'll also want to add gobs of memory to your box and make 
 sure that you actually have enough network bandwidth to serve 
 all those users, but that's another story :) Very very very 
 high performance people probably want to take a look at Dan 
 Kegel's C10K page.  
 
 The {Min,Max}SpareServers settings are a whole other story. 
 When your machine is only a webserver and it gets a lot of 
 hits, you might want to leave around a decent number of extra 
 servers so there'll be a server ready whenever somebody makes 
 a request. Reasonable figures for a highly loaded machine 
 would be 3 to 8 minimum and 5 to 15 maximum. If you need more 
 than that, you're probably already aware of it :)  
 
 When your machine is also doing a lot of other things and you 
 get less than 100.000 hits a day, then you probably want to 
 have only 1 (one) MinSpareServers and 2 or 3 MaxSpareServers. 
 This means that Apache will leave more memory for other 
 programs and disk cache, leading to better overall system 
 performance.  
 
 Limits 
 
 MaxRequestsPerChild should be set high, to something like 
 10000, unless you're running server-side modules which suffer 
 from memory leaks.  
 
 Disable Unused Modules 
 
 If you don't plan on using dynamically loaded modules you can 
 add -DDYNAMIC_MODULE_LIMIT=0 to the CFLAGS.  
 
 Turn Off Expensive Options 
 
 Anywhere you have AllowOverride set means the server will 
 check for the presence of a .htaccess file. For example, if 
 you have AllowOverride set, and the webserver access a file 
 in /usr/local/apache/htdocs/private-area/ Apache will check 
 /usr, /usr/local, /usr/local/apache, etc. So, don't use 
 .htaccess files if you want high performance. You can set 
 AuthUserFile (and associated Auth directives) in the 
 httpd.conf file instead.  
 
 HostNameLookups is off by default. Leave it that way, unless 
 it's really important. Otherwise, you'll be doing a reverse 
 lookup on every client.  
 
 ExtendedStatus is off by default. Again, leave it that way, 
 unless it's really important for you to have timing stats for 
 your site.  
 
 FollowSymLinks and SymLinksIfOwnerMatch both slow your system 
 down, by causing the webserver to check ownership and 
 filetype for each component in the path, so disable them.  
 
 Use Efficient Server-side scripting 
 
 If you do a lot of CGI, consider using mod_perl. The 
 Apache::Registry module can in most cases speed up your CGI 
 requests with no actual changes to your code. Plus, you can 
 do a whole lot more with mod_perl (like using handlers 
 instead of CGI, which can be far faster than CGI). See 
 http://perl.apache.org for more details.  
 
 Take advantage of kernel features 
 
 If you're running a Linux kernel that supports wake-one 
 semantics for accept(), configure Apache to take advantage of 
 that, e.g.  
 
 env CFLAGS='-DSINGLE_LISTEN_UNSERIALIZED_ACCEPT' ./configure  
 
 See also http://www.kegel.com/mindcraft_redux.html#tips and 
 http://home.att.net/~jageorge/performance.html#Apache for 
 more tips.  
 
 OS Tweaks 
 
 As of this writing (Jun 3 1999), the best kernel to run on 
 Intel systems is 2.2.9 (plus the 2.2.9_andrea3 patch for SMP 
 machines). See http://www.kegel.com/mindcraft_redux.html for 
 more tips.  
 
 Limits 
 
 The 2.2 kernel lets you tune some limits at runtime. For 
 example,  
 
 echo 32768 > /proc/sys/fs/file-max 
 echo 65536 > /proc/sys/fs/inode-max 
 
 Other limits are harder to change. For example, to increase 
 the number of tasks allowed, you may need to edit 
 include/linux/tasks.h and rebuild the kernel. (One person 
 recommended changing NR_TASKS from 512 to 2048, and changing 
 MIN_TASKS_LEFT_FOR_ROOT to 24.)  
 
-- 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 162.105.179.11] 

BBS水木清华站∶精华区