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



85.4k

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



2.7k

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

Thanks



85.4k

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.



2.7k

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



85.4k

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.

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



2.7k

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