Is cherrypy's thread pool adding a delay during the first requests?
Gosku <[email protected]> Tue, 20 Sep 2016 10:44:40 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Hi, I have a cherrypy project that uses thread pool of 10 threads. The server.conf is like this: [global] server.socket_port = 8049 server.socket_host = "192.168.0.164" server.thread_pool = 10 tools.gzip.on = True tools.auth.on = True tools.Functions.on = True request.show_tracebacks = False request.error_response = 'handle_error' log.error_file = 'error.log' log.access_file = 'access.log' tools.secureheaders.on = True and webapp.py uses like this: conf_path = os.path.join(os.getcwd(), 'server.conf') cherrypy.config.update(conf_path) app = cherrypy.tree.mount(WEBSITE(), "/", config=conf_path) The thing is when I start cherrypy (or when I restart it with uwsgi because I deployed something) *the first requests are taking an increasing amount of time*, later going back to "normal" times. Today I realized that the number of increasing-time requests is related to the number of threads. For example, here you have a screenshot of this behavior when cherrypy is set up with a thread pool of 10: <https://lh3.googleusercontent.com/-e0iCX8YKJt8/V-FxtuQgzYI/AAAAAAAAXJo/bcPp4HHRhncnf_J69nzTRriPTRicx8smQCLcB/s1600/10threads.png> In the example, asking for the same resource is taking more and more time (the resource is not important). After asking for it 10 times, the server settles down and everything works as it should. The same thing happens if I configure a thread pool of 13: <https://lh3.googleusercontent.com/-Vhy4veEei3U/V-FyRLi6yjI/AAAAAAAAXJs/2jdRVwE2WJoMdm83mjOFftiOVBdy3rnagCLcB/s1600/13threads.png> After the 13th request, everything goes back to normal. This behavior is very annoying, specially because in production I have 40 threads (where the 40th request is taking around 20 seconds) and every time I deploy changes, the website slows down for a couple of minutes. *How can I fix it whithout setting the thread pool to 1?* Thank you on advance. Regards, Gosku -- You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at https://groups.google.com/group/cherrypy-users. For more options, visit https://groups.google.com/d/optout.