Suppose on a high-traffic web-server, there are different types of requests from the client side. Eg.: user-requests vs internal/administrative types. And, among the user-requests, there's those you want to serve more promptly (because they are more time-critical, are more frequent, etc).
The single servlet to handle these requests is "light"-- it sees what each request is about and invokes right away the back-end process to handle it.
So, if you'd like to prioritize these requests, you prioritize these back-end processes on the server-- give them more CPU time, allocate them multiple server instances, etc.
The question here is: whether doing the same thing to the servlets as well as these backend processes is an issue or not. I'm aware that the servlet container (Tomcat in this case) has some mechanisms-- although I don't know what/how exactly.
On one side of this discussion-- yes: code different servlets for different client requests so that you can manage their priorities/execution time at the server level.
On the other side-- no, not at all:
The servlet(s) are handling the requests and dispatching them
to the corresponding processes without burning execution time.
It's the back-end processes that are time-critical.
In fact, this is exactly what Spring is doing--
has the DispatcherServlet as the front-controller for all incoming requests.
A single servlet as the front-controller for all requests is the sound architecture.
This discussion came up few days back. up until then, i was on the "no" side-- the paragraph right above. however, i'm not as clear right now. I'm wondering what would be a sound counter-argument to the claim that "managing the priorities of the servlets for their types improves the time performance on serving the client requests."
TIA.
//==================================================
EDIT:
If the case "yes" above,then how does Spring tell the servlet container about the different types of requests so that the s.container can prioritize them?
I don't think the requests prioritization will have a huge effect on thread time execution unless were talking about a huge traffic like millions of thread on a single web server.But if that is what you want you can configure tomcat to prioritize threads. Tomcat allows you to specify the priority of each thread in an executor's thread pool: tomcat thread pool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With