The simple approach is to prime the cache of worker threads by spawning your server and then making requests to your server from localhost just so that each thread connects to the database.
Otherwise, you will have to consult the documentation of your server as to what hooks it offers and how to take advantage of them.
Looking at Thrall::Server, it seems that it simply creates a new thread in ->_create_thread. You could override that or do your initialisation in a BEGIN block, or use a threads::shared variable to share information between your threads.
In reply to Re^3: How do I make a PSGI program do costly initialisation only once per process, not per thread?
by Corion
in thread How do I make a PSGI program do costly initialisation only once per process, not per thread?
by daxim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |