1

we have the system like the following:

enter image description here

  • Client: A regular client
  • P Server: An apache server which basically runs like a proxy (forwards queries to M Server)
  • M Server: Main server. All the work is done here.

and

Query Q1 is not equal to query Q1' because P Server adds some more variables (like server time, client IP) Q1 before sending it to M Server.

Response R1 doesn't change at all. It is forwarded to client without changing.

Same applies for Q2.

The problem is, if ajax requests with Q1 and Q2 are sent at the same time, Q2 waits in P Server for R1 to finish.

So this is basically a PHP/Apache problem. But, I don't know how to dig this problem. Is it multiple php script problem or multiple request problem? I tried session_write_close() but that didn't change anything.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Cihad Turhan
  • 2,749
  • 6
  • 28
  • 45
  • How are you running PHP (HTTPD or PHP-FPM)? How many processes are you spawning? Short answer is, Q1 should not wait for Q2 unless they're waiting on same resource. – Manu Manjunath Dec 26 '13 at 10:05
  • it's httpd. What do you mean by same resource? Q1 and Q2 are sent to same file: `data_manager.php` and Q1` and Q2` are sent to same java servlet. – Cihad Turhan Dec 26 '13 at 10:08

1 Answers1

0

PHP's default session handler is file based and uses exclusive locks. Which means the request related to the same session will be serialised. Actually this is a positive thing, it can avoid lots of strange parallel programming issues, race conditions/etc.

You can change the session handler to something less paranoid if you prefer. Or you can write an own file based one, without exclusive file locking to avoid this behaviour. Anyway be careful when accessing critical resources... (semaphores, locking, etc can be your friends.)

There are a few related comments here:

You can verify this behaviour with inotifywatch on your session's directory. (Formerly inotify things could cause kernel panics and other strange behaviours... test it only on a test server...)

Community
  • 1
  • 1
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56