I already know that most implementations use a single thread, but is there anything in the specification that implies the single thread? I remember reading about distributed app servers which use a cluster of JVMs. Are there any such implementations? Or are there any such implementations possible? What do the specifications imply for such distributed implementations, and would such an implementation guarantee the single thread?
The relevant servlet spec 3.0 fragment:
6.2.3 Filter Environment
A Filter and the target servlet or resource at the end of the filter chain must execute in the same invocation thread.
Also there are too many frameworks that rely on ThreadLocal
set in one of the filters. If different thread was running filters and other calling the servlet (technically possible) they would all be broken.
Note that distribution only applies to separate requests, i.e. different servers in the cluster handle different requests. I have never heard about splitting a single request into to machines.
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