Deamon de la aplicación web PHP maneja múltiples solicitudes seguidas del mismo usuario

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

So each web request will wait for information from the daemon before a response is generated? Or are the SQL queries performed asynchronously? -

NanoWeb, phpstack, Nanoserv, and others. The one I was originally looking for I didn't found thought. It follows the principle to have the HTTP deamon in PHP so to persistent all objects in memory. Much faster than with APC and similar PHP caches. Works with everything that has a good HTTP abstraction like symfony2 and mind the singletons if you have any. -

1 Respuestas

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.

Respondido 27 ago 11, 19:08

storing data in session is one solution but it adds the burden of thinking it in advance and figuring what to store and what can be reworked next session, while my idea is to keep the state of application as is between sessions, just like in a desktop application. - Younes CHROQI

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.