Connecting Tech Pros Worldwide Help | Site Map

simple multiuser considerations

  #1  
Old September 29th, 2005, 03:15 PM
Joseph S.
Guest
 
Posts: n/a
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 http://www.mysite.com/ 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,
Regards,
Joseph S.

  #2  
Old September 29th, 2005, 03:25 PM
Justin Koivisto
Guest
 
Posts: n/a

re: simple multiuser considerations


Joseph S. wrote:
[color=blue]
> 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 http://www.mysite.com/ 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.[/color]

Take a look into session_set_save_handler:
http://us2.php.net/manual/en/functio...ve-handler.php

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

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
  #3  
Old September 30th, 2005, 07:25 PM
Joseph S.
Guest
 
Posts: n/a

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
use
$_SESSION['x']=$_GET['x'];
or some such code,
then,
are there, in the server machine's RAM, totally three different
$_SESSION['x'] variables with their respective values or is there just
one?

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.

  #4  
Old October 2nd, 2005, 02:45 AM
Tim Roberts
Guest
 
Posts: n/a

re: simple multiuser considerations


"Joseph S." <js_dev@rediffmail.com> wrote:[color=blue]
>
>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
>use
>$_SESSION['x']=$_GET['x'];
>or some such code,
>then,
>are there, in the server machine's RAM, totally three different
>$_SESSION['x'] variables with their respective values or is there just
>one?[/color]

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.
[color=blue]
>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.[/color]

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.
[color=blue]
>Will that setup be <one request one $_SESSION['x'] variable> ?[/color]

Always.
[color=blue]
>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?[/color]

No.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
  #5  
Old October 3rd, 2005, 08:05 PM
Joseph S.
Guest
 
Posts: n/a

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.

Regards,
Jospeh S.

Closed Thread