My Go to Stack for Building a Saas
source: https://news.ycombinator.com/item?id=25973242 Jan 31, 2021
Why docker in 2021
I bought a ebook on docker long time ago. I have learned and re-learned docker many times but didn’t put it in use. Finally I took the bullet and used docker to setup dev environment for workplace.
I found the end result is cleaner than Ansible, one or fewer docker file compared to many and docker-compose orchestration is nice.
But, Docker definitely has bigger learning curve if try to do it right. The amount of notes I took on Docker is telling.
That’s my opinion and let’s hear others:
One of the most important thing docker provides is an abstraction between the application and the OS. If you don’t need the abstraction, then it’s only going to look like cost.
On the other hand, being able to write an some code in python 3.9 and deploy it anywhere across a heterogeneous production environment without fighting with the OS about how many versions of python it has installed is a useful thing.
I find it really useful for development. For example when I configure nginx + a service, if it works in my local env, I have to run one command and I’ll have the same in prod, and I don’t have to debug in the server. Also is useful to keep track of the OS dependencies.
But it ends up being a matter of preference, I could still do it without it, but I’m used to it now, for some reason I feel that it makes my systems more “reproducible” in a simpler way.
and add questions like: are all paths correct for this machine, are binary lib dependencies the same as in production, are the OS versions compatible between dev and prod, is my local runtime version compiled with same options?
If you have to answer such questions then yes, Docker is probably a good solution for them. I find that in my pretty vanilla web development, I am not faced with those questions. Most of my stuff is just Python, Django, PostgreSQL, Nginx and a few not very exciting Python dependencies. (This is in several independent projects, working as a sole developer, since 2014 and let’s say ~100.000 users of my SaaS apps.)
- In my experience you’ll just run into them one day by accident. My last one was actually about differences in postgres drivers talking to sqlalchemy between Debian and Fedora. I agree it’s likely a “pick your poison” situation, but these days I prefer defaulting to containers (and investing time upfront) for just about everything to prevent those problems rather than debug them once they happen.
someone mentioned the following and that led me to this docker official blog post, How to deploy on remote Docker hosts with docker-compose. More reading!
Docker, traefik and debian auto-update alone allow me to run all my side projects on a single semi-beefy machine i pay <20€/mo for.
I like to try new JS technologies and those alone sometimes need different node versions - i would hate to spend time on these issues.
My deployment is 2 lines: DOCKER_HOST=ssh://user@mydomain.com docker-compose up
Did not have to touch it for years
Hosting
Looks like Hetzner is fast even for US visitors.
A dedicated server at hetzner is about 30-35 dollars / month. That will get you a ryzen5/64 gigs/512 RAID-1 NVME on linux.
Heroku at that spec really starts to hit the wallet.
More than engouh for a lot of applications. Hell, I ran a E-commerce company with 20MM USD/year in sales on a dedicated server from 2005-2013.
Most things are plain vanilla and rock stable. I can go from new server to running my first services is less than an hour. Ansible or cloud-init go a long way to turning my pets into cattle, so to speak.
I spend nearly no time “managing it” – I have grafana dashboards and Hetzner monitoring the critical things.
75% of my visitors and users are in the US. The latency is simply not an issue. And surprisingly many in Malaysia.
I run my blog and some small SaaS utils. I’ve never had a complaint ever about speed, responsiveness, or latency.
I’m in Europe, but most of my users are based in the US. The ping seems to be in the low 100s for my users and the price is really low compared to AWS/GCP/Azure (about $450 vs $2500). I think it’s pretty much worth it.
I’m from the US and my personal website has been hosted through hetzner for 3+ years. From the US, I typically got around 120-130ms ping before I put it behind cloudflare.