Symfony2 parallel processing

I came across an interesting problem. I am using Symfony2. A simplified task is as follows. There are two actions, each of which has a path in routing.yml. The first action does the following:

return new \Symfony\Component\HttpFoundation\Response("first"); 

The second action does the following:

 $start = time(); while(time()-$start < 25); return new \Symfony\Component\HttpFoundation\Response("second"); 

The second action starts the loop for 25 seconds and then returns.

I call the second action: domain.com/second (of course, it takes time to download), meanwhile I open another browser window and type: domain.com/first. This should give me the result in the blink of an eye, however, even the first action waits for the second to finish, and they will give me the result at the same moment. This happens both in development mode and in production. I assume that the two processes should work independently. If instead of the first action I call a pure PHP script (and not Symfony), it immediately returns without waiting. In addition, if I run the first and second actions in different browsers, I do not need to wait for the first download.

What could cause the problem? The problem outlined above has been simplified to understand, however, if this had been resolved, my original, more complex task also worked.

Thanks for the help: David

+4
source share
1 answer

By default ( $_SESSION ) PHP sessions are stored in files. When the connection is made and session_start is called, the user session file is opened and locked.

Thus, now other connections of the same user / session can be processed until the session is unlocked.

This may be the (not certain) case that you have encountered.

See http://00f.net/2011/01/19/thoughts-on-php-sessions/ and http://konrness.com/php5/how-to-prevent-blocking-php-requests/ for more details. run through

+3
source

Source: https://habr.com/ru/post/1387140/


All Articles