Reputation: 4187
let say i have implemented few Rest
end points.
Now i want to make sure the a particular route let say POST /log
only get a max of 2 thread and other important route get the rest of the Threads
.
During load hour we dont want to have many thread out of thread pool invested in POST /log
route. We dont care about POST /log
route.
[1] How to achieve this is in tomcat?
[2] Is there some other way to achieve this instead of relaying on web server?
PS: I did find SingleThreadModel interface in Servlet
, but this has been deprecated.
EDIT:
I dont want to add a filter and count request and once limit exceed drop the request as in this case the JVM will still take the heat of switching thread context, just to run my count request and drop request.
Ideally something like event loop of NODE.JS
is refereed where there is only one thread who is processing request and others are queued up.
in my knowledge one crud way to achieve this is by having different connector for which route and assign threadpool to each.But i looking for something for development friendly.
Upvotes: 2
Views: 760
Reputation: 18552
What you need is a basic quality of service where you allocate resources to certain URIs.
This can be achieved with Servlet filters, and yes HTTP requests can be queued since Servlet 3.0.
Jetty, for example, provides a QoSFilter exactly for this purpose, see its documentation.
Upvotes: 2
Reputation: 49462
Setup the QoSFilter and mark your priorities appropriately for the url-patterns that you want to limit.
Upvotes: 2