Linux下Apache配置worker和prefork样例

Ø Apache采用worker方式的配置样例

(1)、安装不再赘述,添加:--with-mpm=worker

(2)、httpd.conf配置段样例:

Listen 80

<VirtualHost *:80>

#SetEnv force-proxy-request-1.0 1

#SetEnv proxy-nokeepalive 1

#SetEnv proxy-initial-not-pooled 1

#Timeout 300

ProxyRequests Off

ProxyPass /saas balancer://yourproxy/ stickysession=JSESSIONID lbmethod=bytraffic nofailover=Off

ProxyPassReverse /saas balancer://yourproxy/

#ProxyTimeout 300

<Proxy balancer://yourproxy>

#ProxySet timeout=300

BalancerMember http://10.72.0.196:7888/saas loadfactor=1 route=cluster1 retry=1 max=25 timeout=300 Keepalive=On

BalancerMember http://10.72.0.198:7888/saas loadfactor=1 route=cluster2 retry=1 max=25 timeout=300 Keepalive=On

</Proxy>

</VirtualHost>

………………………………

# Server-pool management (MPM specific)

Include conf/extra/httpd-mpm.conf

# Various default settings

Include conf/extra/httpd-default.conf

(3)、httpd-default.conf配置段样例:

#

# Timeout: The number of seconds before receives and sends time out.

#

Timeout 300

#

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

#

KeepAlive On

#

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you leave this number high, for maximum performance.

#

MaxKeepAliveRequests 100

#

# KeepAliveTimeout: Number of seconds to wait for the next request from the

# same client on the same connection.

#

KeepAliveTimeout 5

(4)、httpd-mpm.conf配置段样例:

# 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 3

MaxClients 1984

ServerLimit 31

MinSpareThreads 50

MaxSpareThreads 200

ThreadLimit 200

ThreadsPerChild 64

MaxRequestsPerChild 0

</IfModule>

注意:以下限制:

MaxClients=n*ThreadsPerChild

ServerLimit*ThreadsPerChild>=MaxClients

Ø Apache采用prefork方式的配置样例

(1)、安装不再赘述,

(2)、httpd.conf配置段样例:

Listen 80

<VirtualHost *:80>

#SetEnv force-proxy-request-1.0 1

#SetEnv proxy-nokeepalive 1

Timeout 300

ProxyRequests Off

ProxyPass /saas balancer://yourproxy/ stickysession=JSESSIONID nofailover=Off

#ProxyPassReverse /saas balancer://yourproxy/

ProxyTimeout 300

#SetEnv proxy-initial-not-pooled 1

<Proxy balancer://yourproxy>

ProxySet timeout=300

BalancerMember http://10.72.0.196:7888/saas loadfactor=1 route=cluster1 retry=0 timeout=300 Keepalive=On

BalancerMember http://10.72.0.198:7888/saas loadfactor=1 route=cluster2 retry=0 timeout=300 Keepalive=On

</Proxy>

</VirtualHost>

……………………

# Server-pool management (MPM specific)

Include conf/extra/httpd-mpm.conf

# Various default settings

Include conf/extra/httpd-default.conf

(3)、httpd-default.conf配置段样例:

#

# Timeout: The number of seconds before receives and sends time out.

#

Timeout 300

#

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

#

KeepAlive On

#

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you leave this number high, for maximum performance.

#

MaxKeepAliveRequests 0

#

# KeepAliveTimeout: Number of seconds to wait for the next request from the

# same client on the same connection.

#

KeepAliveTimeout 60

(4)、httpd-mpm.conf配置段样例:

# 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>

ServerLimit 5000

StartServers 3000

MinSpareServers 50

MaxSpareServers 3000

MaxClients 5000

MaxRequestsPerChild 50000

</IfModule>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值