How to effectively run Django with multi-processor cores

I am developing a web application and have problems with Django not improving when I increase the number of processor cores.
(in fact, 1 core has the highest performance and 2,4,8 kernels are not very different in their characteristics)
What my application does is just load static files (HTML, CSS, JS) and some data from the database . I use Apache as a web server and mod_wsgi.

Is this the usual behavior of Django?
If so, how can I improve performance with multiple cores?
(I want to increase the number of cores, because the processor load reaches about 90% with only one core)

▼ ab -n 200 -c 200 for 1CPU core and 1 GB of memory enter image description here

▼ ab -n 200 -c 200 for 2CPU cores and 1 GB of memory enter image description here

▼ vmstat 1 for 1CPU core and 1 GB of memory enter image description here

▼ vmstat 1 for 2CPU cores and 1 GB of memory enter image description here

+4
source share
1 answer

I found that I just needed to make some changes to the Apache configuration file. I changed

WSGIDaemonProcess localhost

to

WSGIDaemonProcess localhost processes=2 threads=25

then the response time decreased from 7 seconds to 2 seconds.
after that I experimented with a different number of processor cores, and when I installed the same number of processes as the number of processor cores, the performance got better.

+5
source

Source: https://habr.com/ru/post/1618352/


All Articles