??xml version="1.0" encoding="utf-8" standalone="yes"?>久久综合亚洲色一区二区三区,国产亚州精品女人久久久久久 ,91久久精品国产91性色也http://m.shnenglu.com/qywyh/category/8148.html?>blogzh-cnTue, 02 Sep 2008 11:00:58 GMTTue, 02 Sep 2008 11:00:58 GMT60【{】Apache的prefork模式和worker模式http://m.shnenglu.com/qywyh/articles/60728.html?/dc:creator>?/author>Tue, 02 Sep 2008 10:19:00 GMThttp://m.shnenglu.com/qywyh/articles/60728.htmlhttp://m.shnenglu.com/qywyh/comments/60728.htmlhttp://m.shnenglu.com/qywyh/articles/60728.html#Feedback0http://m.shnenglu.com/qywyh/comments/commentRss/60728.htmlhttp://m.shnenglu.com/qywyh/services/trackbacks/60728.htmlApache的prefork模式和worker模式

prefork模式
q个多\处理模块(MPM)实现了一个非U程型的、预z的web服务器,它的工作方式cM于Apache 1.3。它适合于没有线E安全库Q需要避免线E兼Ҏ问题的pȝ。它是要求将每个h怺独立的情况下最好的MPMQ这栯一个请求出现问题就不会影响到其他请求?/p>

q个MPMh很强的自我调节能力,只需要很的配置指o调整。最重要的是MaxClients讄Z个够大的数g处理潜在的请求高峎ͼ同时又不能太大,以致需要用的内存出物理内存的大?/p>

worker模式
此多路处理模?MPM)使网l服务器支持混合的多U程多进E。由于用线E来处理hQ所以可以处理v量请求,而系l资源的开销于Zq程的MPM。但是,它也使用了多q程Q每个进E又有多个线E,以获得基于进E的MPM的稳定性?/p>

控制q个MPM的最重要的指令是Q控制每个子q程允许建立的线E数的ThreadsPerChild指oQ和控制允许建立的ȝE数的MaxClients指o?/p>

