473,585 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How well do sessions scale?

Hi,

I'm new here-- I've been reading the group for a couple of days. Nice
group; I like the way n00b33 questions are handled.

I've been using a Javascript routine in index.html to determine a
visitor's browser's capabilities. The Javascript then calls main.php,
passing back its findings with a GET string; main.php saves the data as
a visitor's profile in $_SESSION elements. It then serves up home.html
and any further pages requested by the visitor after customizing them
according to the visitor's profile. This is an original technique--
I've not seen or read about any similar method of browser feature
detection.

It has been working quite well in a low volume web site
(http://thornhenge.org/IvyIsEvil/). Unless the visitor has Javascript
disabled, the redirect from index.html happens before that page is
rendered and so long as index.html and home.html are lightweight, there
is no discernable delay. (If the visitor has turned off Javascript,
meta redirection kicks in, or he can use an explicit link to
home.html-- and main.php will set up his session profile with default
values).

But I am worried about whether I'll run into server performance issues
with higher traffic. I'm new to PHP-- gradually working my way through
Welling & Thomson's book with frequent delvings into Gilmore's book
(and heavy use of www.php.net/manual/). I've yet to see any discussion
on the practical limits of sessions. So my more or less specific
questions are:

1. What is the practical size limit for the session array? What
behaviors will I see if this limit is exceeded?

2. Is there a practical limit on the number of simultaneous
sessions a simple server can handle? Would exceeding this
generate a "too many users" message or something?

3. How does PHP/Apache handle abandoned sessions? I'm assuming
that after an interval of no activity, a session is deleted?

4. Do you know of any good discussions on this topic, and could
you steer me toward them (rather than using bandwidth and
time to redundantly say it all over again here)?

TIA,
Will

Aug 1 '05 #1
3 3704
>1. What is the practical size limit for the session array?
What behaviors will I see if this limit is exceeded?
No limit really -- other than that imposed by whatever mechanism you're
using to store the session data. PHP's default session handler uses
files, so you're limited by disk space and any per-directory size
limits your OS might impose.
2. Is there a practical limit on the number of simultaneous
sessions a simple server can handle? Would exceeding
this generate a "too many users" message or something?
Again, you're limited by the session handler. If your OS has a limit
on the number of files in a single directory, that's your answer.
3. How does PHP/Apache handle abandoned sessions?
I'm assuming that after an interval of no activity, a session
is deleted?
Stale sessions are deleted by the garbage collection routine. There
are a couple of parameters that define what get's deleted and when.
Check out:

http://www.php.net/manual/en/ref.ses...gc-maxlifetime
http://www.php.net/manual/en/ref.ses...gc-probability
http://www.php.net/manual/en/ref.ses...ion.gc-divisor
4. Do you know of any good discussions on this topic, and
could you steer me toward them (rather than using bandwidth
and time to redundantly say it all over again here)?


A good place to start would be:

http://www.php.net/session
http://www.acros.si/papers/session_fixation.pdf

Also bear in mind that PHP allows you to redefine the session handler.
In other words, if you don't like PHP's default of storing session data
in files, you could make it use a database or keep everything cached in
RAM. The possibilities are really limitless.

Aug 1 '05 #2
>It has been working quite well in a low volume web site
(http://thornhenge.org/IvyIsEvil/). Unless the visitor has Javascript
disabled, the redirect from index.html happens before that page is
rendered and so long as index.html and home.html are lightweight, there
is no discernable delay. (If the visitor has turned off Javascript,
meta redirection kicks in, or he can use an explicit link to
home.html-- and main.php will set up his session profile with default
values).

But I am worried about whether I'll run into server performance issues
with higher traffic. I'm new to PHP-- gradually working my way through
Welling & Thomson's book with frequent delvings into Gilmore's book
(and heavy use of www.php.net/manual/). I've yet to see any discussion
on the practical limits of sessions. So my more or less specific
questions are:

1. What is the practical size limit for the session array? What
behaviors will I see if this limit is exceeded?
If $_SESSION for a single session is more than a few megabytes,
you'll increase the size of the httpd processes a lot and potentially
have more swapping/paging. Also, you'd better have plenty of disk
space to store the session files. And saving and restoring big
session files every hit is a lot of disk I/O.
2. Is there a practical limit on the number of simultaneous
sessions a simple server can handle? Would exceeding this
generate a "too many users" message or something?
UNIX doesn't work real well with directories with large numbers
of files in them. I'd try to keep it well under 100,000 session
files. However, you can easily write a session handler that
stuffs sessions in a database table rather than in files. This
has advantages that the sessions can be accessed from multiple
round-robin servers serving the same content (for when you run
low on CPU power). That can probably handle a few hundred million
simultaneous sessions (but probably not the associated hit rate
unless you've got some really powerful hardware).
3. How does PHP/Apache handle abandoned sessions? I'm assuming
that after an interval of no activity, a session is deleted?


There are some parameters in PHP for probabalistic garbage collection
of stale sessions. If I wanted sessions to expire at a particular
time, I'd code my own (with the sessions in the database, it might
be occasionally running something like "delete from sessions where
subdate(now(), INTERVAL 2 DAY) >= last_hit_stamp" ).

Gordon L. Burditt
Aug 1 '05 #3
Your reply has been very helpful, especially the links to the garbage
collection parameter documentation.

Thanks again.
ZeldorBlat wrote:

<snip>
No limit really -- other than that imposed by whatever mechanism you're
using to store the session data. PHP's default session handler uses
files
<snip>
Also bear in mind that PHP allows you to redefine the session handler.
In other words, if you don't like PHP's default of storing session data
in files, you could make it use a database


Aug 1 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6211
by: Meghna | last post by:
Hi, I was wondering if some one would be able to help me with this. I am trying to share a session across two servers and I seem to be experiencing some problems. I was wondering if anybody has already tried something like this before and hence be able to provide some guidance in this regard. Any suggestions, pointers or redirections to...
6
6453
by: Richard Bird CCNP, CCDP, MCSE, etc. | last post by:
I need some help adding multithreading to an existing python script. The script was developed to telnet and make changes on a list of cisco routers. I figure that by adding multithreading, I'd be able to telnet to several routers concurrently and speed up the process of making changes. Is this feasible using python with its standard telnet...
1
1656
by: Dwayne Epps | last post by:
I'm somewhat new to developing in ASP. I've some some fairly basic stuff with it. I've just created a simple form that writes information to an Access database using ASP. Everything works fine. My question is, would there be any reason to use the session object other than for tracking purposes. Specifically, does a session have any...
9
1828
by: BLiTZWiNG | last post by:
I'm working on a huge scale project, and I've stumbled onto something that appeared to be just random buggy code before we started larger scale testing. Everytime there is an exception in my code, the session is terminated. I don't understand why this is. I can't find any reference to it in the documentation, nor in my google searches so...
3
1225
by: Amil Hanish | last post by:
I have a localized language website. When I make a simple text change to a language, all user sessions are abandoned because the resource file is recompiled. Any way to avoid this and allow new changes without sessions being killed? Amil
0
1485
by: TonyJ | last post by:
Hello! We have a pc running a form application. If I push some buttons in this application I want to send some commands to a scale which is connected to a specific IP address. When I sent a command I also receive an answer from the scale. I want to communicate with the scale using TCP or UDP. The commands that can be sent to the scale are...
2
3267
by: FastCGI | last post by:
I must admit, I am somewhat ignorant when it comes to understanding FastCGI at this point, but all I do know is that it is the only way to implement dynamic web pages using C++ that compete on the scale of scritping languages like PHP. There seem to be no step-by-step learning materials for FastCGI on the web. But let's place this matter...
3
28216
Atli
by: Atli | last post by:
Introduction: Sessions are one of the simplest and more powerful tools in a web developers arsenal. This tool is invaluable in dynamic web page development and it is one of those things every developer needs to know how to use. This article explains the basics of PHP Sessions. Assumptions: Basic PHP knowledge is required (variables, arrays...
0
1652
by: sql_server_user | last post by:
We're seeing something very strange on our SQL Server 2005 9.0.2047 DB on Windows Server 2003 x64 Standard: 1. Most open connections to the database are being spontaneously terminated by the server. The application log always has this error message in it: A user request from the session with SPID 56 generated a fatal exception. SQL...
0
7900
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8204
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5382
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1167
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.