Fahad Ahammed
Fahad Ahammed

Reputation: 371

How can i limit Tomcats Simultaneous Connection?

I have been testing Apache Tomcat recently. I am using Ubuntu-16.04 and Apache Tomcat/8.0.36. I was messing around with server.xml with connection limit. I was trying to limit it to 2 simultaneous connection. But setting maxThreads="2" is not working to my expectation. I was testing by:

ab -n 150 -c 150 http://127.0.0.1:8080/

But it just acts well without closing any connection.

Upvotes: 0

Views: 100

Answers (1)

Ved
Ved

Reputation: 8757

First of all you need to understand difference between maxThreads and maxConnections. You can find both this parameters in server.xml. Usually Tomcat runs in 2 modes -

1. one thread one connection 
2. one thread many connections  

I believe you are using Tomcat 8 which uses second mode (can be configurable). So while setting up maxThreads = 2 you are not setting connections but you are limiting threads which Tomcat allowed to create.

One more thing, you might setup keepAlive parameter to improve performance (Remove connections that are not used since some time).

Hope this helps.

Upvotes: 1

Related Questions