How to profile django channels?

My technology stack is Redis as a backend for channels, Postgresql as a database, Daphne as an ASGI server, Nginx in front of the whole application. Everything is deployed using Docker Swarm, only with Redis and Database. I have about 20 virtual hosts, with 20 interface servers, 40 working HTTP and 20 working. Load balancing is performed using the Inject overlay Docker network.

The problem is that sometimes very strange things related to performance happen. Most requests are processed in less than 400 ms, but sometimes a request can take up to 2-3 seconds, even with a very small load. Professionals with Django Debug Toolbar or middleware-based profilers show nothing (time 0.01 or less)

My question is: is there a good method for profiling the entire request path with django channels? I would like how much time each phase takes, i.e. When the request was processed by Daphne, when the worker began to process, when he finished, when the interface server sent a response to the client. I currently have no idea how to solve this.

+8
python profiling django django-channels daphne
source share
1 answer

Why not use a monitoring tool like Kibana or New Relic and keep track of why and what takes so long for a small response to the payload. He can tell you the time spent on Python, PostgreSQL and Memcache (Redis).

0
source share

All Articles