prefork和worker模式的切?/strong>
1.当前的prefork模式启动文g改名
mv httpd httpd.prefork
2.worker模式的启动文件改?br>mv httpd.worker httpd
3.修改Apache配置文g
vi /usr/local/apache2/conf/extra/httpd-mpm.conf
扑ֈ里边的如下一D,可适当修改负蝲{参敎ͼ
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
4.重新启动服务
/usr/local/apache2/bin/apachectl restart
卛_换成worker方式启动apache2

处于E_性和安全性考虑Q不更换apache2的运行方式,使用pȝ默认prefork卛_。另外很多php模块不能工作在worker模式下,例如redhat linux自带的php也不能支持线E安全。所以最好不要切换工作模式?/p>

prefork和worker模式的比?/strong>
prefork模式使用多个子进E,每个子进E只有一个线E。每个进E在某个定的时间只能维持一个连接。在大多数^CQPrefork MPM在效率上要比Worker MPM要高Q但是内存用大得多。prefork的无U程设计在某些情况下比worker更有优势Q它可以使用那些没有处理好线E安全的W三Ҏ块,q且对于那些U程调试困难的^台而言Q它也更Ҏ调试一些?/p>

worker模式使用多个子进E,每个子进E有多个U程。每个线E在某个定的时间只能维持一个连接。通常来说Q在一个高量的HTTP服务器上QWorker MPM是个比较好的选择Q因为Worker MPM的内存用比Prefork MPM要低得多。但worker MPM也由不完善的地方Q如果一个线E崩溃,整个q程׃q同其所有线E一?#8221;L”.׃U程׃n内存I间Q所以一个程序在q行时必被pȝ识别?#8221;每个U程都是安全?#8221;?/p>

ȝ来说Qprefork方式速度要稍高于workerQ然而它需要的cpu和memory资源也稍多于woker?/p>

prefork模式配置详解
<IfModule mpm_prefork_module>
ServerLimit 256
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
MaxRequestsPerChild 0
</IfModule>
ServerLimit
默认的MaxClient最大是256个线E?如果惌|更大的|q加上ServerLimitq个参数?0000是ServerLimitq个参数的最大倹{如果需要更大,则必ȝ译apache,此前都是不需要重新编译Apache?br>生效前提Q必L在其他指令的前面

StartServers
指定服务器启动时建立的子q程数量Qprefork默认??/p>

MinSpareServers
指定I闲子进E的最数量,默认?。如果当前空闲子q程数少于MinSpareServers Q那么Apache以最大每U一个的速度产生新的子进E。此参数不要讄太大?/p>

MaxSpareServers
讄I闲子进E的最大数量,默认?0。如果当前有过MaxSpareServers数量的空闲子q程Q那么父q程杀d余的子进E。此参数不要讄太大。如果你该指o的D|ؓ比MinSpareServers,Apache会自动其修改?#8221;MinSpareServers+1″?/p>

MaxClients
限定同一旉客户端最大接入请求的数量(单个q程q发U程?Q默认ؓ256。Q何超qMaxClients限制的请求都进入等候队?一旦一个链接被释放Q队列中的请求将得到服务。要增大q个|你必d时增大ServerLimit?/p>

MaxRequestsPerChild
每个子进E在其生存期内允怼服的最大请求数量,默认?0000.到达MaxRequestsPerChild的限制后Q子q程会l束。如果MaxRequestsPerChild?#8221;0″Q子q程永q不会结束。将MaxRequestsPerChild讄成非零值有两个好处Q?br>1.可以防止(偶然?内存泄漏无限q行Q从而耗尽内存?br>2.l进E一个有限寿命,从而有助于当服务器负蝲减轻的时候减活动进E的数量?/p>

worker模式配置详解
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

StartServers
服务器启动时建立的子q程敎ͼ默认值是”3″?/p>

MaxClients
允许同时伺服的最大接入请求数?最大线E数?。Q何超qMaxClients限制的请求都进入等候队列。默认值是”400″,16(ServerLimit)乘以25(ThreadsPerChild)的结果。因此要增加MaxClients的时候,你必d时增加ServerLimit的倹{?/p>

MinSpareThreads
最空闲线E数,默认值是”75″。这个MPM基于整个服务器监视I闲U程数。如果服务器中ȝI闲U程数太,子进E将产生新的I闲U程?/p>

MaxSpareThreads
讄最大空闲线E数。默认值是”250″。这个MPM基于整个服务器监视I闲U程数。如果服务器中ȝI闲U程数太多,子进E将杀d余的I闲U程。MaxSpareThreads的取D围是有限制的。Apache按照如下限制自动修正你讄的|worker要求其大于等于MinSpareThreads加上ThreadsPerChild的和?/p>

ThreadsPerChild
每个子进E徏立的帔R的执行线E数。默认值是25。子q程在启动时建立q些U程后就不再建立新的U程了?/p>

MaxRequestsPerChild
讄每个子进E在其生存期内允怼服的最大请求数量。到达MaxRequestsPerChild的限制后Q子q程会l束。如果MaxRequestsPerChild?#8221;0″Q子q程永q不会结束。将MaxRequestsPerChild讄成非零值有两个好处Q?br>1.可以防止(偶然?内存泄漏无限q行Q从而耗尽内存?br>2.l进E一个有限寿命,从而有助于当服务器负蝲减轻的时候减活动进E的数量?br>注意对于KeepAlive链接Q只有第一个请求会被计数。事实上Q它改变了每个子q程限制最大链接数量的行ؓ?/p>



]]>
【manual】Apache MPM preforkhttp://m.shnenglu.com/qywyh/articles/60673.html?/dc:creator>?/author>Tue, 02 Sep 2008 03:27:00 GMThttp://m.shnenglu.com/qywyh/articles/60673.htmlhttp://m.shnenglu.com/qywyh/comments/60673.htmlhttp://m.shnenglu.com/qywyh/articles/60673.html#Feedback0http://m.shnenglu.com/qywyh/comments/commentRss/60673.htmlhttp://m.shnenglu.com/qywyh/services/trackbacks/60673.html

Apache MPM prefork

Available Languages:  de  |  en  |  ja 

Description: Implements a non-threaded, pre-forking web server
Status: MPM
Module?Identifier: mpm_prefork_module
Source?File: prefork.c

Summary

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.

This MPM is very self-regulating, so it is rarely necessary to adjust its configuration directives. Most important is that MaxClients be big enough to handle as many simultaneous requests as you expect to receive, but small enough to assure that there is enough physical RAM for all processes.

top

How it Works

A single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.

The StartServers, MinSpareServers, MaxSpareServers, and MaxClients regulate how the parent process creates children to serve requests. In general, Apache is very self-regulating, so most sites do not need to adjust these directives from their default values. Sites which need to serve more than 256 simultaneous requests may need to increase MaxClients, while sites with limited memory may need to decrease MaxClients to keep the server from thrashing (swapping memory to disk and back). More information about tuning process creation is provided in the performance hints documentation.

While the parent process is usually started as root under Unix in order to bind to port 80, the child processes are launched by Apache as a less-privileged user. The User and Group directives are used to set the privileges of the Apache child processes. The child processes must be able to read all the content that will be served, but should have as few privileges beyond that as possible.

MaxRequestsPerChild controls how frequently the server recycles processes by killing old ones and launching new ones.

top

MaxSpareServers Directive

Description: Maximum number of idle child server processes
Syntax: MaxSpareServers number
Default: MaxSpareServers 10
Context: server config
Status: MPM
Module: prefork

The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.

Tuning of this parameter should only be necessary on very busy sites. Setting this parameter to a large number is almost always a bad idea. If you are trying to set the value lower than MinSpareServers, Apache will automatically adjust it to MinSpareServers + 1.

See also

top

MinSpareServers Directive

Description: Minimum number of idle child server processes
Syntax: MinSpareServers number
Default: MinSpareServers 5
Context: server config
Status: MPM
Module: prefork

The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer than MinSpareServers idle, then the parent process creates new children at a maximum rate of 1 per second.

Tuning of this parameter should only be necessary on very busy sites. Setting this parameter to a large number is almost always a bad idea.

See also



]]>
【{】apache2.0 prefork和worker模块性能调优http://m.shnenglu.com/qywyh/articles/60668.html?/dc:creator>?/author>Tue, 02 Sep 2008 03:10:00 GMThttp://m.shnenglu.com/qywyh/articles/60668.htmlhttp://m.shnenglu.com/qywyh/comments/60668.htmlhttp://m.shnenglu.com/qywyh/articles/60668.html#Feedback0http://m.shnenglu.com/qywyh/comments/commentRss/60668.htmlhttp://m.shnenglu.com/qywyh/services/trackbacks/60668.html[
IT技?/strong>]apache2.0 prefork和worker模块性能调优
Tags: mpm apache

  Apache 2.0在性能上的改善最吸引人。在支持POSIXU程的Unixpȝ上,Apache可以通过不同的MPMq行在一U多q程与多U程相؜合的模式下,增强部分配置的可扩充性能。相比于Apache 1.3Q?.0版本做了大量的优化来提升处理能力和可伸羃性,q且大多数改q在默认状态下卛_生效。但是在~译和运行时刻,2.0也有许多可以显著提高性能的选择。本文不惛_q那些以功能换取速度的指令,如HostnameLookups{,而只是说明在2.0中媄响性能的最核心Ҏ:MPMQMulti -Processing ModulesQ多道处理模块)的基本工作原理和配置指o?

  毫不夸张地说QMPM的引入是Apache 2.0最重要的变化。大家知道,Apache是基于模块化的设计,而Apache 2.0更扩展了模块化设计到Web服务器的最基本功能。服务器装蝲了一U多道处理模块,负责l定本机|络端口、接受请求,q调度子q程来处理请求。扩展模块化设计有两个重要好处:

  ?Apache可以更简z、有效地支持多种操作pȝQ?

  ?服务器可以按站点的特D需要进行自定制?

  在用LQMPM看v来和其它Apache模块非常cM。主要区别是在Q意时d能有一UMPM被装载到服务器中?

  指定MPM的方?

  下面以Red Hat Linux 9为^収ͼ说明在Apache 2.0中如何指定MPM (Apache采用2.0.45)。先解压~源代码包httpd-2.0.45.tar.gzQ生成httpd-2.0.45目录QApache 1.3源代码包的命名规则是apache_1.3.NN.tar.gzQ?.0版则是httpd-2.0.NN.tar.gzQ其中NN是次版本P?

  q入httpd-2.0.45目录Q运行以下代码:

$ ./configure --help|grep mpm

 

  昄如下Q?

--with-mpm=MPM
Choose the process model for Apache to use.
MPM={beos|worker|prefork|mpmt_os2| perchild|leader|threadpool}

 

  上述操作用来选择要用的q程模型Q即哪种MPM模块。Beos、mpmt_os2分别是BeOS和OS/2上缺省的MPMQ?perchild主要设计目的是以不同的用户和l的w䆾来运行不同的子进E。这在运行多个需要CGI的虚拟主机时特别有用Q会?.3版中的SuExec 机制做得更好。leader和threadpool都是Zworker的变体,q处于实验性阶D,某些情况下ƈ不会按照预期设想的那样工作,所?Apache官方也ƈ不推荐用。因此,我们主要阐述prefork和workerq两U和性能关系最大的产品UMPM ( 有关其它的MPM详细说明Q请参见Apache官方文档Q?a >http://httpd.apache.org/docs-2.0/mod/)?

  prefork的工作原理及配置

  如果不用“--with-mpm”昑ּ指定某种MPMQprefork是Unixq_上缺省的MPM。它所采用的预z子进E方式也?Apache 1.3中采用的模式。prefork本nq没有用到U程Q?.0版用它是ؓ了与1.3版保持兼Ҏ;另一斚wQprefork用单独的子进E来处理不同的请求,q程之间是彼此独立的Q这也其成为最E_的MPM之一?

  若用preforkQ在make~译和make install安装后,使用“httpd -l”来确定当前用的MPMQ应该会看到prefork.cQ如果看到worker.c说明使用的是worker MPMQ依此类推)。再查看~省生成的httpd.conf配置文gQ里面包含如下配|段Q?

<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

 

  prefork的工作原理是Q控制进E在最初徏?#8220;StartServers”个子q程后,Z满MinSpareServers讄的需要创Z个进E,{待一U钟Ql创Z个,再等待一U钟Ql创建四?#8230;…如此按指数增加创徏的进E数Q最多达到每U?2个,直到满 MinSpareServers讄的gؓ止。这是预派生(preforkQ的由来。这U模式可以不必在h到来时再产生新的q程Q从而减了pȝ开销以增加性能?

  MaxSpareServers讄了最大的I闲q程敎ͼ如果I闲q程数大于这个|Apache会自动kill掉一些多余进E。这个g要设得过大,但如果设的值比MinSpareServers,Apache会自动把其调整ؓMinSpareServers+1。如果站点负载较大,可考虑同时加大MinSpareServers和MaxSpareServers?

  MaxRequestsPerChild讄的是每个子进E可处理的请求数。每个子q程在处理了“MaxRequestsPerChild” 个请求后自动销毁?意味着无限Q即子进E永不销毁。虽然缺省设?可以使每个子q程处理更多的请求,但如果设成非零g有两炚w要的好处Q?

  ?可防止意外的内存泄漏Q?

  ?在服务器负蝲下降的时侯会自动减少子进E数?

  因此Q可Ҏ服务器的负蝲来调整这个倹{笔者认?0000左右比较合适?

  MaxClients是这些指令中最为重要的一个,讑֮的是Apache可以同时处理的请求,是对Apache性能影响最大的参数。其~省?150是远q不够的Q如果请求L已达到这个|可通过ps -ef|grep http|wc -l来确认)Q那么后面的hp排队Q直到某个已处理h完毕。这是pȝ资源q剩下很多而HTTP讉K却很慢的主要原因。系l管理员可以Ҏg配置和负载情冉|动态调整这个倹{虽然理Zq个D大,可以处理的请求就多Q但Apache默认的限制不能大?56。如果把q个D为大?56Q那?Apache无法v动。事实上Q?56对于负蝲E重的站点也是不够的。在Apache 1.3中,q是个硬限制。如果要加大q个|必须?#8220;configure”前手工修改的源代码树下的src/include/httpd.h中查?256Q就会发?#8220;#define HARD_SERVER_LIMIT 256”q行。把256改ؓ要增大的|?000Q,然后重新~译Apache卛_。在Apache 2.0中新加入了ServerLimit指oQ得无重~译Apache可以加大MaxClients。下面是W者的prefork配置D:

<IfModule prefork.c>
StartServers 10
MinSpareServers 10
MaxSpareServers 15
ServerLimit 2000
MaxClients 1000
MaxRequestsPerChild 10000
</IfModule>

 

  上述配置中,ServerLimit的最大值是20000Q对于大多数站点已经_。如果一定要再加大这个数|对位于源代码树下server/mpm/prefork/prefork.c中以下两行做相应修改卛_Q?

#define DEFAULT_SERVER_LIMIT 256
#define MAX_SERVER_LIMIT 20000

 

  worker的工作原理及配置

  相对于preforkQworker?.0 版中全新的支持多U程和多q程混合模型的MPM。由于用线E来处理Q所以可以处理相Ҏv量的hQ而系l资源的开销要小于基于进E的服务器。但是, worker也用了多进E,每个q程又生成多个线E,以获得基于进E服务器的稳定性。这UMPM的工作方式将是Apache 2.0的发展趋ѝ?

  在configure -with-mpm=worker后,q行make~译、make install安装。在~省生成的httpd.conf中有以下配置D:

<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

 

  worker的工作原理是Q由L制进E生?#8220;StartServers”个子q程Q每个子q程中包含固定的ThreadsPerChild U程敎ͼ各个U程独立地处理请求。同PZ不在h到来时再生成U程QMinSpareThreads和MaxSpareThreads讄了最和最多的I闲U程敎ͼ而MaxClients讄了所有子q程中的U程L。如果现有子q程中的U程L不能满负蝲Q控制进E将z新的子进E?

  MinSpareThreads和MaxSpareThreads的最大缺省值分别是75?50。这两个参数对Apache的性能影响q不大,可以按照实际情况相应调节?

  ThreadsPerChild是worker MPM中与性能相关最密切的指令。ThreadsPerChild的最大缺省值是64Q如果负载较大,64也是不够的。这时要昑ּ使用 ThreadLimit指oQ它的最大缺省值是20000。上qC个g于源码树server/mpm/worker/worker.c中的以下两行Q?

#define DEFAULT_THREAD_LIMIT 64
#define MAX_THREAD_LIMIT 20000

 

  q两行对应着ThreadsPerChild和ThreadLimit的限制数。最好在configure之前把64Ҏ所希望的倹{注意,不要把这两个D得太高,过pȝ的处理能力,从而因Apache不v动ɾpȝ很不E_?

  Worker模式下所能同时处理的hL是由子进EL乘以ThreadsPerChild值决定的Q应该大于等于MaxClients。如果负载很大,现有的子q程C能满xQ控制进E会z新的子进E。默认最大的子进EL?6Q加大时也需要显式声明ServerLimitQ最大值是20000Q。这两个g于源码树server/mpm/worker/worker.c中的以下两行Q?

#define DEFAULT_SERVER_LIMIT 16
#define MAX_SERVER_LIMIT 20000

 

  需要注意的是,如果昑ּ声明了ServerLimitQ那么它乘以ThreadsPerChild的值必d于等于MaxClientsQ而且MaxClients必须是ThreadsPerChild的整数倍,否则Apache会自动调节C个相应|可能是个非期望|。下面是W者的 worker配置D:

<IfModule worker.c>
StartServers 3
MaxClients 2000
ServerLimit 25
MinSpareThreads 50
MaxSpareThreads 200
ThreadLimit 200
ThreadsPerChild 100
MaxRequestsPerChild 0
</IfModule>

 

  通过上面的叙qͼ可以了解到Apache 2.0中prefork和workerq两个重要MPM的工作原理,q可Ҏ实际情况来配|Apache相关的核心参敎ͼ以获得最大的性能和稳定性?



?/a> 2008-09-02 11:10 发表评论
]]>
޾ƷŮþ777777| һƷ˾þ| þþþþŮ| ŷ˾þô߽ۺ| ޾ƷþþþĻ69| 91Ʒ91þþþþ| þþþþ޾Ʒ| Ʒ99þþþþ鶹| 99þۺϺݺۺϾþ| þþƷ޾Ʒŷ| ޾ƷþþþþҲ| 99鶹þþùƷ| ѾƷþþþþĻ| þۺۺϾþۺ| ƷþþþþþþþĻ| 99þþƷѿһ| 91þþƷ91ɫҲ| ھƷþþþӰԺ˾| þ99Ʒ鶹| պAVþһ | þþƷվ| AvƷþ| 99þóĻ| þѿaëƬ| ݺۺϾþۺ88| 뾫ƷþѼ| Ѿþˬˬav| 99þˬ޾ƷŮ| 99ŷþþþƷѿ| ˳ŷþ| ٸƷþ| þó18վ| ˾þþþƷ| 2020þþƷ| þݺҹҹ2O2O| 99Ʒ99þþþþ97 | Ʒþ| ŷ˾þƬ| 97þۺϾƷþþۺ| þþþþþAv| ھƷþþþav|