We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Close connection and continue process

Hi,

I'm working on a rest api and try to close the connection and continue the process.

Any idea how I can send \Phalcon\Http\Response () and keep the process alive ?

Thanks



98.9k

Is the process serving requests on CLI or using a standard web server?



3.9k

Currently it's a standard web server, but if needed I can create a CLI. Any suggestions ?

Thanks



98.9k

Well, I think one does not keep a web server request alive because the PHP processes are reused by incoming requests in a standard web server, if you can deploy your own CLI server (note that this does not scale properly and have other flaws) you can simulate sending the HTTP request (headers/body) while keeping the process alive.



3.9k

Well, I'm using shell exec to avoid that issue but Im looking for something a little bit more "clean". Can the CLI server share some classes from my web server app (phalcon) or share memory with it?.

Basically, it's a rest api. I have to send the response asap then do some heavy processing. I know I have different options to accomplish that but I wanted to see what the phalcon community is going to suggest.

Thanks



98.9k

I think what you need is a message/queue server, when you process the API response and send a message to the worker, then via cron or a process in background you get the messages from the queue and process the heavy tasks.

https://fr.slideshare.net/IanBarber/zeromq-is-the-answer-php-tek-11-version https://www.google.com/search?q=zeromq+php



3.9k

Great.

Exactly, I had a home made system but as soon as you have 1000 concurrent users, it became a nightmare

I started implementing Gearman but then I thought maybe it's overkill. I'll take a look at this one.

Thank you very much