M
M
Maxim Barulin2016-08-11 13:35:05
JavaScript
Maxim Barulin, 2016-08-11 13:35:05

How to send multiple ajax requests to symfony at the same time?

Good day!

In general, there is a simple task. When generating a document, show the progress of its formation. For implementation, I made saving the current status in a radish and checking it from the client.

That is, an ajax request is sent first to generate a document, and then, after an interval, the storage is polled for readiness. But here an unexpected problem arose. After sending a request for a document, all the others join the queue and wait until the first one is completed ...

37e5898e3489_001.png

Maybe you need to correct something in the config somewhere?

PS: picking in the log confirmed my idea, symphony queues all responses and waits for the first request to complete, and then returns the rest, i.e. kernel.response is called for status check requests only after the main request is completed...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dizzy7, 2016-08-11
@Slavenin999

Symphony is not the problem, it's a standard php session mechanism - they are blocked. While a session is open in one thread, another thread cannot open it and waits for completion. You need to either implement your own session storage without locks, or close the session manually if you don't need it.

E
Evgeny Svirsky, 2016-08-11
@e_svirsky

У вас документ формируется синхронно и вы хотите еще статус показывать, я правильно понял?
Такие вещи лучше на бэкграунд повесить. Тогда не будет проблем с сессиями. Таска выполняется в бэкграунде, и меняет редис, а вы с редиса на фронтенде показываете статус. Так будет красиво и правильно. И если вдруг вырастет время формирования документа - вам пофигу, потому что команда будет выполняться в бэкграунде и вы не вылетите по http request timeout.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question