Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

93
Vistas
Apache PHP trigger only one process with multithreading

I have a rest service in Apache - PHP that triggers a database query and data processing. REST -> DB_QUERY.
Problems comes when REST incomming are too much and each one triggers a new thread of DB_QUERY.

REST -> DB_QUERY -- thread 1  
REST -> DB_QUERY -- thread 2  
REST -> DB_QUERY -- thread 3  
REST -> DB_QUERY -- thread ...

The solution I need is have only one DB_QUERY in process. I could do it by two ways:
1 - Break the trigger, and set a bucle in the DB_QUERY process (while true).

REST -- thread 1  
REST -- thread 2  
REST -- thread 3  
REST -- thread ...

DB_QUERY(while true)

2 - Maintain the trigger, but have only one DB_QUERY.

REST -- thread 1 |  
REST -- thread 2 |  
REST -- thread 3 |  
REST -- thread ...|___> DB_QUERY

For the first solution, I don't know how to launch a the DB_QUERY(while true) in a clean way. I have done it with systemctl daemon, but I would prefer to trigger it from php code.

For the second one I have tried singleton patter, but it doesn't work because DB_QUERY is triggered from differents threads.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda