Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx PHP-FPM and curl hangs subsequent browser to server requests

Tags:

php

curl

nginx

I have php-fpm & nginx stack installed on my server.

I'm running a JS app which fires an AJAX request that internally connects to a third party service using curl. This service takes a long time to respond say approximately 150s.

Now, When i connect to the same page on another browser tab, it doesn't even return the javascript code on the page which triggers the ajax requests. Basically all subsequent requests keep loading until either the curl returns response or it timeouts.

Here, i have proxy_read_timeout set to 300 seconds.

I want to know why nginx is holding the resource and not serving other clients.

like image 435
Nitesh morajkar Avatar asked Oct 27 '25 19:10

Nitesh morajkar


1 Answers

The issue was due to the PHP session lock. When i used to make a certain request, PHP used to lock the session file and would release only after the request was completed.

To avoid this, you may use session_write_close(). In my case, I implemented redis session.

Problem solved!!!

like image 164
Nitesh morajkar Avatar answered Oct 29 '25 09:10

Nitesh morajkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!