Django, DRF, nginx, Jmeter: Sample Time becomes large even though there is no load on the CPU, etc
I am using Jmeter
to load test the DRF
, and even though the CPU and memory are not at 100%, the throughput and response time is slow.
The Django
+ nginx
and Postgres
servers are separated, and both have the following specs
4CPU, 4GB memory.
nginx is using docker's https-portal
as shown below.
version: "3"
services:
https-portal:
image: steveltn/https-portal:1
ports:
- "80:80"
- "443:443"
environment:
DOMAINS: "my.domain.com -> http://backend:8000"
STAGE: "production"
volumes:
- https-portal-data:/var/lib/https-portal
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- ./static:/static
depends_on:
- backend
restart: always
backend:
build: .
command: uwsgi --http :8000 --module myapp.wsgi --processes 4
volumes:
- .:/usr/src/app
- ./static:/usr/src/app/static
expose:
- 8000
env_file:
- .env
- .env.prod
restart: always
volumes:
https-portal-data:
Looking at the django logs, there doesn't seem to be anything wrong with django, what do you think could be causing this?
generated 8302 bytes in 29 msecs (HTTP/1.0 200) 7 headers in 208 bytes (1 switches on core 0)
Setting up Jmeter:
After 5 minutes of continuous loading.
If there is any other information you need, please let me know.
- Check your application performance via profiler tool
- Depending on the outcome you may also want to check Postgresql query logs and stats
- Don't run JMeter in GUI mode, it might be the case you're getting false negative results because JMeter cannot send requests fast enough and/or got stuck due to garbage collection
- Follow other JMeter Best Practices and make sure that JMeter doesn't lack CPU, RAM, etc.