Six months ago, I posted a project I worked on. You might remember it from:
[My First Django Application, App that tracks profit's and prices on OldSchool Runescape](https://www.reddit.com/r/django/comments/cqcmln/my_first_django_application_app_that_tracks/)
The aforementioned website has grown pretty large with the database now consisting of almost 10 million rows... Due to Heroku's Database tiering system going from $9/mo to $50/mo when you have over 10 million rows, I decided I needed to find a more cost-effective solution to this problem.
The reason in the first place I went with Heroku, was that 1) they gave free student credit. 2) it was being used in the Corey Shafer Django Tutorial I was following, 3) it was intuitive and has a nice UI.
Now however that I am 6 months wiser, require more computational power, and still equally broke, I required a new solution.
I started looking for a Heroku-esque clone. That is when I stumbled upon a Platform as a Service similar to Heroku called [CapRover](https://caprover.com/) that seemed too good to be true.
*Note: I'm not sponsored or anything.*
I did a quick search on [r/Django](/r/Django) for '*CapRover*' but there was no mention of it, that is why I am here today to hopefully help some people because this is too good to not share with others.
From CapRovers own site:
## What's this?
>CapRover is an extremely easy to use app/database deployment & web server manager for your **NodeJS**, **Python**, **PHP**, **ASP.NET**, **Ruby**, **MySQL**, **MongoDB**, **Postgres**, **WordPress** (and etc...) applications!
>It's blazingly fast and very robust as it uses Docker, nginx, LetsEncrypt and NetData under the hood behind its simple-to-use interface.
>✔ **CLI** for automation and scripting ✔ **Web GUI** for ease of access and convenience ✔ **No lock-in!** Remove CapRover and your apps keep working! ✔ **Docker Swarm** under the hood for containerization and clustering ✔ **Nginx** (fully customizable template) under the hood for load-balancing ✔ **Let's Encrypt** under the hood for free SSL (HTTPS)
What you need for CapRover to work is a Linux VPS. You can set up a VPS with CapRover preinstalled at DigitalOcean for just $5/Mo, which has 1GB of RAM, 1 vCPU, 25GB SSD, and 1TB transfer/Mo.
You will also need a domain name so that you can log in to the server through your browser. Once logged in you, can see what apps you have installed (same as Heroku) as well as monitor your system's resources, etc.
If you are a student, you can get all of this for free with [GitHub's Student Pack](https://education.github.com/pack), by the way.
I've been tinkering with CapRover for a couple of days now and have successfully got the following running on it simultaneously. (Granted I did have to upgrade my Linux VPS from 1GB of RAM to 2GB of RAM. I think however I still have enough headroom to probably add 1 more website ontop still.)
* 1 Django site on it
* 1 WordPress site on it
* 2 PostgreSQL databases on it
* 1 Python web scraper running.
Since, I could not find any tutorials online on how to set up a CapRover Linux VPS, and install Django on top of it from scratch I decided to write a [blog post](https://blog.alfred.software/2020/02/12/how-to-create-your-own-heroku-clone-and-setup-django-and-postgres/) about it. In the blog post, I go step by step with screenshots, from not owning a VPS to having a
response from a Django server on your domain, hosted on CapRover.
Granted it's not the most difficult thing in the world, but I thought I might as well compile all the information in a single post to save others time and mistakes.
I might also create a youtube video in the future in which I do what I do in the blog post, which might be clearer for some.
I hope I provided some value.
11 thoughts on “How I reduced my Django Heroku hosting costs by 80%”
Thank you for sharing, this will be valuable for my next project! 🙂
Saving this post.
Pretty interesting – obviously no surprise that moving from Heroku to DO is going to be cheaper. But the whole sysadmin thing isn’t everyone’s cup of tea, and so that’s where CapRover would fit in. Looks cool, might have to try this out on a VM.
Yeah as I was pricing out my current project, I was going to build it in aws lambda, but the free teir at heroku was too easy. As others have mentioned the reduced amount of admin required was key.
Strictly by pricing, it seemed like aws lambda was one of the cheaper options out there, but I admit my research was not exhaustive.
Consider this as my bookmark.
Would have probably been cheap (and definitely easier) to simply spin up an instance with Amazon RDS (Postgres or whatever) and point Django to it.
Moving out of Heroku into a proper VPS of course gives you much more flexibility and bang for the buck, but now you’re on the hook for all sysadmin stuff – are you monitoring counters? Log shipping? Backups? Etc etc.
Sounds super nice. Thanks for sharing this.
In case you know, can I write my own hander to import a new app type? I didn’t spot this option in docs.
Great post and read. Interesting topic and tool. How long does your app runs on this?
Great read, I’m in similar bind. Have you looked into AWS? How do you think it compares pricing wise?
Not sure why so many people struggle with deployment. Just use digital ocean alone, why bring in this other tool? Setting up Postgres is not that hard.
How would you go about hosting a React frontend communicating with a Django Backend using this setup and one domain name?
You can stretch caprover out even further by using S3 / Amazon RDS. w/ this setup I’m able to scale pretty seamlessly.