Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat doing 15K req/second on a single server using Jersey Jax-RS

I tried testing things on a VPS, and came close to 10K requests per second, and that was a simple 'hello world' servlet, let alone making a call to membase.

My VPS was a 2 x Intel Xeon X5570, quad-core “Nehalem” architecture.

Note: I'm not a java expert, nor a tomcat expert, this was on default settings.

Does anyone else deal with such high traffic that could shed some light?

I used apache bench, and I ran it maybe 4-5 times, doing about 100K requests to the server.

original: how to handle 2000+ requests/sec on tomcat?

like image 642
codecompleting Avatar asked Nov 01 '11 18:11

codecompleting


People also ask

How many requests can Tomcat handle per second?

The default installation of Tomcat sets the maximum number of HTTP servicing threads at 200. Effectively, this means that the system can handle a maximum of 200 simultaneous HTTP requests.

What is Jax-RS and Jersey?

The JAX-RS (JSR 311: The Java API for RESTful Web Services) specification provides a standardized Java-based approach to implementing REST-style web services. Jersey is the reference implementation of JAX-RS and I provide a brief introduction to JAX-RS via Jersey in this blog post.


1 Answers

Turn on NIO (Non-Blocking IO). This is not by default turned on. Without NIO, every HTTP connection is handled by a single thread and the limit is dependent on the amount of threads available. With NIO, multiple HTTP connections can be handled by a single thread and the limit is dependent on amount of heap memory available. With about 2GB you can go up to 20K connections.

Turning on NIO is a matter of changing the protocol attribute of the <Connector> element in Tomcat's /conf/server.xml to "org.apache.coyote.http11.Http11NioProtocol".

<Connector
    protocol="org.apache.coyote.http11.Http11NioProtocol"
    port="80"
    redirectPort="8443"
    connectionTimeout="20000"
    compression="on" />
like image 172
BalusC Avatar answered Nov 15 '22 06:11

BalusC