Skip to content
Advertisement

Django: Horizontal scaling with a single database

I have a single django instance about to hit its limits in terms of throughput. Id like to make a second instance and start scaling horizontally.

I understand when dealing with database read replicas there is some minimal django configuration necessary, but in the instance of only using a single database: is there anything I need to do, or anything I should be careful of when adding a second instance?

For the record, I use render.com (it’s similar to heroku) and their scaling solution just gives us a slider and will automatically move an instance up or down. Is there any sort of configuration I need to do with django + gunicorn + uvicorn? It will automatically sit behind their load balancer as well.

For reference my stack is:

  • Django + DRF
  • Postgres
  • Redis for cache and broker
  • Django-q for async
  • Cloudflare

Advertisement

Answer

You can enable autoscaling on Render and it will automatically scale your instances up (and down) based on your application’s average CPU and/or memory utilization across all instances. You do not need to change your Django app.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement