叉叉助手 微信好友清理助手哪个好

使用resource_limit及profile限制用户连接
使用resource_limit及profile限制用户连接
& 数据库性能是一个永恒的话题,那就是如何使用更少的资源以达到更高效的性能。Oracle系统参数RESOURCE_LIMIT是一个用于控制用户对于数据库资源使用的参数,当值为true的时候即为启用,否则禁用。该参数结合profile来可以控制多种资源的使用,如CPU_PER_SESSION, CONNECT_TIME,LOGICAL_READS_PER_SESSION,
PRIVATE_SGA等等从而达到到节省资源来实现高效性能。本文描述了数据资源限制并演示了IDLE_TIME及SESSIONS_PER_USER的用法。
1、数据库资源限制的主要步骤
Implemented by&
& & &* Setting RESOURCE_LIMIT = TRUE in the database startup parameter file (spfile or pfile)&
& & &* Creating or modifying existing user profiles (DBA_PROFILES) to have one or more resource limit
& & &* Assigning a profile to a user whose resources are wished to be limited
It could happen that if the idle_time has been set on the DEFAULT profile, this can lead to an MTS dispatchers being set to 'sniped' and then getting 'cleaned up' via the shell script.
The removal of the dispatcher will result in other sessions 'dying' .In that case, If you are to implement resource limits, may be advisable to create new profiles that be assigned to users and not to change the characteristics of DEFAULT.
Alternatively, if you do change DEFAULT, ensure that all the properties that you have affected have been fully tested in a development environment.
用户超出限制后的完成的动作
When a resource limit is exceeded (for example IDLE_TIME) ... PMON does the following&
& & &* Mark the V$SESSION as SNIPED&
& & &* Clean up the database resources for the session
& & &* Remove the V$SESSION entry
2、资源限制的配置
--演示环境 &
SQL& select * from v$version where rownum&2; &
-------------------------------------------------------------------------------- &
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production &
--查看参数resource_limit &
SQL& show parameter resource_limit &
NAME & & & & & & & & & & & & & & & & TYPE & & & &VALUE &
------------------------------------ ----------- ------------------------------ &
resource_limit & & & & & & & & & & & boolean & & FALSE &
--修改参数resource_limit为true &
SQL& alter system set resource_limit= &
System altered. &
SQL& show parameter resource_limit &
NAME & & & & & & & & & & & & & & & & TYPE & & & &VALUE &
------------------------------------ ----------- ------------------------------ &
resource_limit & & & & & & & & & & & boolean & & TRUE &
--创建profile,其idle_time为3分钟 &
SQL& create profile app_user limit idle_time 3; &&
Profile created. &
--修改profile,限制每个用户只能开一个session &
SQL& alter profile app_user limit sessions_per_user 1; &
Profile altered. &
--将用户指派给特定的profile &
SQL& alter user scott profile app_ &
User altered. &
--查看刚刚创建的profile,查询结果中的RESOURCE_NAME都可以作相应的设置或修改 &
SQL& select * from dba_profiles where profile='APP_USER'; &
PROFILE & & & & & & & & & & & &RESOURCE_NAME & & & & & & & & & &RESOURCE LIMIT &
------------------------------ -------------------------------- -------- ---------------------------------------- &
APP_USER & & & & & & & & & & & COMPOSITE_LIMIT & & & & & & & & &KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & SESSIONS_PER_USER & & & & & & & &KERNEL & 1 &
APP_USER & & & & & & & & & & & CPU_PER_SESSION & & & & & & & & &KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & CPU_PER_CALL & & & & & & & & & & KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & LOGICAL_READS_PER_SESSION & & & &KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & LOGICAL_READS_PER_CALL & & & & & KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & IDLE_TIME & & & & & & & & & & & &KERNEL & 3 &
APP_USER & & & & & & & & & & & CONNECT_TIME & & & & & & & & & & KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & PRIVATE_SGA & & & & & & & & & & &KERNEL & DEFAULT &
APP_USER & & & & & & & & & & & FAILED_LOGIN_ATTEMPTS & & & & & &PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_LIFE_TIME & & & & & & & PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_REUSE_TIME & & & & & & &PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_REUSE_MAX & & & & & & & PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_VERIFY_FUNCTION & & & & PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_LOCK_TIME & & & & & & & PASSWORD DEFAULT &
APP_USER & & & & & & & & & & & PASSWORD_GRACE_TIME & & & & & & &PASSWORD DEFAULT &
16 rows selected. &
3、演示资源被限制的情形
C:\Users\robinson.cheng&sqlplus scott/tiger@oradb1 &
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 26 18:12:10 2013 &
Copyright (c) , Oracle. &All rights reserved. &
SQL& host & & & & & & -----&开启一个session &
Microsoft Windows [Version 6.1.7600] &
Copyright (c) 2009 Microsoft Corporation. &All rights reserved. &
C:\Users\robinson.cheng&sqlplus scott/tiger@oradb1 & ---&尝试开启另一个sessioin &
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 26 18:12:21 2013 &
Copyright (c) , Oracle. &All rights reserved. &
ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit & ---&此时收到资源被限制的提示 &
Enter user-name: &
--在服务器端查看session的情形,3分钟后用户scott 的session的状态被置为SNIPED &
SQL& @comm_sess_ &
+----------------------------------------------------+ &
| User Sessions (All) & & & & & & & & & & & & & & & &| &
+----------------------------------------------------+ &
Instance & & SID Serial ID & &Status Oracle User & & O/S User &O/S PID Session Program & & & & Terminal & & & & & & Machine &
--------- ------ --------- --------- ----------- ------------ -------- --------------------- ---------- ------------------- &
oradb & & & & &1 & & & & 5 &INACTIVE & & & & SYS & & & oracle 10090 & &sqlplus@node1.szdb.co & & &pts/1 & & & &
& & & & & & & 35 & & & & 7 & &ACTIVE & & & & &HR & & & &robin 10171 & &sqlplus@SZDB (TNS V1- & & &pts/2 & & & & & & & &SZDB &
& & & & & & & 40 & & & 237 & &SNIPED & & & SCOTT Robinson.Che 13282 & &sqlplus.exe & & & & & & & & PC39 & & 2GOTRADESZ\PC39 &
--获得session的spid &
SQL& @my_spid_from_sid &
Enter value for input_sid: 40 &
& &SID & &SERIAL# SPID &
------ ---------- ------------------------------------- &
& & 40 & & & &237 13282 &
--此时的时间为20:17:54 &
SQL& ho date &
Wed Jun 26 20:17:54 CST 2013 &
--查看scott对应的server process,其进程的启动时间为18:12,过了1个多小时,进程依旧没有被释放 & & &
SQL& ho ps -ef | grep 13282 | grep -v grep &
oracle & 13282 & & 1 &0 18:12 ? & & & &00:00:00 oracleoradb (LOCAL=NO) &
--下面调用shell脚本来杀掉对应的进程 &
SQL& host &
[oracle@node1 ~]$ ./kill_sniped.sh oradb &
[oracle@node1 ~]$ ps -ef | grep 13282 | grep -v grep &
--清除服务器进程的shell脚本 &
[oracle@node1 ~]$ more kill_sniped.sh &&
#!/bin/sh &
export ORACLE_SID=$1 &
tmpfile=/tmp/tmp.$$ &
sqlplus -S /nolog &&EOF &
connect / as sysdba &
set head off feedback off &
spool $tmpfile &
select p.spid from v\$process p,v\$session s &
where s.paddr=p.addr &
and s.status='SNIPED'; &
spool off &
for x in `cat $tmpfile | grep &^[]&` &
& & & & & & & & do &
& & & & & & & & kill -9 $x &
rm $tmpfile &
4、注意事项
& & & If you are running in a shared server environment, you need to be careful not to accidentally kill your dispatchers and/or shared servers. In Oracle 10.2 (or higher) a dedicated connections V$SESSION + V$PROCESS + OS Process can be cleaned up with&
& & & ALTER SYSTEM DISCONNECT SESSION '&SID&,&SERIAL&' IMMEDIATE
At this point in versions prior to 10.2 and for shared server connections the only solution is to kill the session at the OS level (see Kill and ORAKILL above)&
& & &* Windows : use the orakill command .... orakill &ORACLE SID& &Thread ID& (see Note 69882.1 for details)
On occasions we see conditions where a database session has a V$SESSION.STATUS = SNIPED ... and the entry never goes away . This condition can be achieved by implementing Database Resource Limits + Profiles without DCD and allow the database session to exceed the limit in the profile
a、参数RESOURCE_LIMIT = TRUE用于启用数据库资源配置限制
b、profile用于实现资源配置,创建profile或修改已存在的profile来调整各个具体资源配置
c、将profile指派给那些需要限制的用户
d、一旦被限制的用户超出所设定的阀值将收到资源配置相关的错误提示
e、被限制资源的session状态变成sniped
f、被限制资源的session对应的server process并没有被释放,需要手动释放或结合sqlnet.expire_date来进行释放
顶一下(0) 踩一下(0)
热门标签:本文讲的是Apache中配置最大并发用户数 tcp连接设置方法,
Apache在配置编译时可以自主的选择想要使用的MPM模块,使用./configure --with-mpm=MPM命令。我们主要了解prefork和worker这两种MPM模块。
如果不用“--with-mpm”
Apache在配置编译时可以自主的选择想要使用的MPM模块,使用./configure --with-mpm=MPM命令。我们主要了解prefork和worker这两种MPM模块。
如果不用“--with-mpm”显式指定某种MPM,prefork就是Unix平台上缺省的MPM。它所采用的预派生子进程方式,用单独的子进程来处理不同的请求,进程之间彼此独立。在make编译和make install安装后,使用httpd -l来确定当前使用的
MPM是prefork.c。查看httpd-mpm.conf配置文件,里面包含如下默认的配置段:
&IfModule prefork.c&
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
&/IfModule&
prefork控制进程在最初建立“StartServers”个子进程后,为了满足MinSpareServers设置的需要创建一个进程,等待一秒钟,继续创建两个,再等待一秒钟,继续创建四个……如此按指数级增加创建的进程数,最多达到每秒32个,直到满足MinSpareServers设置的值为止。这种模式可以不必在请求到来时再产生新的进程,从而减小了系统开销以增加性能。MaxSpareServers设置了最大的空闲进程数,如果空闲进程数大于这个值,Apache会自动kill掉一些多余进程。这个值不要设得过大,但如果设的值比MinSpareServers小,Apache会自动把其调整为MinSpareServers+1。如果站点负载较大,可考虑同时加大MinSpareServers和MaxSpareServers。MaxRequestsPerChild设置的是每个子进程可处理的请求数。每个子进程在处理了“MaxRequestsPerChild”个请求后将自动销毁。0意味着无限,即子进程永不销毁。虽然缺省设为0可以使每个子进程处理更多的请求,但如果设成非零值也有两点重要的好处:1、可防止意外的内存泄漏。2、在服务器负载下降的时侯会自动减少子进程数。因此,可根据服务器的负载来调整这个值。MaxClients是这些指令中最为重要的一个,设定的是Apache可以同时处理的请求,是对Apache性能影响最大的参数。其缺省值150是远远不够的,如果请求总数已达到这个值(可通过ps -ef|grep http|wc -l来确认),那么后面的请求就要排队,直到某个已处理请求完毕。这就是系统资源还剩下很多而HTTP访问却很慢的主要原因。虽然理论上这个值越大,可以处理的请求就越多,但Apache默认的限制不能大于256。ServerLimit指令无须重编译Apache就可以加大MaxClients。ServerLimt应该放在第一个位置,放在其他指令之间不起作用(不明白原因)。
&IfModule prefork.c&
ServerLimit
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 10000
MaxRequestsPerChild 0
&/IfModule&
相对于prefork,worker全新的支持多线程和多进程混合模型的MPM。由于使用线程来处理,所以可以处理相对海量的请求,而系统资源的开销要小于基于进程的服务器。但是,worker也使用了多进程,每个进程又生成多个线程,以获得基于进程服务器的稳定性。在configure --with-mpm=worker后,进行make编译、make install安装。在缺省生成的httpd-mpm.conf中有以下默认配置段:
&IfModule worker.c&
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
&/IfModule&
Worker由主控制进程生成“StartServers”个子进程,每个子进程中包含固定的ThreadsPerChild线程数,各个线程独立地处理请求。同样,为了不在请求到来时再生成线程,MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数;而MaxClients设置了同时连入的clients最大总数。如果现有子进程中的线程总数不能满足负载,控制进程将派生新的子进程。MinSpareThreads和MaxSpareThreads的最大缺省值分别是75和250。这两个参数对Apache的性能影响并不大,可以按照实际情况相应调节。ThreadsPerChild是worker MPM中与性能相关最密切的指令。ThreadsPerChild的最大缺省值是64,如果负载较大,64也是不够的。这时要显式使用ThreadLimit指令,它的最大缺省值是20000。Worker模式下所能同时处理的请求总数是由子进程总数乘以ThreadsPerChild值决定的,应该大于等于MaxClients。如果负载很大,现有的子进程数不能满足时,控制进程会派生新的子进程。默认最大的子进程总数是16,加大时也需要显式声明ServerLimit(最大值是20000)。需要注意的是,如果显式声明了ServerLimit,那么它乘以ThreadsPerChild的值必须大于等于MaxClients,而且MaxClients必须是ThreadsPerChild的整数倍,否则Apache将会自动调节到一个相应值。
&IfModule worker.c&
ServerLimit 25
ThreadLimit 200
StartServers 3
MaxClients 2000
MinSpareThreads 50
MaxSpareThreads 200
ThreadsPerChild 100
MaxRequestsPerChild 0
&/IfModule&
下面是利用Apache自带的测试工具ab对Server进行测试的情况(设定请求的index页面为6bytes,Apache Server配置2cpu 2G memory),cpu%为cpu占用率,mem为内存使用量(M为单位),RequestsPerSecond为每秒处理的请求数。
1、Prefor方式
(ServerLimit,StartServer,MinSpareServers,MaxSpareServers,MaxClients,MaxRequestPerChild)
-n/-c(ab参数) Cpu% Mem Requestspersecond
(-,5,5,10,150,0)
28.8 285 8434
29.2 304 8032
25.3 323 7348
0 24.4 330 5886
(,10,500,0)
28.7 371 8345
27.4 389 7929
24.9 417 7229
0 23.4 437 6676
(,10,1000,0)
28.8 408 8517
27.0 422 8045
24.2 455 7236
0 22.5 470 6570
(,10,1500,0)
29.6 330 8407
28.1 349 8014
26.4 380 7290
0 24.0 400 6686
2、Worker方式
(ServerLimt,Threadlimt,Startservers,MaxClients,MinspareThread,MaxspareThread,ThreadperChild,MaxRequestPerChild)
-n/-c(ab参数) cpu% mem RequestsperSecond
(50,500,5,,200,0)
18.6 188 6020
20.1 195 5892
19.8 209 5708
0 22.2 218 6081
(100,500,5,,100,0)
24.5 240 6919
23.6 247 6798
24.6 254 6827
0 22.3 271 6114
(200,500,5,,50,0)
27.3 301 7781
27.4 307 7789
26.0 320 7141
0 21.8 344 6110
相对来说,prefork方式速度要稍高于worker,然而它需要的cpu和memory资源也稍多于woker。
下面贴出我的系统mpm文件
# Server-Pool Management (MPM specific)
# PidFile: The file in which the server should record its process
# identification number when it starts.
# Note that this is the default PidFile for most MPMs.
&IfModule !mpm_netware_module&
PidFile "logs/httpd.pid"
&/IfModule&
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
&IfModule !mpm_winnt_module&
&IfModule !mpm_netware_module&
LockFile "logs/accept.lock"
&/IfModule&
&/IfModule&
# Only one of the below sections will be relevant on your
# installed httpd.
Use "apachectl -l" to find out the
# active mpm.
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
&IfModule mpm_prefork_module&
StartServers
MinSpareServers
MaxSpareServers
MaxClients
MaxRequestsPerChild
&/IfModule&
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
&IfModule mpm_worker_module&
StartServers
MaxClients
MinSpareThreads
MaxSpareThreads
ThreadsPerChild
MaxRequestsPerChild
&/IfModule&
# BeOS MPM
# StartThreads: how many threads do we initially spawn?
# MaxClients:
max number of threads we can have (1 thread == 1 client)
# MaxRequestsPerThread: maximum number of requests each thread will process
&IfModule mpm_beos_module&
StartThreads
MaxClients
MaxRequestsPerThread 10000
&/IfModule&
# NetWare MPM
# ThreadStackSize: Stack size allocated for each worker thread
# StartThreads: Number of worker threads launched at server startup
# MinSpareThreads: Minimum number of idle threads, to handle request spikes
# MaxSpareThreads: Maximum number of idle threads
# MaxThreads: Maximum number of worker threads alive at the same time
# MaxRequestsPerChild: Maximum
number of requests a thread serves. It is
recommended that the default value of 0 be set for this
directive on NetWare.
This will allow the thread to
continue to service requests indefinitely.
&IfModule mpm_netware_module&
ThreadStackSize
StartThreads
MinSpareThreads
MaxSpareThreads
MaxThreads
MaxRequestsPerChild
MaxMemFree
&/IfModule&
# OS/2 MPM
# StartServers: Number of server processes to maintain
# MinSpareThreads: Minimum number of idle threads per process,
to handle request spikes
# MaxSpareThreads: Maximum number of idle threads per process
# MaxRequestsPerChild: Maximum number of connections per server process
&IfModule mpm_mpmt_os2_module&
StartServers
MinSpareThreads
MaxSpareThreads
MaxRequestsPerChild
&/IfModule&
# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum
number of requests a server process serves
&IfModule mpm_winnt_module&
ThreadsPerChild
MaxRequestsPerChild
&/IfModule&
以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索线程
最大并发用户数、最大在线并发用户数、lr 最大并发用户数、apache最大并发数、apache支持最大并发数,以便于您获取更多的相关知识。
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效率,降低 IT 成本...
RDS是一种稳定可靠、可弹性伸缩的在线数据库服务。支持MySQL、SQL Server、PostgreSQL、高...
云栖社区()为您免费提供相关信息,包括
的信息,还有最大并发用户数、最大在线并发用户数、lr 最大并发用户数、apache最大并发数、apache支持最大并发数等
,所有相关内容均不代表云栖社区的意见!Apache中配置最大并发用户数 tcp连接设置-Windows-ab蓝学网
Apache中配置最大并发用户数 tcp连接设置
简介:服务器|这是关于在Apache中配置最大并发用户数tcp连接设置,对学习这方面知识有朋友会有一定的帮助httpd_mpm.conf文件在你apache安装上当的\\conf\\extra中,还在就是在要apa...
这是关于在Apache中配置最大并发用户数 tcp连接设置,对学习这方面知识有朋友会有一定的帮助
httpd_mpm.conf文件在你apache安装上当的\\conf\\extra中,还在就是在要apache httpd.conf中把#Include conf/extra/httpd-mpm.conf前面的#号去了哦。
Apache在配置编译时可以自主的选择想要使用的MPM模块,使用./configure --with-mpm=MPM命令。我们主要了解prefork和worker这两种MPM模块。
Prefork 如果不用“--with-mpm”显式指定某种MPM,prefork就是Unix平台上缺省的MPM。它所采用的预派生子进程方式,用单独的子进程来处 理不同的请求,进程之间彼此独立。在make编译和make install安装后,使用httpd -l来确定当前使用的 MPM是prefork.c。查看httpd-mpm.conf配置文件,里面包含如下默认的配置段:
&IfModule prefork.c& StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 &/IfModule&
prefork控制进程在最初建立“StartServers”个子进程后,为了满足MinSpareServers设置的需要创建一个进程,等待 一秒钟,继续创建两个,再等待一秒钟,继续创建四个……如此按指数级增加创建的进程数,最多达到每秒32个,直到满足MinSpareServers设置 的值为止。这种模式可以不必在请求到来时再产生新的进程,从而减小了系统开销以增加性能。MaxSpareServers设置了最大的空闲进程数,如果空 闲进程数大于这个值,Apache会自动kill掉一些多余进程。这个值不要设得过大,但如果设的值比MinSpareServers小,Apache会 自动把其调整为MinSpareServers+1。如果站点负载较大,可考虑同时加大MinSpareServers和 MaxSpareServers。MaxRequestsPerChild设置的是每个子进程可处理的请求数。每个子进程在处理了 “MaxRequestsPerChild”个请求后将自动销毁。0意味着无限,即子进程永不销毁。虽然缺省设为0可以使每个子进程处理更多的请求,但如 果设成非零值也有两点重要的好处:1、可防止意外的内存泄漏。2、在服务器负载下降的时侯会自动减少子进程数。因此,可根据服务器的负载来调整这个值。 MaxClients是这些指令中最为重要的一个,设定的是Apache可以同时处理的请求,是对Apache性能影响最大的参数。其缺省值150是远远 不够的,如果请求总数已达到这个值(可通过ps -ef|grep http|wc -l来确认),那么后面的请求就要排队,直到某个已处理请求完毕。这就是系统资源还剩下很多而HTTP访问却很慢的主要原因。虽然理论上这个值越大,可以 处理的请求就越多,但Apache默认的限制不能大于256。ServerLimit指令无须重编译Apache就可以加大MaxClients。 ServerLimt应该放在第一个位置,放在其他指令之间不起作用(不明白原因)。
&IfModule prefork.c& ServerLimit& 10000 StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 10000 MaxRequestsPerChild 0 &/IfModule&
Worker 相对于prefork,worker全新的支持多线程和多进程混合模型的MPM。由于使用线程来处理,所以可以处理相对海量的请求,而系统资源的开销要小 于基于进程的服务器。但是,worker也使用了多进程,每个进程又生成多个线程,以获得基于进程服务器的稳定性。在configure --with-mpm=worker后,进行make编译、make install安装。在缺省生成的httpd-mpm.conf中有以下默认配置段:
&IfModule worker.c& StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 &/IfModule&
Worker由主控制进程生成“StartServers”个子进程,每个子进程中包含固定的ThreadsPerChild线程数,各个线程独立 地处理请求。同样,为了不在请求到来时再生成线程,MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数;而 MaxClients设置了同时连入的clients最大总数。如果现有子进程中的线程总数不能满足负载,控制进程将派生新的子进程。 MinSpareThreads和MaxSpareThreads的最大缺省值分别是75和250。这两个参数对Apache的性能影响并不大,可以按照 实际情况相应调节。ThreadsPerChild是worker MPM中与性能相关最密切的指令。ThreadsPerChild的最大缺省值是64,如果负载较大,64也是不够的。这时要显式使用 ThreadLimit指令,它的最大缺省值是20000。Worker模式下所能同时处理的请求总数是由子进程总数乘以ThreadsPerChild 值决定的,应该大于等于MaxClients。如果负载很大,现有的子进程数不能满足时,控制进程会派生新的子进程。默认最大的子进程总数是16,加大时 也需要显式声明ServerLimit(最大值是20000)。需要注意的是,如果显式声明了ServerLimit,那么它乘以 ThreadsPerChild的值必须大于等于MaxClients,而且MaxClients必须是ThreadsPerChild的整数倍,否则 Apache将会自动调节到一个相应值。
&IfModule worker.c& ServerLimit 25 ThreadLimit 200 StartServers 3 MaxClients 2000 MinSpareThreads 50 MaxSpareThreads 200 ThreadsPerChild 100 MaxRequestsPerChild 0 &/IfModule&
下面是利用Apache自带的测试工具ab对Server进行测试的情况(设定请求的index页面为6bytes,Apache Server配置2cpu 2G memory),cpu%为cpu占用率,mem为内存使用量(M为单位),RequestsPerSecond为每秒处理的请求数。 1、Prefor方式 & (ServerLimit,StartServer,MinSpareServers,MaxSpareServers,MaxClients,MaxRequestPerChild)&&&&&&&&&&&
-n/-c(ab参数) Cpu% Mem Requestspersecond
(-,5,5,10,150,0)
28.8 285 8434
29.2 304 8032
25.3 323 7348
0 24.4 330 5886
(,10,500,0)
28.7 371 8345
27.4 389 7929
24.9 417 7229
0 23.4 437 6676
(,10,1000,0)
28.8 408 8517
27.0 422 8045
24.2 455 7236
0 22.5 470 6570
(,10,1500,0)
29.6 330 8407
28.1 349 8014
26.4 380 7290
0 24.0 400 6686
2、Worker方式 (ServerLimt,Threadlimt,Startservers,MaxClients,MinspareThread,MaxspareThread,ThreadperChild,MaxRequestPerChild) &&&&&&&&&&&&&&&&&&
-n/-c(ab参数) cpu% mem RequestsperSecond
(50,500,5,,200,0)
& 18.6 188 6020
20.1 195 5892
19.8 209 5708
0 22.2 218 6081
(100,500,5,,100,0)
& 24.5 240 6919
23.6 247 6798
24.6 254 6827
0 22.3 271 6114
(200,500,5,,50,0)
& 27.3 301 7781
27.4 307 7789
26.0 320 7141
0 21.8 344 6110
相对来说,prefork方式速度要稍高于worker,然而它需要的cpu和memory资源也稍多于woker。
下面贴出我的系统mpm文件
# # Server-Pool Management (MPM specific) # # # PidFile: The file in which the server should record its process # identification number when it starts. # # Note that this is the default PidFile for most MPMs. # &IfModule !mpm_netware_module& &&& PidFile &logs/httpd.pid& &/IfModule& # # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. # &IfModule !mpm_winnt_module& &IfModule !mpm_netware_module& LockFile &logs/accept.lock& &/IfModule& &/IfModule& # # Only one of the below sections will be relevant on your # installed httpd.& Use &apachectl -l& to find out the # active mpm. # # prefork MPM # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare # MaxSpareServers: maximum number of server processes which are kept spare # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves &IfModule mpm_prefork_module& &&& StartServers&&&&&&&&& 5 &&& MinSpareServers&&&&&& 5 &&& MaxSpareServers&&&&& 10 &&& MaxClients&&&&&&&&& 150 &&& MaxRequestsPerChild&& 0 &/IfModule& # worker MPM # StartServers: initial number of server processes to start # MaxClients: maximum number of simultaneous client connections # MinSpareThreads: minimum number of worker threads which are kept spare # MaxSpareThreads: maximum number of worker threads which are kept spare # ThreadsPerChild: constant number of worker threads in each server process # MaxRequestsPerChild: maximum number of requests a server process serves &IfModule mpm_worker_module& &&& StartServers&&&&&&&&& 2 &&& MaxClients&&&&&&&&& 150 &&& MinSpareThreads&&&&& 25 &&& MaxSpareThreads&&&&& 75
&&& ThreadsPerChild&&&&& 25 &&& MaxRequestsPerChild&& 0 &/IfModule& # BeOS MPM # StartThreads: how many threads do we initially spawn? # MaxClients:&& max number of threads we can have (1 thread == 1 client) # MaxRequestsPerThread: maximum number of requests each thread will process &IfModule mpm_beos_module& &&& StartThreads&&&&&&&&&&& 10 &&& MaxClients&&&&&&&&&&&&& 50 &&& MaxRequestsPerThread 10000 &/IfModule& # NetWare MPM # ThreadStackSize: Stack size allocated for each worker thread # StartThreads: Number of worker threads launched at server startup # MinSpareThreads: Minimum number of idle threads, to handle request spikes # MaxSpareThreads: Maximum number of idle threads # MaxThreads: Maximum number of worker threads alive at the same time # MaxRequestsPerChild: Maximum& number of requests a thread serves. It is
#&&&&&&&&&&&&&&&&&&&&& recommended that the default value of 0 be set for this #&&&&&&&&&&&&&&&&&&&&& directive on NetWare.& This will allow the thread to
#&&&&&&&&&&&&&&&&&&&&& continue to service requests indefinitely.&&&&&&&&&&&&&&&&&&&&&&&&&
&IfModule mpm_netware_module& &&& ThreadStackSize&&&&& 65536 &&& StartThreads&&&&&&&&&& 250 &&& MinSpareThreads&&&&&&&& 25 &&& MaxSpareThreads&&&&&&& 250 &&& MaxThreads&&&&&&&&&&& 1000 &&& MaxRequestsPerChild&&&&& 0 &&& MaxMemFree&&&&&&&&&&&& 100 &/IfModule& # OS/2 MPM # StartServers: Number of server processes to maintain # MinSpareThreads: Minimum number of idle threads per process,
#&&&&&&&&&&&&&&&&& to handle request spikes # MaxSpareThreads: Maximum number of idle threads per process # MaxRequestsPerChild: Maximum number of connections per server process &IfModule mpm_mpmt_os2_module& &&& StartServers&&&&&&&&&& 2 &&& MinSpareThreads&&&&&&& 5 &&& MaxSpareThreads&&&&&& 10 &&& MaxRequestsPerChild&&& 0 &/IfModule& # WinNT MPM # ThreadsPerChild: constant number of worker threads in the server process # MaxRequestsPerChild: maximum& number of requests a server process serves &IfModule mpm_winnt_module& &&& ThreadsPerChild&&&&& 150 &&& MaxRequestsPerChild&&& 0 &/IfModule&
上一编:下一编:
喜欢猜你喜欢的内容
大家感兴趣的内容
1 2 3 4 5 6 7 8 9 10
最近更新的内容
1 2 3 4 5 6 7 8 9 10
本月热门的内容
1 2 3 4 5 6 7 8 9 10

我要回帖

更多关于 微信好友清理助手 的文章

 

随机推荐