6 ms·
My default for websites which do not require database is docker image + Google cloud run. Costs almost nothing, easy clickops deployment from GitHub, https mana
by kebsup 3y ago
My default for websites which do not require database is docker image + Google cloud run. Costs almost nothing, easy clickops deployment from GitHub, https managed, reasonably fast cold starts.
- ngshiheng 3y agogenerally speaking, isnt using vps a lot less expensive than a managed service like cloud run? im assuming the “websites” doesnt require to be always available 24/7 (hence the cold start is fine)?
- sauercrowd 3y agoreally depends on the traffic, but even if you're service ends up running 24x7 you'll end up paying about 10 dollars for a 1CPU/0.5GB RAM instance. So for a lot of stuff Cloudrun will actually work out pretty cheap. Don't underestimate cold starts though. Will be a long time until you need to worry about that if you're backend is written in Go or Rust, but you can hit painful starts pretty quickly when it's Nodejs. Really comes down to (unsurprisingly) image size.
- sauercrowd 3y agoAlso - this is worth calling out If coldstarts are a problem, things like fly.io are incredible. Just set the minimum amount of instances to 1, pay 5$ a month and you don't need to deal with anything. It wasn't immediately obvious to me how fly and Cloudrun compare, but the way I think about it now after having used both: In Cloudrun you don't think about any servers, you give them your image and they'll do the rest. It feels serverless in the sense that you don't think about machines. Fly meanwhile is much closer to the infrastructure. It feels more like "we deploy a docker image to a VM for you", which let's you much more granuarly control what's going on beyond that. Less magic, but in a good way because more predictable results. Cloudrun has a few fun corners (like no CPU between requests unless you explicitly enable it) that can lead to fun side effects and just make it harder to reason about.
- riskable 3y agoUgh... I don't want to denigrate your advice (which I'm sure is great) but at this point in the comments we're getting so far away from the, "keep it simple" approach in the article that it's getting ridiculous. If you're at the point where you're concerned about cold starts and using a service like fly.io why not just skip the (unbelievable, no-one-knows-this-stuff) complexity and use a $5/month VPS?
- sauercrowd 3y agoThat's a fair point, but that's essentially what fly does. If the only purpose of your VM is to serve your app (and not as a workspace for you or stuff like that), fly's great because you don't need to do any plumbing to deploy. "Simply" using a 5$ VPS sounds great until you need to start writing systemd files, need to keep the box updated, want to deploy straight from GitHub,...
- prmoustache 3y agoIt doesn't take more to write a systemd unit file than figuring out the api request or navigating the gui of your favorite cloud service. Nowadays all linux distros offer an unattended way to do packages security updates and reboot the node.
- stephenr 3y agoGoogle cloud run calculator says a 24x7 0.5G instance is $30 a month - the DO droplet with the same cpu/memory is $6/month. The 0.5G instance has a minimum cost of $10 a month, before any kind of traffic metering, or what have you.
- kebsup 3y agoJust to give some specific numbers: - 40 visits a day - costs 0.01 USD per month - cold start time: 350 ms - however request latencies are 99%: 120ms, 95%: 85ms, 50%: 5ms - there seems to be "idle" instance like 80% of the time The website with source: https://github.com/PetrKubes97/ts-neural-network https://github.com/PetrKubes97/ts-neural-network
- schemescape 3y agoAm I reading correctly that you’re running a site with 40 visits per day and it’s only costing you 1 cent per month? So you have a container with Alpine Linux and nginx and that’s hosted in Cloud Run and mapped to your domain? When you say “visits” do you mean the container is active 40 times per day (presumably for not very long)? Edit: what determines when to suspend the container? Edit again: answering the previous question: https://cloud.google.com/blog/topics/developers-practitioners/lifecycle-container-cloud-run https://cloud.google.com/blog/topics/developers-practitioner...
- kebsup 3y agoYes, that's exactly right. 40 visits, is just what plausible measures, and looking at GCloud logs, seems that container start count is in similar range.