Apache2和PHP会话 - 它会导致随机减速吗?

I have a application consisting of HTML (AngularJS) client and PHP backend. All communication between client and server is done using XMLHTTPRequests (of course except of loading first HTML file and static resources - JS/CSS...). Server exposes some API endpoints and client makes request to these URL. Once server receives request, it checks $_SESSION to check if user is logged in.

My question is, is it possible that reading (not writing to) from $_SESSION upon almost each request could cause major hangs in responses? For instance, the application works for several requests and then random request is sent and response is received after minutes (15 is record so far). It also seems that the request is processed that late (according to dummy error_log test), so the slowdown is not caused by operations in PHP my code.

Maybe it is a stupid question, but I've already doubled apache's ServerLimit (1000) but no luck. I also have another PHP application on this server which works fine, the only difference I could think of is the working application is barely checking $_SESSION in combination of XMLHTTPRequests.

PHP version: 5.3.3

I could not find a specific reason for your problem but there if you are using php 5.1.x it loads all session data in to memory at session_start() . As a result of this file access in the entire server will be delayed .

If your server php version is not 5.1 and if it is latest 5.4 or .5 then , the possible problem would come due to creation of large number of session temp files .

This some times causes problems with filesystem limits in operating system . so you need to set the session time out to less period .

Also while reading there will be much load on the operating system .

This can be achieved by using config parameter session.gc_maxlifetime

PHP runs garbage collection on expired sessions after the current session is loaded and by using session.gc_probability and session.gc_divisor it calculates the probability that garbage collection will run.

So set session maxlife time to max 1 and see the performance .

Because of this reason most of the web applications provide an option called remember me.

And those applications usually replaces session_start and enforces a timeout if user is idle for a particular span of time .

Hope this helps

References : -

Session time out best practices

Session Clustering White paper