in reply to Re: How do I make a PSGI program do costly initialisation only once per process, not per thread?
in thread How do I make a PSGI program do costly initialisation only once per process, not per thread?
unless I’m missing somethingIndeed; you did not run thrall and couldn't make the crucial observations of the difference to plackup yourself.
With plackup, the initialisation happens only once, when main is called. It is easy to notice that the server only starts accepting connections three seconds after executing plackup. So the characteristics of the bad performance are at server start-up, only once, happening under the sysadmin's control - this is altogether acceptable. An end user never gets to experience it: either the server is down, or it's up and always responding fast. The example program does not show it, but there's one db connection.
With thrall, the server starts accepting connections almost immediately. However, each request runs the initialisation separately. I surmise this happens for each spawned thread until the pool is filled, afterwards requests are handled fast on each thread. So the characteristics of the bad performance are at unforeseeable times after the server has been started, up to --max-workers several times, happening under no one's control - this is altogether not acceptable. The user experience is spotty: works fast for most requests, especially when the server had already been running for some amount of requests, but when bad luck strikes and the request happens to be handled by a new thread, the server responds slowly. The example program does not show it, but there are up to --max-workers db connections, and the operations team does not appreciate that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I make a PSGI program do costly initialisation only once per process, not per thread?
by Corion (Patriarch) on Jun 01, 2017 at 14:54 UTC | |
|
Re^3: How do I make a PSGI program do costly initialisation only once per process, not per thread?
by vr (Curate) on Jun 01, 2017 at 13:51 UTC | |
by daxim (Curate) on Jun 07, 2017 at 11:02 UTC |