I use the uwsgi to start my flask server, which has 15 workers, and I want to get the call times for each api, and return the result like:
{
"api/students": 10,
"api/teachers": 20,
...
}
I add the before_request handle for app:
@app.before_request
def before_request_handler():
# here to do statistics
# count += 1
And I write an api to get the count value. However, I found that each time the values was not increment, because there're multi workers, each time I just got one worker's call times
So, my question is how to collect all the request call times from all the workers in Flask?