You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ed Park <ep...@athenahealth.com> on 2000/12/12 08:49:17 UTC

Apache::Session benchmarks

FYI-- here are some Apache::Session benchmark results. As with all
benchmarks, this may not be applicable to you.

Basically, though, the results show that you really ought to use a database
to back your session stores if you run a high-volume site.

Benchmark: This benchmark measures the time taken to do a create/read for
1000 sessions. It does not destroy sessions, i.e. it assumes a user base
that browses around arbitrarily and then just leaves (i.e. does not log out,
and so session cleanup can't easily be done).

RESULTS: I tested the following configurations:

Apache::Session::MySQL - Dual-PIII-600/512MB/Linux 2.2.14SMP: Running both
the httpd and mysqld servers on this server. Average benchtime: 2.21 seconds
(consistent)

Apache::Session::Oracle - Ran the httpd on the dual-PIII-600/512MB/Linux
2.2.14SMP, running Oracle on a separate dual PIII-500/1G (RH Linux 6.2).
Average benchtime: 3.1 seconds (consistent). (ping time between the servers:
~3ms)

Apache::Session::File - Dual-PIII-600/512MB/Linux 2.2.14SMP: Ran 4 times.
First time: ~2.2s. Second time: ~5.0s. Third time: ~8.4s. Fourth time:
~12.2s.

Apache::Session::DB_File - Dual-PIII-600/512MB/Linux 2.2.14SMP: Ran 4 times.
First time: ~20.0s. Second time: ~20.8s. Third time: ~21.9s. Fourth time:
~23.2s.

The actual benchmarking code can be found at
http://www.lifespree.com/modperl/ (warning - the site is in a terrible state
right now, mostly a scratchpad for various techniques & benchmarks)

Question: does anyone know how to pre-specify the _session_id for the
session, rather than allowing Apache::Session to set it and read it? I saw
some posts about it a while back, but no code...

cheers,
Ed


Re: Apache::Session benchmarks

Posted by Gerald Richter <ri...@ecos.de>.

> Gerald Richter sent the following bits through the ether:
>
> > That only works if the session id already exists. If the session id
doesn't
> > exists, Apache::Session will throw an exception (die)
>
> The documentation implies that is it currently possible to do so.

But the perl code shows that it doesn't work. For example Store/DBI.pm in
the function materialize die's when it doesn't find the row with the id you
given in the database. It's the same for other Stores.

> I'd
> love for it to be possible to do so, but I can't seem to contact
> Jeffrey. Was it a complicated patch?
>

it overrides the the TIEHASH method in Session.pm. It wasn't too hard, but I
don't have a patch for Session.pm that comes with Apache::Session 1.53, but
you can simply use HTML::Embperl::Session instead of Apache::Session, which
works with Apache::Session 1.00 and 1.5x and which should work also outside
of Embperl.

perldoc HTML::Embperl::Session

shows the additional attributes you can pass to tie. The rest remains the
same as with Apache::Session.

Gerald





Re: Apache::Session benchmarks

Posted by Leon Brocard <ac...@astray.com>.
Gerald Richter sent the following bits through the ether:

> That only works if the session id already exists. If the session id doesn't
> exists, Apache::Session will throw an exception (die)

The documentation implies that is it currently possible to do so. I'd
love for it to be possible to do so, but I can't seem to contact
Jeffrey. Was it a complicated patch?

Cheers, Leon
-- 
Leon Brocard.............................http://www.astray.com/
yapc::Europe............................http://yapc.org/Europe/

... All new improved Brocard, now with Template Toolkit!

Re: Apache::Session benchmarks

Posted by Gerald Richter <ri...@ecos.de>.
>
> > Question: does anyone know how to pre-specify the _session_id for the
> > session, rather than allowing Apache::Session to set it and read it? I
saw
> > some posts about it a while back, but no code...
>
> Isn't it just this?
>
> tie %session, 'Apache::Session::Foobar', $id;
>
That only works if the session id already exists. If the session id doesn't
exists, Apache::Session will throw an exception (die)

I run into the same problem with Embperl. I send a patch against
Apache::Session to Jeffery to allow this (and other things), but he didn't
incorporated it and instead created a separte class for it. Since it was
easier to maintain this class is now part of the Embperl distribution.
HTML::Embperl::Session is a sub class of Apache::Session and allows you to
specify the id, even if it doesn't already exists, along with a set of flags
what to do in various cases (create new one, if the id doesn't exists;
create the specified id or die)

Gerald



Re: Apache::Session benchmarks

Posted by Perrin Harkins <pe...@primenet.com>.
On Wed, 13 Dec 2000, Jeremy Howard wrote:

> Perrin Harkins wrote:
> > > Apache::Session::File - Dual-PIII-600/512MB/Linux 2.2.14SMP: Ran 4
> times.
> > > First time: ~2.2s. Second time: ~5.0s. Third time: ~8.4s. Fourth time:
> > > ~12.2s.
> >
> > Is there any reason not to use a file tree approach (splitting first and
> > second characters of filenames into separate directories) like mod_proxy
> > does?  This seems like a pretty easy solution to the problem of degraded
> > performance on larger sets of data.
> >
> If you use File::Cache for storage, then it does this for you, to a
> user-defined depth.

Which begs the question, is there any reason not to combine these modules
into Hash::Persistent or something?

- Perrin


Re: Apache::Session benchmarks

Posted by Jeremy Howard <jh...@fastmail.fm>.
Perrin Harkins wrote:
> > Apache::Session::File - Dual-PIII-600/512MB/Linux 2.2.14SMP: Ran 4
times.
> > First time: ~2.2s. Second time: ~5.0s. Third time: ~8.4s. Fourth time:
> > ~12.2s.
>
> Is there any reason not to use a file tree approach (splitting first and
> second characters of filenames into separate directories) like mod_proxy
> does?  This seems like a pretty easy solution to the problem of degraded
> performance on larger sets of data.
>
If you use File::Cache for storage, then it does this for you, to a
user-defined depth.



Re: Apache::Session benchmarks

Posted by Perrin Harkins <pe...@primenet.com>.
> FYI-- here are some Apache::Session benchmark results. As with all
> benchmarks, this may not be applicable to you.

Thanks for taking the time to run these and write up the results.

> Benchmark: This benchmark measures the time taken to do a create/read for
> 1000 sessions. It does not destroy sessions, i.e. it assumes a user base
> that browses around arbitrarily and then just leaves (i.e. does not log
out,
> and so session cleanup can't easily be done).

It would be interesting to see how the options perform with different mixes
of read/write traffic, i.e. not writing every time as you are in your
current code.  Maybe not that big a deal, since we can assume more writes
will have worse performance across the board, but it would also be
interesting to see how locking issues might come into play if you were using
different lock managers.  And the next step from there would be to run the
test from many processes in parallel and see how they do.

> Apache::Session::File - Dual-PIII-600/512MB/Linux 2.2.14SMP: Ran 4 times.
> First time: ~2.2s. Second time: ~5.0s. Third time: ~8.4s. Fourth time:
> ~12.2s.

Is there any reason not to use a file tree approach (splitting first and
second characters of filenames into separate directories) like mod_proxy
does?  This seems like a pretty easy solution to the problem of degraded
performance on larger sets of data.

> Question: does anyone know how to pre-specify the _session_id for the
> session, rather than allowing Apache::Session to set it and read it? I saw
> some posts about it a while back, but no code...

Isn't it just this?

tie %session, 'Apache::Session::Foobar', $id;

- Perrin