2

I am a Django developer, i have recently build a messaging app using Channels 2 and Redis. For each conversation i am creating a group and adding all the participant to the group every time when one reconnect.

I am also using workers for channels with Daphne on production

The problem is that after 10 groups for a user , the messaging get super slow with daphne using nearly 100 % CPU usage, causing all site slow.

I have attached the screehshots for the CPU usage.

Data output screenshot

I would be really thankful to you could advice to reduce CPU usage

Regards, Saadullah Naeem

SandPiper
  • 2,816
  • 5
  • 30
  • 52
  • Please add the extra information into the question as an edit rather than posting it as a comment. – ChrisF Jul 18 '18 at 11:30

2 Answers2

0

In my case, some error in tasks.py(celery) makes daphne cpu 100% usage.

The error log can be checked in asgi log file.

creaddiscans
  • 56
  • 1
  • 1
0

I have same problem. I see a best performance with Uvicorn and Gunicorn.

gunicorn -b 0.0.0.0 -p 8000 mysite.asgi:application -k uvicorn.workers.UvicornWorker --workers 4

In this case I expecify 4 worker and It's use 4 core of server, and distributes the use of CPU.

enter image description here

fdelcampo
  • 16
  • 2