I starting using http://reactphp.org/ for handle HTTP request.
I run multiple react workers that run on different ports and then use Nginx as load balancing to handle requests. Like this
upstream backend {
server 127.0.0.1:13300;
server 127.0.0.1:13301;
.....
}
All works well as expected.
The question is how to get a statistic of reactphp process status. How many processes currently on idle state (waiting for new request), how many process is work under request, etc.
Is there existing workaround?
Or idea how to handle process statistic by hand.
Example - locking write to some cache process status. When is start request process - increase number of handled processes, when finish request - increase number of idle processes.
The last time I had a set of worker threads I set up some tables in a MySQL DB.
workers was where each thread registered a row (giving it an ID). The thread would lock it's row and maintain the status column.
There was also an instructions stack. If the worker saw it's ID and the text "exit" it would close up and exit. Last thing would be to delete it's row. Setting status to exited also would have worked.
I also made a status report and admin page where I could issue commands and set up tasks for my worker threads.
This would then allow you to see what each thread was doing and get a count of idle threads.
Idle threads:
SELECT count(id) AS threads WHERE status='idle';
Thread status count:
SELECT status, count(id) AS threads GROUP BY status;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With