DEV Community

Bhavin Patel
Bhavin Patel

Posted on Edited on

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

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. I use Redis for short-lived data, and I clean it up on a schedule instead of letting it grow. With only 2GB of RAM, Redis can quietly eat memory that the rest of the stack needs, so I treat it like a cache that must stay small, not a place to dump things.

I’m curious what other people with tiny servers did first. Caching, cleanup, or something else?

Top comments (0)