Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: How to keep network connection persistent during session?

by PetaMem (Priest)
on Oct 12, 2009 at 08:15 UTC ( [id://800623]=note: print w/replies, xml ) Need Help??


in reply to Re: How to keep network connection persistent during session?
in thread How to keep network connection persistent during session?

Hello Monks,

thank you for your answers. I would like to clarify some things.

  • I'm using newest Apache2, newest mod_perl.
  • I do not need nor want to store the connections on disk. I would simply want that within a session a network connection is opened, and remains open as long as the session is active. Which means the network connections life should extend - of course - the life of the running apache processes that happen during that session. That's the whole problem.
  • The backend is not a DB, but an own server process (which uses Net::Server::Multiplex

If it's going to be a "daemon brokering the connections", that's ok, I just thought Apache2/mod_perl2 would have something that persistent themself - shared memory perhaps? Some space all Apache processes are sharing for the lifetime of the Apache process? (I'd be willing to take into account that if the Apache as whole had to be restarted that the network connections would be lost).

Thanks

Bye
 PetaMem
    All Perl:   MT, NLP, NLU

  • Comment on Re^2: How to keep network connection persistent during session?

Replies are listed 'Best First'.
Re^3: How to keep network connection persistent during session?
by afoken (Chancellor) on Oct 13, 2009 at 19:38 UTC
    I'm using newest Apache2, newest mod_perl.

    That does not change even one bit in the HTTP protocol, so it is (nearly) irrelevant.

    I do not need nor want to store the connections on disk. I would simply want that within a session a network connection is opened, and remains open as long as the session is active. Which means the network connections life should extend - of course - the life of the running apache processes that happen during that session. That's the whole problem.

    Serialisation does not necessarily mean writing to disk. It just means to generate a string of bytes representing a complex structure. And you can't to that with a network connection, because you literally hold only one end of the connection.

    Basically, you want to extend the session handling to also manage a network connection. A naive implementation would use a hash, using the session ID as key and the file handle of the socket (network connection) as the key. Whenever you create a new session, you also generate a new socket, and store both in the hash. Whenever the session is closed or expires, you close the socket and remove session ID and socket handle from the hash.

    A better solution would be to separate connection and session also in the backend. If you use some kind of remote procedure call API, create a new session in the backend and get a handle (a simple, random number) back. Use that handle for all interactions during the session, and destroy the handle when the session is terminated or expired. Connect to and disconnect from the backend as needed.

    The backend is not a DB, but an own server process

    As most DBs are separate server processes, this is irrelevant, too. In fact, it does not matter if you connect to a DB server, an FTP server, or a coffee machine server.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://800623]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found