# Apache Tomcat performance

**URL:** <https://www.ruby-forum.com/t/apache-tomcat-performance/201212>\
**Category:** NGINX\
**Created:** [January 3, 2011, 2:37am UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212 "2011-01-03T02:37:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 3, 2011, 2:37am UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/1 "2011-01-03T02:37:40Z")

</div>

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

```auto

```

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

```auto
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

```auto
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:

> **[Apache Tomcat performance](https://forum.nginx.org/read.php?2,162986,162986#msg-162986)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 3, 2011, 10:41am UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/2 "2011-01-03T10:41:29Z")

</div>

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://nginx.org/mailman/listinfo/nginx](http://nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 3, 2011, 10:39pm UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/3 "2011-01-03T22:39:20Z")

</div>

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

Posted at Nginx Forum:

> **[Re: Apache Tomcat performance](https://forum.nginx.org/read.php?2,162986,163236#msg-163236)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 4, 2011, 3:38am UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/4 "2011-01-04T03:38:32Z")

</div>

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 · GitHub](https://github.com/yaoweibin/nginx_ajp_module)), it  
will help you to get a better performance.

> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,162986,163236#msg-163236](http://forum.nginx.org/read.php?2,162986,163236#msg-163236)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 8, 2011, 12:26pm UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/5 "2011-01-08T12:26:28Z")

</div>

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

Posted at Nginx Forum:

> **[Re: Apache Tomcat performance](https://forum.nginx.org/read.php?2,162986,164539#msg-164539)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 4, 2011, 2:36pm UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/6 "2011-01-04T14:36:18Z")

</div>

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 :

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 8, 2011, 12:32pm UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/7 "2011-01-08T12:32:44Z")

</div>

@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:

> **[Re: Apache Tomcat performance](https://forum.nginx.org/read.php?2,162986,164540#msg-164540)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![mschipperheyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mschipperheyn](https://www.ruby-forum.com/u/mschipperheyn)\
**Post date:** [January 10, 2011, 3:52am UTC](https://www.ruby-forum.com/t/apache-tomcat-performance/201212/8 "2011-01-10T03:52:14Z")

</div>

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:  
> [http://forum.nginx.org/read.php?2,162986,164540#msg-164540](http://forum.nginx.org/read.php?2,162986,164540#msg-164540)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.
