Java Rest Client: I/O Dispatcher threads buildup in Tomcat

We are observing a steady build up of I/O dispatcher threads when firing queries from a Tomcat webapp we've developed. One thing to note... we are using the low-level Java REST client, and we only call close() on the RestClient when the webapp is stopped during Tomcat shutdown (i.e. ServletContextListener)... does this mean that the I/O dispatcher threads are only released then? Is there another way to release these threads? The problem is that they end up consuming a lot of memory and eventually the Tomcat instance goes OutOfMemory. Is there some basic step we could be missing here to ensure proper cleanup?

Also want to point out that our requests are returning with HTTP code 200, so we don't think it has anything to do with connections not getting cleaned up on failure.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

Hi @Neel_Tiwari,

I know that this is an old issue, but I was wondering what made you think that this was a problem rather than just surprising?

Were you seeing the number of threads growing? Or was it just creating a surprising number (one per CPU core) ?

Thanks,
Chris

Just to close this out:

The current expected behavior is that the client will create a thread per CPU core. If you find yourself seeing a lot more, then either you are creating extra clients or something is wrong. In those cases, please open an issue on GitHub.

Thanks,
Chris