G
G
GT_Volk2014-07-16 07:40:01
PHP
GT_Volk, 2014-07-16 07:40:01

Nginx + PHP-FPM + Yii = why is there a 504 error?

Given:
There is a web server with Nginx, php-fpm and MySQL installed, on it several XML parsers process tens of thousands of files and put them into the database, the average processing time is 3-5 minutes, it's all written in Yii .
The essence of the problem is this:
If you run any parser, then during these 5 minutes while it is working on any calls to the rest of the resource pages, the web server issues 504 Gateway Time-out
At the same time, if on the same server I run the old version of parsers written in pure php, then 504 no errors occur and I manage to run several of them in parallel and open other pages of the resource without difficulty.
Errors in the logs only for Nginx:
2014/07/16 14:25:27 [error] 11665#0: *9 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 37.#.#.#, server: ## ###.ru, request: "GET /index.php?r=loading/parsenotifications HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "#####.ru" , referrer: " http://#####.ru/index.php?r=loading/index "
2014/07/16 14:25:29 [error] 11665#0: *12 upstream timed out (110 : Connection timed out) while reading response header from upstream, client: 37.#.#.#, server: #####.ru, request: "GET /index.php?r=loading/parsecontracts HTTP/1.1" , upstream: "fastcgi://127.0.0.1:9000", host: "#####.ru", referrer: " http://#####.ru/index.php?r=loading/ index "

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexander Melekhovets, 2014-07-16
@GT_Volk

There is a suspicion that file sessions are being locked. Try not to use them, or use sessions in the database if you need them (just be careful with race conditions). Here is more details. Well, yes, it would be even better to run the parsers through the console, and not through the web server.

D
Dmitry Entelis, 2014-07-16
@DmitriyEntelis

There could be a lot here.
1) mysql overload by load, by the number of connections (most likely)
2) parsers if there are a lot of them at once and you start them not from the console, choose nginx workers

S
Sergey, 2014-07-16
Protko @Fesor

take the parser to the CLI daemon and just tie the whole thing together via RabbitMQ for example.

_
_ _, 2014-07-16
@AMar4enko

How are parsers launched?

P
Puma Thailand, 2014-07-16
@opium

Go to the logs and just look
at the edge enable slolog in php-fpm

I
Igor, 2014-07-16
@merryjane

Do you happen to have an important plate in the database that is not locked when parsers work?
Maybe the parser is locking it, and all requests to the site are waiting for the blocking to subside?
Have you monitored what happens to queries in the database when the parser is running?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question