Self-host database or pay for a service?

I’m building my first app which includes a backend, frontend, and a database. I’m considering using Docker for my backend and possibly putting the database in a separate container.

I think paying for a database hosting service would cost around $10 per month, while hosting it myself might not raise my costs significantly. Should I opt for the paid service for easier management?

Just looking for advice and to see what others have done.

Edit: I meant to say it’s a Postgres database.

Edit 2: I realize I don’t mean ‘self-hosted’; I mean running the database on a server I manage instead of paying for a managed database service.

If you’re using Docker, you can dockerize your database and host it alongside your backend on a platform like DigitalOcean.

Lin said:
If you’re using Docker, you can dockerize your database and host it alongside your backend on a platform like DigitalOcean.

Check out Coolify. It’s free, open-source, and simplifies DevOps. But if you’re unfamiliar with Docker or Nginx, it might be worth learning.

@Lyle
Coolify uses PHP. Your choice, but I wouldn’t recommend it.

Lin said:
If you’re using Docker, you can dockerize your database and host it alongside your backend on a platform like DigitalOcean.

Is managing it yourself particularly harder than using a paid service? I assume backups would be simpler in a managed service.

@Devi
Yes, managing it yourself involves more DevOps tasks, like Docker, Nginx, and scaling, while managed services take care of those aspects.

Lin said:
@Devi
Yes, managing it yourself involves more DevOps tasks, like Docker, Nginx, and scaling, while managed services take care of those aspects.

Would you then recommend a service? As a one-person team, I’d be happy to pay around $10 per month for something straightforward. Some people have mentioned Neon, where I think I’d fit within the free tier.

@Devi
I prefer self-hosting for a toy project, but would go for a managed service for a more serious project.

@Devi
PHP is definitely the way to go, and most Terraform modules, Kubernetes, etc., use it as well.

I suggest self-hosting. There is little to manage since, at low traffic levels, the database requires no tuning or scaling. I managed to reach 200k daily active users with just one DB instance.

Kai said:
I suggest self-hosting. There is little to manage since, at low traffic levels, the database requires no tuning or scaling. I managed to reach 200k daily active users with just one DB instance.

Would I need to manage backups as well? I’m unsure about the requirements and process for that.

@Devi
You can set up a script to back up your database to S3. It’s quite simple, just a one-liner.

@Devi
Perform a dump of the database and store it elsewhere. Most cloud providers also offer daily snapshots, which should suffice for starting out.

For a casual or small project, I would suggest deploying the database in the same container as your backend service.

Oli said:
For a casual or small project, I would suggest deploying the database in the same container as your backend service.

Exactly, include Nginx in that setup too.

Where are you planning to host your backend?

Lin said:
Where are you planning to host your backend?

I haven’t decided yet, but it seems likely I will use a Docker container, as it’s highly recommended.

Consider using CockroachDB; it’s robust and offers a generous free tier.

The most cost-effective way is to self-host on a Docker instance, but consider hidden costs like time spent on administration, infrastructure for redundancy, backups, updates, etc.

Although it may seem overkill for a small app, ask yourself if managing these intricacies is worth it. Do you have the skills to handle potential issues that may arise behind the scenes?

Personally, I’ve gone with NeonDB due to their generous free tier, especially since you’re using Postgres which is compatible with their service.

@Avery
Thanks, Neon was recommended by someone else too. As a solo developer, I’d be comfortable paying $10/month for ease of use, and I think I’d fit within their free tier.