Re: PHP session replication
| From: | Florin Jurcovici | Date: | Sat, 19 Mar 2011 14:06:37 +0000 |
| Subject: | Re: PHP session replication | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-311972@lists.php.net to get a copy of this message | ||
Hi.
Just for comparison:
PHP does not provide sessions in the same way a servlet-based platform
provides. PHP actually destroys the in-mem representation of sessions
after each request is served, whereas a servlet-based platform caches
the sessions in mem between requests.
ASP.Net also serializes session state, but not into a cookie - it uses
a hidden field instead. Which works around cookie size limitation. You
don't even have a choice of database sessions with ASP.Net. OTOH, even
if performance might suffer, scalability, as far as the sessions
mechanism is concerned, is excellent - you don't need session
replication.
Servlet-based platforms provide the most complicated solution, when
compared to the other two. They keep sessions in mem, which improves
performance (no serialization/deserialization for each request), but
creates potential scalability problems. You won't hit the wall at a
few thousands of users, but replicating maybe a million sessions among
no more than a hundred servers causes the replication process to
consume quite a lot of resources, the resources being used for
replication increasing faster than linearly with each added server
(not quite exponentially, though). You can use sticky sessions with
most servlet-based platforms, but these come with their own problems
(already described by a previous poster). Nevertheless, in mem
sessions a la servlets are a very convenient mechanism to use - the
session replication is provided by the platform, and the app
programmer doesn't have to worry about it.
All three approaches rely on every piece of data in the session being
serializable, so you can't store interesting objects, like an open
file or the like, in sessions.
Does anybody know of any fundamentally different session
sharing/replication mechanism?
br,
flj