views:

44

answers:

2

Today if i login into g-mail.after 3-4 days also i could see my account without logout. If everybody in this world do same thing,maintaining connections in a pool becomes difficult(may be because of Memory constraints).So if an account is idle after 2-3 days i think it is better to disconnect (disconnected one can be used for new connection).How long time(days) g-mail user can maintain connection with server if he doesn't logout.Can somebody explain this process of connecting to website , maintaining connection and connection pooling mechanism ?

+4  A: 

You seem to be misunderstanding one thing. The web (in general) doesn't use actual persistent TCP connections, it uses a request and response methodology. The actual connection gets closed after the request and response have been exchanged (or a short while after). The thing that looks like a "connection" is just a unique session token Google has given to you to identify your "connection". And that's as expensive as having a row in a database, that is, not expensive at all.

(Let's try not to get into a big confusing debate about whether packet switched networks ever have anything that could be called a persistent connection.)

Matti Virkkunen
But there is a session maintained on the server. So while the communication channel is "closed", the state is preserved. In a technical point of view, it's different, but in a logical point of view, it makes sense to ask the question above.
Pierre 303
However the session state Google has to store is quite small in size. And they have like JIGGABYTEs of storage!
Matti Virkkunen
+1  A: 

Every minute or so, the web page your are in (gmail) is requesting for an update (new mails for example) on the Google's load balancer servers. Since you do it frequently, your session on their servers stay alive.

Since you are "disconnected" form the web server as soon as you received the response, the session is maintained in their database using a record referencing an id that is also stored in a cookie on your local machine. (please read Matti's response to avoid confusion with TCP connections)

To answer the question, how they handle the load ? The request you do each minute is very small, and the response too. Compared to a google search for example. For the session, it's a single line in their databases, which if few bytes... compared to the 7 giga bytes they provide to all their users, it's nothing.

Further reference:

http://en.wikipedia.org/wiki/Http_session#Web_server_session_management

Pierre 303