Reputation: 843
I know that web servers use thread pools to spare expensive thread creation operation. My question is, are the thread pools shared amond different modules deployed on the same web server?
In particular, we have two web modules deployed. A filter defined only in one module sets a threadlocal variable (and never unsets it). Would that be threadlocal also visible in another web module, as a result of the same thread being reused there?
thanks
Upvotes: 0
Views: 51
Reputation: 196
That heavily depends on the web server technology.
Node.js for example runs every module in a separate process of it's own. Every process will have a single thread running the server module's JavaScript code and other node runtime libuv threads in a thread pool doing async work under the hood. Since every module runs in its own process, it would have it's own thread pool which is not shared with other modules. Different processes can not share the same thread pool.
Moral of the story is, if the different web modules somehow run inside the same process, then yes they could theoretically share a same thread pool however if the web server runs each deployed web module in a process of it's own, then it's impossible that they share a same thread pool.
Upvotes: 1
Reputation: 56
I am not sure about all servers but in case of Tomcat, the thread pool is set for the given port. So if your modules are deployed under different ports then each of them will have the separate thread pool. So the threadLocal would be only visible for given module.
Sample extract from Tomcat config. I am guessing that the other servers use similar approach.
Upvotes: 1