Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda