Reactphp process status statistic (idle, worked, etc)
Asked Answered
C

1

13

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.

Clareta answered 5/5, 2015 at 7:47 Comment(4)
Where are the process statistics exposed? In react php specifically. What uri/path?Rumor
Idea for getting this statistic for me is understand what is loading i my server. Mostly of all there should be special handler that can show me this statistic. Like number of idle worker, number of processing workers.Clareta
Where are the statistics? I get your idea, but I don't know react php and how it exposes its statistics? Or nginx has a status stub, see nginx.org/en/docs/http/ngx_http_stub_status_module.htmlRumor
Thats that main question, i can't find any way to export statistic from reactphp.Clareta
O
3

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;
Ophthalmic answered 14/5, 2015 at 12:3 Comment(1)
Thank you for sharing this idea. This is something that I call "by hand". If I can't find any build-in way I will use something like this.Clareta

© 2022 - 2024 — McMap. All rights reserved.