Menu

How I handle ~1M requests a day on 1 vCPU and 2GB RAM (and keep bots out without user accounts)
📰

How I handle ~1M requests a day on 1 vCPU and 2GB RAM (and keep bots out without user accounts)

DEV Community: django·Bhavin Patel·about 6 hours ago
#1mpwDa9c
#devtodjango#devto#dev#django#redis
Reading 0:00
15s threshold

I run a Tempgbox : free temporary email service on one vCPU and 2GB of RAM. Django, PostgreSQL, Redis, Celery. It serves around a 1 million+ requests a day. Still i notice that backend use only 500 Mb ram and 1.5 GB ram free.

Four changes made the biggest difference for such a small server.

Cloudflare in front. I put Cloudflare in front of everything as a proxy. Most requests are for frontend pages, and Cloudflare caches those, so they never reach my server. That alone took a lot of load off it.

DRF to Django Ninja. I migrated the API from Django REST Framework to Django Ninja, which has built-in async support. I’m still learning how much that gives me, but it was the right direction for an API that does a lot of waiting.

Cleaning up guest users. Most of my users are guests, so guest accounts pile up fast. Now I delete a guest user as soon as their token expires. The database stays small, and I stopped paying to store people who were gone anyway.

Redis, with regular cleanup.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.