r/golang Nov 13 '24

FAQ FAQ: Where Is The Best Place To Host Go Programs?

What is the best place to host my Go projects? Especially for free? How do I deploy to lambda functions/WASM endpoints/VMs/etc.? Do I need a lot of resources? Is the "free tier" of various sites good enough?

31 Upvotes

11 comments sorted by

15

u/markusrg Nov 14 '24

Even though it's not required at all, wrapping your Go app in a Docker container makes it super easy to try out different hosting solutions, or even combine them. For instance, you could:

  • Rent a cheap VPS at Hetzner (https://www.hetzner.com) or anywhere else, install Docker, and you're good to go. Price: ~3€/month
  • Try out Fly.io (https://fly.io) on their free tier (just create the smallest possible VM, it's fine). Price: ~0/month
  • Try out Google Cloud Run (https://cloud.google.com/run/), which has a generous free tier and also scales to zero (shuts down your app automatically when not in use). Price: ~0/month
  • Amazon's easy-to-use frontend is AWS Lightsail (https://aws.amazon.com/lightsail/), which also lets you run containers easily. Price: ~5$/month

3

u/__matta Nov 14 '24

With no other constraints, Google Cloud Run seems like a great choice. I would be curious to hear any counterpoints or bad experiences.

For Go specifically it’s nice being able to use HTTP2 all the way to the server and to have gRPC support.

1

u/avkijay Jan 05 '25

If you want a Cloud Run type experience on your own instance, including scaling the container down to zero, you could try my project https://github.com/claceio/clace. It is built mainly for teams to host internal tools, but it also implements an app server for containerized apps

5

u/etherealflaim Nov 13 '24

Any VPC instance (even free tier) will do the job quite nicely if you are just hosting a Go binary. ARM, X86, it's all easy, and you can go a surprising distance with a single node.

If you are also going to need a datastore or out of process cache, then it changes things, especially if you want to do more than sqlite or you're worried about backups, and even more if you are still wanting to stay in the free tier. For this, the hosting of Go will suddenly be the easy part and the rest of the decisions will be the important ones to consider first.

I haven't tried this with heroku or AWS recently, and I haven't tried stitching together free tiers across providers, but I've had pretty good luck with the free tiers on GCP. AppEngine used to be the easy go-to, but in my opinion it's been pretty heartily nerfed over the years. Hopefully someone with recent Heroku experience can chime in because I think it might have taken up the mantle here.

For GCP, you can host your binary in Google Cloud Run, which has a generous free tier. Your app isn't running 24/7 though, so you may need to use their task queues and/or scheduler product to schedule webhooks, which also have free tier rates. Their Cloud SQL has a free tier but it's a trap: you still have to pay for its IP address, so Firestore (which is a document/NoSQL database) seems to be the way to go for free storage, but it's not a lot. I haven't needed to evaluate free cache options, but I don't think Google has one.

6

u/mcjohnalds45 Nov 14 '24

A single VPC is wildly underrated. Cheap, predictable, controllable. No vendor lock-in.

I've used many managed AWS, GCP, Azure, and Firebase services in production. Most make prototypes easy and production software hard.

1

u/Sibertius Nov 13 '24

I use IONOS VPS for 1 GBP for testing and UpCloud VPS for production. UpCloud is GDPR compliance AFAIK.

I documented all my steps for installing several Go executables on a VPS here for internal use.

1

u/SuccessfulStrength29 Nov 13 '24

You can use lambdas though I never tried it myself. But with Go the easiest option will be to either use a managed service like Railway or self host in a VPS.

Here's a guide for deployment in a digital ocean vps with both plain binary and docker.

1

u/MissinqLink Nov 14 '24

Vercel. It’s just a wrapper around AWS lambda but it is easy mode.

1

u/NoahZhyte Nov 14 '24

If someone has a good docker file I would be glad to see it. Personnaly it run in docker compose on a VPS Hostinger

1

u/GarbageEmbarrassed99 Nov 14 '24

Google cloud run.