Heroku is an old and popular cloud provider that people often recommend as the go-to solution for deploying your web apps.
But is Heroku such a great platform?
The main problem with Heroku is pricing.
Heroku Pricing Structure
Let's first see what Heroku is charging for.
In Heroku, they for every process running in your application. These processes are called Dynos.
If you need to run several processes like web, celery workers, celery beat – Heroku will charge for each of them. So if you have four dynos, it will be at least 4*$7/mo = $28/mo.
It is easy to start small, they have a free plan, and their paid options start from $7 per Hobby Dyno per month.
Hobby Dyno gives every process 512MB of RAM. So for $28/mo, you get in 2GB RAM in total.
Your production app probably won't like running on such limited resources, and you would want to use Standard Dynos.
When you switch to Standard Dynos, you can't use Hobby Dynos within the same app. Your processes will be running with at least Standard Dynos($25/mo) or higher.
The total price jumps to $100/mo on four processes.
The Standard Dyno gives your process 1Gb of RAM. So on four processes, it is 4GB of RAM.
Digital Ocean charges for the 4GB RAM Droplet is $20/mo. In Hetzner 4GB RAM VPS costs $6.62/mo.
A fleet of 4 Standard Dynos is more expensive than Hetzner VPS by $93/mo!
If you need to process a lot of data and 1GB RAM is not enough, you can switch to "Performance M" dyno and get 2.5GB RAM, for which Heroku charges the insane $250/mo.
In our example of the application with a web process, two celery workers at "Performance M" and a Celery Scheduler on a Standard Dyno, the monthly compute expenses for this app will be already $775/mo.
And that's where you wished you didn't use Heroku!
How Heroku pricing compares to Digital Ocean and Hetzner?
For 2GB RAM VPS:
- In Digital Ocean, you can get for $10/mo.
- In Hetzner they ask $5.40/mo.
So it is already $15/mo overhead on a small hobby app which can be noticeable for side projects.
For bigger apps where Heroku charges $775/mo, let's compare to other providers:
- Digital Ocean: 8GB RAM droplet will be $40/mo
- Hetzner: 8GB RAM VPS will be $12/mo.
It is $763 savings per month or $9156 per year.
More than $9000 saved per year solely on computing expenses.
Appliku is the alternative to Heroku
Heroku provides a massive convenience for developers by automating application management and building and deploying the app.
While moving to another provider, we would like to keep this convenience and experience.
Appliku provides all the tools that you need to manage your apps on servers of your choice conveniently:
Appliku will do the following tasks for you:
- Setup your server
- Issue and setup SSL certificates so your app is served securely with HTTPS
- Build and deploy your apps from GitHub and GitLab repositories
- Provide you with a dashboard to change settings of your app without login in via SSH
- Sync your Config Vars between applications in Heroku and Appliku for seamless migration.
Appliku helps you move to a more cost-efficient cloud provider while providing you with powerful tools to run your apps.
Appliku charges a flat fee for the number of servers you want to manage. You can run as many applications as you need and perform any number of deployments per month.
How to reduce Heroku costs?
The good news is that reducing the costs of Heroku is quite simple. Moreover, you can do it gradually and without service interruption.
Moving off of Heroku includes taking care of these main parts:
- Moving background workers
- Moving web worker and routing web traffic
- Moving database and Redis
It is best to do it in this particular order to start reducing costs faster and leave the more challenging steps for later.
Databases are linked to your application via Config Vars.
Databases on Heroku inject the DATABASE_URL, and Redis sets REDIS_URL config vars to your app with credentials for access to these services.
The tricky part is that Heroku updates these variables' values when they perform maintenance for databases. Therefore, the app needs to have this config vars up to date at all times.
Thankfully, Appliku has the feature Heroku Config Vars Sync, which will mirror all config vars from Heroku application to Appliku application for you.
Let's get back to our example and calculate how much money we can save.
We'll compare the initial Heroku compute expenses and the alternative with Appliku Duo Team Plan + a VPS from Hetzner.
Heroku Dynos: 3x$250/mo Performance M + 1x$25/mo Standard = $775/mo, $9300 per year
$29/mo Appliku Duo Plan + $17/mo Hetzner CPX31VPS = $46/mo, $552 per year
Do you see? It is $8748 per year saved without sacrificing convenience in managing your applications!
Additional benefits of running on your own server
In Heroku, there is a limited number of customizations you can do. You either accept it or adapt your app to meet your requirements while running on their platform.
Some customizations and fine-tuning are not possible in Heroku at all.
Web Server settings
You have no control over web server settings. There is a limit of 30 seconds for the web process to respond to a given request. After 30 seconds of waiting client will receive an error. Of course, it is a bad practice to allow long responses over 30 seconds, but if your app needs this, it won't work on the Heroku Platform.
Static IP for outgoing requests
Since Heroku is running on its cluster, you never know which server will execute your program and the IP address of that server. If your app requests an external API from an allowed range of IP addresses, it won't work on the Heroku Platform.
In Appliku, it is possible to configure pretty much anything if you need it because apps are deployed on your servers.
You can access the server and tweak the server configuration to match your application needs.
Since you know the server's IP and it is unlikely to change, you can safelist it in 3rd party API.
How to migrate from Heroku to Appliku
- Get an account in Appliku https://app.appliku.com/
- Create a server through Appliku or add a custom server from provider of your choosing.
- Create an application from the same repository you are using for your Heroku app.
- Get your API key from Heroku and enable Heroku Config Vars Sync
- Enable all workers and deploy the app in Appliku.
- Disable celery beat and other workers in Heroku and make sure your app operates as expected. You already started saving money at this point!
- Change the A record of your web app to point to your server.
- Add the custom domain to your application in Appliku. These two steps can take few minutes and this can result in a little interruption of your service.
- Disable web Dynos in Heroku. That's it, you are no more paying for Heroku compute.
- Create a Redis instance through Appliku interface. Copy the REDIS_URL from Redis instance.
- Remove Redis instance in Heroku and add REDIS_URL from the previous step into Heroku Application Config Var.
- You can also create a Postgres instance in Appliku and do the similar transition as with Redis, but you also need to migrate the data to the new database!
- When you remove database from Heroku you can disable Heroku Config Vars Sync feature. At this point your app works solely through Appliku.