how to handle database connection to a single database SQLite, or even Pg, MySQL, from a possibly-forking program. Do I initiate the DB connection from each forked worker? Or can I share parent's DB handle among the children/workers? The 1st option means that I connect/disconnect to the db each time a worker is spawned. How then is possible to keep a DB connection alive "for-ever"? #### # run: hypnotoad myapp.pl # then (for 6 simultaneous clients) # for i in {1..6}; do echo $i; done | parallel -j 6 "echo '$0 : called with pid=$$ and param={}'; curl 'http://localhost:4444/' -o 'a{}'" # with no GNU parallel, do this: # for i in {1..6}; do wget 'http://localhost:4444/' -O a$i & done use Mojolicious::Lite; use Mojolicious::Plugin::OnFork; my $PORT = 4444; plugin OnFork => sub { print "FORKED with pid=$$ !\n"; }; get '/' => sub { my $c = $_[0]; sleep(1); $c->render( 'text' => "hello there from pid=$$\n" ); }; my $daemon = Mojo::Server::Daemon->new( app => app, listen => ["http://*:${PORT}"], single_accept => 0, keep_alive_timeout => 1, ); print "$0 : started listening on port ${PORT} (pid $$) ...\n"; $daemon->run;