Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!