• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Tomcat connection management

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

How would i configure my application server(TOMCAT) to only allow 10 concurrent connections at a time.
For every connection after that there should be a proper message indicating maximum connection reached.

Posts: 20938
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP does not work like a time-sharing computer system where you log in, establish a session, do work, then log out. HTTP is a series of one-shot request-response message exchanges, each of which has exactly one request and one response. Making it that much more difficult to limit "connections" is the fact that web pages often contain content that has to itself be handled by independent request/response cycles, such as image, script, and style fetches, which a typical user's browser will run in parallel.

I think probably you're thinking more along the lines of 10 sessions than 10 connections. An HttpSession gives the illusion of a continuous conversation, even though a lasting connection isn't possible. It does that by providing an ongoing conversation context.

You should be able to provide something in a Session Listener to limit to 10 outstanding sessions. However, an arbitrary limit to the number of sessions has little practical use. More commonly you'd want to throttle access to particular resources in a webapp. Also note that a session listener only deals with the sessions of the webapp that contains it. To throttle the server as a whole you'd need to augment Tomcat itself, either via a mechanism such as a custom Valve or by actual mods to the Tomcat source code.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!