News Feed
Sections




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

Paul Reinheimer:
PHP and Async requests with file based sessions
July 24, 2013 @ 09:52:43

Paul Reinheimer had a problem - when he was making asynchronous requests back to his server from his frontend (Ajax) there was a slowness he noticed when more than one connection was fired off. In this new post to his site he traces through how he found the answer and what he did to fix it.

Digging a little deeper into the queries being executed, I was expecting return times in the order of 200ms, not the several seconds I was seeing. Installing XHGui only furthered my confusion: session_start() was the culprit with incredibly high run times.

He thought first about the number of session files (stored locally) being too large and causing issues, but that turned out to be a false lead. Instead, the issue was something PHP does by default...and does correctly. When PHP executes, it locks the session file, preventing another process from writing to it. This caused the delay he saw until it was unlocked. His solution? Use session_write_close immediately after writing information to unlock the session for further use.

0 comments voice your opinion now!
asynchronous session lock delay filebased request

Link: http://blog.preinheimer.com/index.php?/archives/416-PHP-and-Async-requests-with-file-based-sessions.html

blog comments powered by Disqus

Similar Posts

Mike Naberezny's Blog: Request/Response or Bust

Mike Naberezny's Blog: Request/Response or Bust

Zend Developer Zone: The ZendCon Sessions Episode 28: PHP 5.3 == Awesome!

Brandon Savage's Blog: Peer Review: You Have Not Because You Ask Not (Requests & Responses)

Paul Reinheimer: PHP and Async requests with file based sessions


Community Events





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


interview developer conference list api community bugfix deployment zendserver podcast tips introduction release series library symfony laravel language framework voicesoftheelephpant

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