How do I make a PSGI program do costly initialisation only once per process, not per thread? How do I make a PSGI program do costly initialisation only once per process, not per thread? multithreading multithreading

How do I make a PSGI program do costly initialisation only once per process, not per thread?


For whatever reason, the program thrall hard-coded a "loader" parameter in its configuration section:

my $runner = Plack::Runner->new(    server     => 'Thrall',    env        => 'deployment',    loader     => 'Delayed',    version_cb => \&version,);$runner->parse_options(@ARGV);

That string "Delayed" refers to the module Plack::Loader::Delayed, which delays the loading of .psgi files until first request comes. That would match your benchmarking result. (If you re-run the benchmark again without killing thrall, you'll see identical output).

You may try running thrall -L +Plack::Loader app.psgi, which reverts the "loader" parameter to the default value hard-coded in Plack::Runner.


Isn't this what the --preload-app option to Starman does?