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>

猜你喜欢

转载自can-do.iteye.com/blog/2250711
今日推荐