An alternative to mod_perl et al is SpeedyCGI. You still fork one process per CGI request, but the actual script gets stuffed into a background daemon for a given time or number of invocations. The connection set-up would go into the global variables space of the script == backend. The first caller would initialize it, subsequent calls re-use until the backend terminates (and takes any memory leak with it).