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