Limiting the number of threads Compojure spawns

北城以北 提交于 2019-12-09 23:29:38

问题


I'm running compojure on Heroku. They have a limit of a 100 threads per process. So when I go over that limit, I get: java.lang.OutOfMemoryError: unable to create new native thread. Compojure is using the jetty ring adapter. Is there away of configuring the the server to only accept a hundred threads to the servlet at a time?


回答1:


The solution comes from Chris Perkins over at the compojure google group.

(run-jetty app {:configurator #(.setThreadPool % (QueuedThreadPool. 5))})

This initializes a QueuedThreadPool (with a concurrent limit of five threads) to the jetty instance, before it starts.



来源:https://stackoverflow.com/questions/7878725/limiting-the-number-of-threads-compojure-spawns

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