simple multiuser considerations

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi everyone,
Managing sessions and cookies looks simple if you go by the varied
tutorials on the web. But I have a few questions about real multiuser
issues which i could not get any tutorials on:

1)say, I have a page doesalot.php on which will
be accessed by say 50 users at a time. Then, my session id checking
script must run 50 instances, one for each user and the appropriate
database table must, at the end of that time, get 50 rows, one for each
session (of course, i've written the db insert code into the page right
at the top). Does this happen by default or do I have to set something
in php.ini or anywhere else or worse, take care of it in the script by
checking for IP via $_SERVER['REMOTE_ADDR'] etc.

2) If it is just 5-10 users per second maybe it will not be a problem,
but a worst-case load of say 50-100 requests per second will definitely
be an issue (assuming my host has given me enough bandwidth). Is there
some setting for such tuning?

It'll be great if someone could point me to a site or tutorial that
deals with these issues.

Thanks in advance,
Joseph S.

Re: simple multiuser considerations

Joseph S. wrote:

Quoted text here. Click to load it

Take a look into session_set_save_handler:

You may find something that will save you a lot of time.

Justin Koivisto, ZCE -

Re: simple multiuser considerations

Let me rephrase my question,

If i have a page dosomething.php which three users situated at
geographically diverse locations are simultaneously viewing, and if I
or some such code,
are there, in the server machine's RAM, totally three different
$_SESSION['x'] variables with their respective values or is there just

I looked up and found (send win enabler white paper) that the CGI
installation of PHP under Apache,Windows works like that - there is "a
separate process initiated" for each request of the dosomething.php
page and apparently (not clearly stated) not the apache module version
of PHP.

It also says that php on apache 1.3 on Unix (or linux) uses a
multiprocess webserver - meaning one process for each request.

I have a WinXP machine for development and will be deploying to a host
that has PHP and MySQL on Apache on Linux.

Will that setup be <one request one $_SESSION['x'] variable> ?

Also, does the code have to be written in a different way for LAMP than
for WAMP(apachemodule, not CGI) or does it automatically understand so
and behave thread safe?
In other words, do I have to do anything else to my $_SESSION['x'] =
$_GET['x'] for the code to work on LAMP after seeing it run properly on
my single user WAMP development setup?

Thanks in advance.
Joseph S.

Re: simple multiuser considerations

Quoted text here. Click to load it

There will, of course, be three separate session data structures, and three
separate instances of $_SESSION['x'].  That is the entire point of using
sessions -- to distinguish between different users.

Quoted text here. Click to load it

Well, sort of; *every* CGI request, regardless of the language, starts up a
new process.  When the request has been handled, the process ends
(usually).  The session stuff has to be put in a store somewhere so that it
does not evaporate.

Quoted text here. Click to load it


- Tim Roberts,
  Providenza & Boekelheide, Inc.

Re: simple multiuser considerations

Thanks, Tim. Your reply was very helpful, cleared all the doubts. I'm
doing a small project for a company. The advice is invaluable.

Jospeh S.

Site Timeline