Slow Performance Issue with Django Admin in Production Environment
francoleyes
PROOP

2 years ago

Hello, I need help because the Django admin is very slow when accessing an app. With the same database of less than 8000 records, it takes 8.60 seconds on the server and only 90 ms locally. I tried adding workers on the server, but it doesn't improve. I also tested it from very close to the server (from Miami), so I don't think it's latency. I have the Pro plan.

0 Replies

francoleyes
PROOP

2 years ago

60937526-0f38-463c-a9c3-319f6b9e53dd


brody
EMPLOYEE

2 years ago

where is your database hosted?


francoleyes
PROOP

2 years ago

I have tested from US West (Oregon, USA) and also from US East (Virginia, USA).


brody
EMPLOYEE

2 years ago

okay so the database is on railway?


francoleyes
PROOP

2 years ago

Yes, it is in railway


brody
EMPLOYEE

2 years ago

is your database and django app both in us east?


francoleyes
PROOP

2 years ago

Yes, both the database and Django app are hosted in the US East


brody
EMPLOYEE

2 years ago

is your django app connecting to the database via the private network?


francoleyes
PROOP

2 years ago

Yes, the Django app is connecting to the database via the private network


brody
EMPLOYEE

2 years ago

whats your middleware stack?


francoleyes
PROOP

2 years ago

My middleware stack configuration in the Django settings file is as follows:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
"whitenoise.middleware.WhiteNoiseMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware',
"corsheaders.middleware.CorsMiddleware",
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'auditlog.middleware.AuditlogMiddleware',
]


brody
EMPLOYEE

2 years ago

looks fine, what is debug set to when on railway?


francoleyes
PROOP

2 years ago

DEBUG is set to False


brody
EMPLOYEE

2 years ago

whats your start command when you run locally, and your start command that railway runs?


francoleyes
PROOP

2 years ago

local:
python manage.py runserver

railway:
I've tried many production setups, but currently, this is what I'm using "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn -k gevent --workers=8 gym.wsgi"


brody
EMPLOYEE

2 years ago

already using gevent, that was what i was going to ask you to try next


francoleyes
PROOP

2 years ago

any idea what might be going on?


brody
EMPLOYEE

2 years ago

at this moment no, but i do know that this would not be a platform issue


brody
EMPLOYEE

2 years ago

there is some kind of misconfiguration somewhere


francoleyes
PROOP

2 years ago

is there any way to debug or trace where it's coming from?


brody
EMPLOYEE

2 years ago

you would need to implement some kind of highly verbose logging for that


brody
EMPLOYEE

2 years ago

have you tried other worker classes?


francoleyes
PROOP

2 years ago

yes, I've experimented with different worker classes, but the performance issue persists


brody
EMPLOYEE

2 years ago

im stumped, that just leaves process of elimination, remove bits of code until the issue goes away, not the most elegant solution, but it can work


francoleyes
PROOP

2 years ago

thank you very much for the suggestion and help, I will keep trying


brody
EMPLOYEE

2 years ago

please update me if you find anyting!


Loading...