Does application server create new thread for each request from same user?

橙三吉。 提交于 2019-12-23 15:13:21

问题


Here is the simple scenario:

User triggers some operation from a web page of the web application. This operation is heavy one and takes some more time.

And before the operation is completed on server side, user triggers say same operation with some different parameters. so the second operation for second request will also start processing.

So in this case, are there two different threads like 1st one processing first request and other for 2nd request ? or it's just one thread processing both the requests and first operation is just interrupted (left uncompleted) for sake of execution for second request ?

Here I don't want to avoid user requesting same operation multiple times. Just want to know how it works.

This might be a silly question but i am little confused with this. And what is happening with me is adding into the confusion. For me it seems like operation for 1st request is not getting completed.

It's Websphere application server, if that helps.


回答1:


WebSphere Web Container uses a Thread Pool for all the requests.

For any request (doesn't matter who made it) a thread is obtained from the pool, the request is processed, and the thread goes back to the pool.

Even if the requests are one after the other, there is no guarantee the same thread will process them.

If you see one request interfere with another it is most likely something you do in your code and not due to how WebSphere behaves.




回答2:


No. Each request is independent of others. There is no thread affinity in websphere. One good way of teaching urself is checkout the websphere logs. When WebSphere writes a record to its log file e.g. SystemOut.log,etc the log includes a thread id. Here is an example record in the WebSphere log file:

[12/11/08 13:06:36:830 CST] 0000002e VirtualHost I .....

The second field is the thread id which is "0000002e". So this way you may correlate how two requests are being handled by two different threads. Hope it make sense to you.



来源:https://stackoverflow.com/questions/14440241/does-application-server-create-new-thread-for-each-request-from-same-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!