[CentOS] clustering and load balancing Apache, using nginx

Sergej Kandyla sk.paix at gmail.com
Wed Feb 11 14:51:49 UTC 2009


Les Mikesell пишет:
> Sergej Kandyla wrote:
>   
>>    
>> No, nginx could serve any kind of content via ngx_http_proxy_module 
>> module http://wiki.codemongers.com/NginxHttpProxyModule
>> For example I'm using nginx as reverse proxy for tomcat 
>> servers\applications.
>>     
>
> Is there some advantage to this over apache with mod_jk?
>
>   
afaik mod_jk is only available for RHEL4\Centos4 i.e apache 2.0 (of 
course you could compile it manually for apache 2.2 coming with centos5)
So, recommended way for centos5 (apache 2.2) is using mod_proxy 
(mod_proxy_ajp)

nginx http_proxy module is universal complex solution. Also apache 
working in prefork mode (in general cases), I don't know does 
mod_jk\mod_proxy_ajp works in the worker-MPM mode...

In the preforking mode apache create a child on each incoming request, 
so it's too much expensive for resource usage. Also apache spend about 
15-30Kb mem for serving each tcp connection at this time nginx only 
1-1.5Kb. If you have, for example, abount 100 concurrent connections 
from different IPs there is nearly 100 apache forks... it's too expensive.

If you don't need full power of apache flexibility as server for dynamic 
applications, why use it for simple job such as proxing ?
So, I think nginx is great as light frontend server.

example config for proxing to tomcat backend:

location / {
rewrite ^/$ /tomcatapp/ redirect;
}

location /tomcatapp {
proxy_pass http://localhost:8080/tomcatapp;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;

}




More information about the CentOS mailing list