Problems with Ajax, PHP and Sessions

I have a PHP application that uses Zend Framework, jQuery ajax and Zend_Session. This application has been working for about 7 months and works as it should. When the application is initialized after the user logs in, about 10 ajax requests are launched to load the corresponding data onto a panel type page. After the requests are completed, ajax requests are mostly initiated by the user from now on. When the application worked correctly, we did not have a really balanced load, we had 3 application servers that process requests, but each of them stores PHP session data locally. We recently changed this so that each application server is connected to a central NFS file where PHP session data is stored. That is, when the application broke.

Now that the page is initializing, I see pending ajax requests, but half the timeout. If I wait long enough (about 3-10 minutes), then all clicks initiated by the user will respond quickly. We verified that the problem was caused by our change in session processing.

Does anyone have an explanation of what might happen, how do I troubleshoot and / or resolve?

I really appreciate any help you can give. I pull my hair out because of this.

+3
source share
3 answers

For me, a quick and easy solution is to store sessions in the database, right? :) http://framework.zend.com/manual/en/zend.session.savehandler.dbtable.html

+4
source

. , . , PHP, ( , Zend_Session ), - flock() .

HTTP-? , , , 1 , NFS .

AJAX , PHP cookie NFS. , .

. , PHP.

, " ", , , . , , .

- . .

+2

.

  • NFS noac, ( ?).
  • NFS
  • The file is locked (called session_write_close()?) Or is not written to the file, but only in the server’s local memory
  • Known issues when using frame sets (check php session documentation)
  • There may also be problems when changing domains (a.domain.com, b.domain.com)
+2
source

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


All Articles