|Perl: the Markov chain saw|
How to keep network connection persistent during session?by PetaMem (Priest)
|on Oct 11, 2009 at 20:40 UTC||Need Help??|
PetaMem has asked for the
wisdom of the Perl Monks concerning the following question:
a (Mason-based) webapp connects to a backend server via IO::Socket::INET. Now I would like to make that connection persistent for the session. unfortunately, simply pouring the client object into the session storage doesn't work, as this immediately complains:
The handle is created the usual way - I think.
But if I want to store it in a session, like this (Dumper output)
I see this error
I have read here about why this doesn't work and why some people think it doesn't make sense to try to achieve that persistence. Well - for me the reason is, that when the traffic gets high, I would prefer for a session not always to:
Actually I'd be pretty happy if one could omit the 1st and 3rd point, because they are simply performance killers during a session. Now what I have tried;
Circumventing the "Storable cannot store GLOB" problem by transfering bless( \*Symbol::GEN40, 'IO::Socket::INET' ), to a string and later evaluating that actually DOES work, but as I've been told this doesn't keep up the connection, instead it recreates just some glob. The result being a program that astonishingle DOES still work, but I see connections being established and terminated (probably when the last reference to the glob vanishes).
So what could one do? My next ideas would be:
1. some kind of mini-persistent-proxy on the frontend side that would keep up the persistent connections under some accessible index (and the index number of course easily storable in session data.
2. and/or by somehow tieing these sockets to the filesystem (socket files) and using them as the proxy. No idea HOW to do that, just an Idea, because I know there are socket "files".What would you suggest?