Apache Tomcat performance

Hi,

I’m a newbie on Nginx and I became interested in it because Apache 2 is
so wasteful with resources. However, Nginx seems a lot slower than
Apache. It takes about 3 seconds to return a request even when I’m
within the cache timeout period which surprises me.

My test server is 512MB, Lucid Lynx with Apache Tomcat 6.0.24 and Nginx
0.7.65.

I’ve set up an asset server configuration and an application server
configuration.

Any help’s appreciated.

server.xml

I also tried the Nio protocol with the same result.
I used apt-get install libtcnative-1 (1.1.19) to install the APR support
for Tomcat and I can see that the native libraries are being loaded

default nginx

server {
  listen          80 default;
  server_name     _;
  server_name_in_redirect  off;
  charset utf-8;
  root            /usr/shared/apache-tomcat-6.0.x/webapps/ROOT;
  add_header  Cache-Control public;

  location /WEB-INF/ {
    deny all;
  }
  location ~ /\.ht {
    deny  all;
  }

  location / {
    try_files $uri $uri/ @proxy;
  }

  location @proxy {
    proxy_pass              http://localhost:8080;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
    proxy_max_temp_file_size 0;
    proxy_buffering off;
    proxy_store         off;
    proxy_connect_timeout 120;
    proxy_send_timeout    120;
    proxy_read_timeout    120;

    # All POST requests go directly
    if ($request_method = POST) {
      proxy_pass http://localhost:8080;
      break;
    }
  }
}

assets nginx

server {
  listen          80;
  server_name     assets.mercadosa.com;
  root            /usr/share/apache-tomcat-6.0.24/webapps/ROOT/assets;

  location / {
    rewrite ^/[^/]+(/.*)  /$1;
    expires 90d;
  }
}

Posted at Nginx Forum:


nginx mailing list
[email protected]
http://nginx.org/mailman/listinfo/nginx

Ok, so, installing native support by installing libtcnative-1 is not the
same as building Tomcat with APR native?

Posted at Nginx Forum:

mschipperheyn at 2011-1-4 5:38 wrote:

Ok, so, installing native support by installing libtcnative-1 is not the
same as building Tomcat with APR native?

Try nginx_ajp_module(GitHub - yaoweibin/nginx_ajp_module: support AJP protocol proxy with Nginx), it
will help you to get a better performance.

Posted at Nginx Forum:
Re: Apache Tomcat performance


nginx mailing list
[email protected]
nginx Info Page


Weibin Y.

@Jérôme
Yes and yes. I tried both Nio and Apr connector

Posted at Nginx Forum:

Do you see something like this at tomcat startup?
Jan 3, 2011 6:29:22 PM org.apache.catalina.core.AprLifecycleListener
init
INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
Jan 3, 2011 6:29:22 PM org.apache.catalina.core.AprLifecycleListener
init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true].
Jan 3, 2011 6:29:23 PM org.apache.coyote.http11.Http11AprProtocol init

And do you have defined connector for your service catalina in
server.xml with Http11AprProtocol :

If yes, you have indeed Tomcat with APR well configured.

Le 3 janv. 2011 22:38, mschipperheyn a crit :

@Weibin
Do you know the difference between the apr_cache directives and the
proxy_cache directives
They are probably fudnamentally different but because they look so
similar I’m wondering

Posted at Nginx Forum:

mschipperheyn at 2011-1-8 19:31 wrote:

@Weibin
Do you know the difference between the apr_cache directives and the
proxy_cache directives
They are probably fudnamentally different but because they look so
similar I’m wondering

apr_cache or ajp_cache? ajp_cache is the similar feature with
proxy_cache while nginx_ajp_module connects with backends via AJP
connector.

Posted at Nginx Forum:
Re: Apache Tomcat performance


nginx mailing list
[email protected]
nginx Info Page


Weibin Y.