Apache Tomcat Request Threads

后端 未结 3 614
陌清茗
陌清茗 2020-12-15 14:15

We have an application which leaks a bit of memory, a bit being an understatement.

I am using jvisualvm to try and find what is causing the problem.

3条回答
  •  隐瞒了意图╮
    2020-12-15 15:08

    Generally speaking, application servers will pre create a number of threads. Not only will the app server create them, but it will keep the threads around. This is known as a thread pool. The server will take a request and dispatch it to a thread, and when that request completes, the server will dispatch a new request to that thread.

    Thread creation overhead is rather expensive so handling many requests benefits greatly from sharing threads. To answer your question, dispatching threads created by the server (assuming no serious runtime errors occur) will live for the lifetime of the server.

    As for what you are seeing, if you see many many threads being started, then some other part of the application can be forking threads in which is a completely separate issue.

    Its important to know that your tomcat server should not be creating new threads for each request (again generally speaking) it should reusing threads.

提交回复
热议问题