I am developing a web app and I need to have the main script running in the background ( as a deamon ) and handle many requests from the same user.
My application performs many SQL queries and generates huge arrays for its internal workings, and this is done for every single request from the user. My goal is to keep the application running in the background and let it respond to the user requests, thus improving performance and easing on the server resources; once the user logs off I can then, kill the deamon.
I thought of using pcntl_fork() but it only works for CLI ( if my understanding is correct )
Any help will be highly appreciated! Thank you.
preguntado el 27 de agosto de 11 a las 14:08
You could try storing the huge arrays in session variable(s) or memcache between accesses. It depends on how "huge" they are.
Another though I had was to run a CLI php "Daemon" that listens to a specific port, the "regular"(CGI?) php scripts would communicate through port I/O. Seems way complicated and therefor fragile though.