|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Dear PHP List,
PHP 5, Apache2, MySQL 5, running on Ubuntu, viewing & deving with FireFox and Konqueror (Linux). I am building a site with multiple tools and want to pass variables throughout them all. Before, I was passing variables using <hidden> HTML Form tags, but the site has grown too large for this tactic, so I went to using $_SESSION. However, when I started using $_SESSION, my site loads 3-5 times slower then before. A page that queried MySQL and built itself in 3-5 seconds was now taking 15-20. While more has changed then just $_SESSION, it is really the only significant difference. Is $_SESSION slowing down my site? Is there a faster alternative to global variables then using $_SESSION? Are using regular faster? Any is appreciated. Thanks, Scott -- Scott Campbell "If you do what you've always done, you'll get what you've always gotten." "Courage is resistance to fear .. not absence of fear." |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Wed, 2008-05-07 at 12:27 -0400, Scott Campbell wrote: > Dear PHP List, > > PHP 5, Apache2, MySQL 5, running on Ubuntu, viewing & deving with > FireFox and Konqueror (Linux). > > I am building a site with multiple tools and want to pass variables > throughout them all. Before, I was passing variables using <hidden> HTML > Form tags, but the site has grown too large for this tactic, so I went to > using $_SESSION. However, when I started using $_SESSION, my site loads 3-5 > times slower then before. A page that queried MySQL and built itself in 3-5 > seconds was now taking 15-20. While more has changed then just $_SESSION, > it is really the only significant difference. > > Is $_SESSION slowing down my site? Is there a faster alternative to > global variables then using $_SESSION? Are using regular faster? > > Any is appreciated. How are your sessions implemented? Are you using the stock PHP session functionality or did you cook your own solution? I can't see the stock PHP solution adding anything more than a split second to your page time. The exception being when it performs cleanup. Cleanup should be relegated to a cron job. Have you added anything new to the database? new query perhaps on a large table that doesn't make use of indexes? Small changes can have a bigger impact than large changes depending on what exactly changed. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
At 12:34 PM -0400 5/7/08, Robert Cummings wrote:
> >The exception being when it performs cleanup. Cleanup should be >relegated to a cron job. Rob: What clean-up? Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: > At 12:34 PM -0400 5/7/08, Robert Cummings wrote: > > > >The exception being when it performs cleanup. Cleanup should be > >relegated to a cron job. > > Rob: > > What clean-up? All the inactive session files... inactive and garbage collection time is denoted by the following php.ini settings: session.gc_probability = 1 ; percentual probability that the ; 'garbage collection' process is ; started ; on every session initialization session.gc_maxlifetime = 1440 ; after this number of seconds, ; stored data will be seen as ; 'garbage' and cleaned up by the ; gc process Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Wed, May 7, 2008 at 2:22 PM, Robert Cummings <robert@interjinn.com>
wrote: > > On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: > > At 12:34 PM -0400 5/7/08, Robert Cummings wrote: > > > > > >The exception being when it performs cleanup. Cleanup should be > > >relegated to a cron job. > > > > Rob: > > > > What clean-up? > > All the inactive session files... inactive and garbage collection time > is denoted by the following php.ini settings: > > session.gc_probability = 1 ; percentual probability that the > ; 'garbage collection' process is > ; started > ; on every session initialization > session.gc_maxlifetime = 1440 ; after this number of seconds, > ; stored data will be seen as > ; 'garbage' and cleaned up by the > ; gc process so where is the setting, using the stock session handler, to relegate the gc process to a cron job ? -nathan |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
At 4:22 PM -0400 5/7/08, Robert Cummings wrote:
>On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: >> At 12:34 PM -0400 5/7/08, Robert Cummings wrote: >> > >> >The exception being when it performs cleanup. Cleanup should be >> >relegated to a cron job. >> >> Rob: >> >> What clean-up? > >All the inactive session files... inactive and garbage collection time >is denoted by the following php.ini settings: > >session.gc_probability = 1 ; percentual probability that the > ; 'garbage collection' process is > ; started > ; on every session initialization >session.gc_maxlifetime = 1440 ; after this number of seconds, > ; stored data will be seen as > ; 'garbage' and cleaned up by the > ; gc process > >Cheers, >Rob. Oh, Okay. That's an automatic practice taken from the php.ini settings. I was thinking that maybe one was supposed to do something after using sessions. Thanks, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Wed, 2008-05-07 at 14:29 -0600, Nathan Nobbe wrote: > On Wed, May 7, 2008 at 2:22 PM, Robert Cummings <robert@interjinn.com> > wrote: > > On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: > > At 12:34 PM -0400 5/7/08, Robert Cummings wrote: > > > > > >The exception being when it performs cleanup. Cleanup > should be > > >relegated to a cron job. > > > > Rob: > > > > What clean-up? > > > All the inactive session files... inactive and garbage > collection time > is denoted by the following php.ini settings: > > session.gc_probability = 1 ; percentual probability > that the > ; 'garbage collection' > process is > ; started > ; on every session > initialization > session.gc_maxlifetime = 1440 ; after this number of > seconds, > ; stored data will be seen as > ; 'garbage' and cleaned up by > the > ; gc process > > so where is the setting, using the stock session handler, to relegate > the gc process to a cron job ? session.gc_probability = 0 Then do it yourself in a script called by cron. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Wed, May 7, 2008 at 2:35 PM, Robert Cummings <robert@interjinn.com>
wrote: > > On Wed, 2008-05-07 at 14:29 -0600, Nathan Nobbe wrote: > > On Wed, May 7, 2008 at 2:22 PM, Robert Cummings <robert@interjinn.com> > > wrote: > > > > On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: > > > At 12:34 PM -0400 5/7/08, Robert Cummings wrote: > > > > > > > >The exception being when it performs cleanup. Cleanup > > should be > > > >relegated to a cron job. > > > > > > Rob: > > > > > > What clean-up? > > > > > > All the inactive session files... inactive and garbage > > collection time > > is denoted by the following php.ini settings: > > > > session.gc_probability = 1 ; percentual probability > > that the > > ; 'garbage collection' > > process is > > ; started > > ; on every session > > initialization > > session.gc_maxlifetime = 1440 ; after this number of > > seconds, > > ; stored data will be seen as > > ; 'garbage' and cleaned up by > > the > > ; gc process > > > > so where is the setting, using the stock session handler, to relegate > > the gc process to a cron job ? > > session.gc_probability = 0 > but wont it still try to run sometimes since that setting determines whether or not the gc will run *every* time ? i would imagine if it was for *any* time, setting session.gc_probability = 0 would effectively disable the stock gc. Then do it yourself in a script called by cron. it would be nice if you could latch into the one they provide out of the box and just invoke it via cron.. -nathan |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
> On Wed, May 7, 2008 at 2:35 PM, Robert Cummings <robert@interjinn.com>
> wrote: > >> >> On Wed, 2008-05-07 at 14:29 -0600, Nathan Nobbe wrote: >> > On Wed, May 7, 2008 at 2:22 PM, Robert Cummings <robert@interjinn.com> >> > wrote: >> > >> > On Wed, 2008-05-07 at 16:03 -0400, tedd wrote: >> > > At 12:34 PM -0400 5/7/08, Robert Cummings wrote: >> > > > >> > > >The exception being when it performs cleanup. Cleanup >> > should be >> > > >relegated to a cron job. >> > > >> > > Rob: >> > > >> > > What clean-up? >> > >> > >> > All the inactive session files... inactive and garbage >> > collection time >> > is denoted by the following php.ini settings: >> > >> > session.gc_probability = 1 ; percentual probability >> > that the >> > ; 'garbage collection' >> > process is >> > ; started >> > ; on every session >> > initialization >> > session.gc_maxlifetime = 1440 ; after this number of >> > seconds, >> > ; stored data will be seen as >> > ; 'garbage' and cleaned up by >> > the >> > ; gc process >> > >> > so where is the setting, using the stock session handler, to relegate >> > the gc process to a cron job ? >> >> session.gc_probability = 0 >> > > but wont it still try to run sometimes since that setting determines > whether > or not the gc will run *every* time ? i would imagine if it was for *any* > time, setting session.gc_probability = 0 would effectively disable the > stock > gc. > that setting is the chance (in percents) for the stock gc to run at any request. so if it is set to 0, it does not have a chance ![]() of course it will try but it always decides not to run greets, Zoltán Németh > Then do it yourself in a script called by cron. > > > it would be nice if you could latch into the one they provide out of the > box > and just invoke it via cron.. > > -nathan > |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
I can't see PHP sessions slowing down your site by that amount. As
someone said, it should be no more than a split second. If you are having that much of a problem with them, then I would say it is either your implementation, or another determining factor. I would not, personally, stray away from PHP's GC of sessions. I would imagine that any third-party concoction could not be any faster. I would however, check to see how long PHP takes to clean up defunct sessions, and also monitor how many sessions are lying around at any given time. Regards, - Craige |
|
![]() |
| Outils de la discussion | |
|
|