On Sat, 9 May 2020 at 9:09 PM, Vikas Kumar <hers...@gmail.com> wrote:

> I did not know about the images being dropped.
>
> Here are the steps I depicted in the image:
>
> Step 0: Request accepted by OS
> Step 1: Request sent to Tomcat. Tomcat accepts the request if it's internal
> queue is not full, else rejects the request
> Step 2: Tomcat adds the request to the queue if all worker threads are
> busy, else sends the request to one of the free worker threads
> Step 3: Request is picked by the worker thread for processing
>
> I would like to add a hook between step(1) and step (2). As I mentioned
> earlier, I want to dynamically control the Tomcat internal queue size based
> on some application logic. Is there a way to do that?
>

The queue is managed here:
https://github.com/apache/tomcat/blob/14406c0b49c29fd05dd8f707b62ece38429e16f8/java/org/apache/tomcat/util/net/AbstractEndpoint.java#L429

And there is an mbean here for the NIO connector:
https://github.com/apache/tomcat/blob/7d66c652a3e4d64b9711712fa1409ba1261effd8/java/org/apache/tomcat/util/net/mbeans-descriptors.xml#L91

I don’t know if that makes the attribute query able as well as writable,
though. You may want to experiment and check.

What you are looking at writing, though, will be code that lives outside
your warfile and as an extension to Tomcat ( is you want to enhance the
AbstractEndpoint above), or at least JMX privileges (in case changing the
limit is permitted by that mbean config)

Alternatively, you could consider setting maxConnections and or acceptCount
to higher numbers. See :
https://tomcat.apache.org/tomcat-8.5-doc/config/http.html

Ram



>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Sat, May 9, 2020 at 6:16 PM calder <calder....@gmail.com> wrote:
>
> > On Sat, May 9, 2020, 07:16 Vikas Kumar <hers...@gmail.com> wrote:
> >
> > > As per my understanding (using a Spring Boot app with Tomcat server),
> we
> > > define:
> > >
> > >    - Max no. of worker threads (maxThreads, default 200)
> > >    - Tomcat queue size (maxConnections, default 8192 for APR, 10000 for
> > >    NIO). When all worker threads are busy, requests are placed into the
> > queue.
> > >    As worker threads free up, queued requests are sent to them in FIFO
> > order
> > >
> > >
> > I'll assume the "steps" are shown in the "broken" image (inline/attached
> > images are normally dropped) - you'll need the convert whatever text is
> > contained into actual text and post back.
> >
> >
> > [image: Untitled Diagram.png]
> > >
> > > I can add a hook at step (3) using a servlet filter or
> > >
> > [ snip ]
> >
>

Reply via email to