News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Richard Thomas' Blog:
Improving PHP Sessions
July 23, 2007 @ 09:35:00

Richard Thomas has shared some suggestions on improving the performance and use of PHP's built-in sessions in your site:

If your developing a new website and want to ensure its scalable sessions can be a sticking point. [...] There are a couple problems you may run into with this approach and most database driven examples you may use to base your session code off.

These problems can pretty much be summarized into a single sentence: Every single page load your database is going to be hit at least 2 times, first to read the session data and then session to rewrite all that data.

He includes three suggestions:

  • Hash your data when pulled from the DB, if your data hasn't changed don't bother updating
  • Figure out what your margin of error is for how long a session has been inactive (don't update if you don't need to)
  • Use memcache in conjunction with your database, Check memcache first if its there, if it is use memcache, if its not pull from DB and shove into memcache when you DO update your data update memcache at the same time.
0 comments voice your opinion now!
session improve database problem suggestion memcache session improve database problem suggestion memcache


blog comments powered by Disqus

Similar Posts

Jan Lehnardt's Blog: CouchDb Views with PHP

ProDevTips.com: Doctrine for dummies

Greg Beaver\'s Blog: Protecting a MySQL user/password in a PHP script

Padraic Brady's Blog: ZF Blog Tutorial Addendum #1: Base URL, Magic Quotes, Database Schema & UTF-8

dynaTrace Blog: Top 10 Performance Problems taken from Zappos, Monster, Thomson and Co


Community Events

Don't see your event here?
Let us know!


release symfony2 interview example opinion voicesoftheelephpant library series xdebug laravel podcast introduction version extension community php7 conference api performance framework

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework