Re: Sessio variables and Load Balancing
| From: | Kristian Köhntopp | Date: | Tue, 04 Jul 2000 15:25:54 +0000 |
| Subject: | Re: Sessio variables and Load Balancing | ||
| References: | 1 2 3 4 5 6 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23475@lists.php.net to get a copy of this message | ||
Chris Adams wrote:
> The session read handler should be called once at the start of the page and
> the write handler once at the end. With a decent session handler, it's 2
> queries per page (SELECT,UPDATE), with an additional INSERT when the session
> is first created and a DELETE when session_destroy() is called.
Plus, these queries are with a constant against a unique index, zero
joins, which is the fastest query against a database you can have.
This is actually much faster than any file access, especially when
gc runs. I have much anecdotal evidence for this from PHPLIB users.
Kai Voigt of NetUSE (kv@netuse.de) has reimplemented much of this
logic in the Roxen webservers Session module. His module is running
at real.com and some other large sites. The Real people had problems
with gc taking considerable time when using file storage, and he came
up with a database storage handler, which completely solved this
problem. The bottleneck was the large number of stat() calls during
gc (Quadratic directory search times multiplied by number of gc's
running). Another minor source of slowdown was the number of namei()
lookups in large directories on page_open() and page_close() (Quadratic
directory search times).
Compare this to logarithmic access times in a database when querying
an index with a constant value or with a cutoff value (as in gc).
All in all the inital overhead is slightly larger in a database, but
the database wins hands down in scaling (tested with MySQL only,
do not know about Oracle).
Kristian
--
Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel
Tel: +49 431 386 436 00, Fax: +49 431 386 435 99
Using PHP3? See our web development library at http://phplib.netuse.de/