Where do you choose to keep your data, managed DB or a DIY solution?

Unless I have very specific requirements, I lean to the managed options whenever possible because they save a lot of time. Same with hosting.

I can do it all. I’d just rather spend my time elsewhere.

1 Like

Completely understandable, but it’s much more expensive to use managed options. Instead of paying ~$5 per month, you’d pay ~$20 from what I understand

I would avoid the lowest tier of anything for production. If you are low on budget, App + DB on one 10 bucks VM (second lowest tier) is a much better deal than seperate 5 bucks VM (lowest tier) for App + 15 bucks DB (again, lowest tier)

1 Like

Yep. Completely true.

The real question is, what is your time worth?

And that answer can become skewed if you want to invest the time to learn how to manage everything yourself.

4 Likes

That’s perfect question. I would like to suggest to not install own servers, db, etc… I use heroku a lot and they have free tier for DB too. Even, I would suggest to use AWS db, it can be cheap for not a lot of data (< 1 000 000 rows). You can connect to your AWS DB from outside of aws with ssl/tls connection(https, mutual tls with own cert,…) and I think it’s by default.
Also, DigitalOcean has new feature https://www.digitalocean.com/products/app-platform/ and I’m not sure about pricing.

Because when you install own servers you have to take care of:

  • security,
  • upgrades,
  • regular issues with OS/VM.
    And these things can consume a lot of times, tens of hours. So it’s up to you where you want to invest your time.

And it depends on your Elixir app, you can have very fast restart/upgrade with just a few seconds downtime. But in case you need to have do rolling upgrade because you want to take some data and processes from old app you should thing you will have to have more money for it. The easiest way it’s managed Kubernetes. Yes it’s too much virtualization but it can give you powerful deploy (rolling upgrade) orchestration. I don’t think k8s is good tool for elixir app but we use it a lot because I’ve not found better and cheaper tool for deploy orchestration of our ~40 elixir apps.

1 Like

Thanks for your comment! I was really hoping to avoid k8s because it would just get quite expensive. The entire motivation behind a DIY solution was to keep the price low, but based on the comments I’ve received so far, it seems that it’s almost a necessary expenditure.

I found that DigitalOcean is far more expensive than heroku, but I don’t know pricing of their new Apps platform. I have couple of Elixir apps on Heroku. Two biggest apps have around 100k visitors per month. One is ruby, simple blog and another one is Phoenix. It’s portal for some kind of startup competitions, so a lot of uploads, questions and some collaboration with LiveView. Both apps run on own 1 Dyno + paid plan of Postgresql. It was on smaller plan for $7/m but we had issue sometimes with huge load (>1 000 people was uploading and answering huge forms and collaboration) so we upgraded it. Now we don’t care about it at all. It just works


When you are going to have only one app so don’t even think about k8s :smiley: . If you want to have release without outage you can find some way, maybe some PaaS have it (Gigalixir, AWS Elastic Beanstalk,…). Or you can find solution how to run to apps when you are releasing and these connect to cluster and later kill old one. Or do your app faster to start and you will have really small downtime, like 1-2 seconds maybe.

2 Likes

fyi for example AWS has ECS and these guys created nice tool for it Ship it! with ecs-ship - NextRoll and I think that company use erlang/elixir a lot. So there will be some article/tutorial/support from them.

1 Like

It really depends on what my expectations are for the project.

Even for a single server deployment, a hosted DB is interesting from a downtime perspective because if you wanted to perform a “reboot required” update (upgrading machine specs, kernel updates, etc.) you can do it with zero down time by spinning up a 2nd server and setting your A record to that, but this only works seamlessly if your database isn’t on the same host as your server.

That’s because your site might be loading from the old vs new server depending on the user’s DNS cache so your data needs to be in some other centralized placed where either version writes to the same DB.

Also having a managed DB lets you move from 1 server to multiple servers with no downtime and is pretty much a hard requirement if you plan to use multiple servers from the beginning.

But with that said, I don’t mind self hosting everything on 1 server if I’m ok with the project having 5 minutes of downtime to upgrade OS versions once in a while. Running PostgreSQL manually on 1 server really isn’t too bad from a technical difficulty POV.

1 Like

I manage everything myself on a single digitalocean droplet. I just set it up with a bash script, so that’s the easy part, but I agree 100% on the downtime when a reboot is required. What I do is non-essential so I don’t mind a minute of downtime every now and then, but it’s a thing to keep in mind.
With ie Gigalixir you don’t even have to think about it.

For self managed servers I’ve had good success with unattended-upgrades and auto-reboots set to false. I’ve gotten 900+ days of uptime with this approach that was hands free maintenance wise. Sure I was running an older kernel but that never had any negative effect on my app. The server was rock solid.

Man, i just had a look at heroku pricing and my monthly estimate worked out to be $75 (DB + VM) which is far more than I was hoping for.

1 Like

Can I ask why 75? Which paid addons do you need? So you can check AWS or DO Apps solution. Or you can give use some more information about architecture and maybe we can save you some money.

Fwiw, you can connect to AWS RDS from Heroku. I’ve been running a $7 Hobby dyno for years without issues too.

btw try this https://fly.io/

1 Like

That Dyno has less memory but Elixir/Phoenix doesn’t eat a much

Sorry, my mistake, when I was browsing on mobile, I missed a few options that would work best for me. Now I ended up with a quote of 16 per month which is quite reasonable

1 Like

I am curious, what kind of latency do you see in this setup? You are running the database in a different provider, a different data center, from your application, with firewall and TLS and possibly a load balancer in between.

I’ve never measured it mainly because I’ve never noticed it as a problem. Heroku runs in AWS us-east-1 so if you provision RDS there your only latency will be between Availability Zones. On several sites we do the same thing with Gigalixir + AWS RDS.

You need to add the RDS cert to your application and use verify-full on your connection string for some added security since you can’t easily VPC limit the connections to the database until you can afford to pay for Heroku Private Spaces.

1 Like

Both Gigalixir and Heroku provide managed database services, with which I have no experience either. You don’t use them because cost concerns? Not much added value to you?