Golang Hosting

Hosting Go web applications and APIs are a bit different than hosting PHP applications. Where a PHP file can be uploaded to a server, anywhere in the web root, and it will be interpreted and executed by the web server. Go is different. A Go application normally is a long running process, waiting for connections when it’s not processing requests. The apps need to listen on port 80, or alternatively use a proxy to by a front end sever.

Because Go applications need permission to listen on port 80, they don’t work well on a shared host. There are hosting solutions though, they range in scope and size from VPS providers, platform providers, and specialized platforms. Each offering a variety of features and options to fit any need.

VPS Hosting

The VPS (Virtual Private Server) is a fully self-managed server virtualized on the host provider’s server. These are classified as IaaS (Infrastructure as a Service), the lowest level in the cloud services hierarchy. IaaS offer full control over the whole software stack. In effect it is a full Linux server, root and all. With this freedom and control comes the responsibility of managing it. Linode does offer a manged service as an add-on.

I have several websites on my VPS running on Apache. Because I wanted to keep my existing sites I setup my Go web applications to proxy back to Apache, the apps then listen on localhost for incoming connections. This allows my existing sites and Go apps to live together in harmony.

The power of have a VPS is your ability to customize your install any way you like. Using Docker, lightweight Linux containers, you can containerize your Go app. The Docker container can be used locally for development and deployed to live. Because the container is self-contained deployment is simplified. Docker is flexible enough that you can continue to use Apache/nginx as a front end proxy to the application.

Linode, now with fast SSDs.

DigitalOcean

Amazon EC2

Heroku

Heroku is a PaaS (Platform-as-a-Service) provider that supports Go through a third-party buildpack. These buildpacks are a shim layer that adds language support to the core PaaS server. Heroku supports a few of their own buildpacks, but allows for third-parties to create their own to extend the usefulness of their service.

Heroku is a PaaS, which means you don’t have as much control over the lower layers of the server as you would with a VPS. Instead you use the heroku command-line program to interact with the server, and git to deploy. This offers control of your application without the hassle of having to fully manage a server.

Google App Engine

App Engine is Google’s cloud PaaS. It sits somewhere between Heroku’s service and fully managed SaaS apps. It allows you to create customized applications and run them on App Engine without being concerned with the database, operating system and software upgrades, security, and uptime. Like Heroku it allows you to focus on your app and Google takes care of the rest, but it also takes care of the datastore.

The good news is that App Engine supports Go as a first class language. The drawback is that Go apps written for App Engine use their API, which makes them difficult to move to another hosting solution should the need arise.

All the choices

There are several options for hosting Go. Each type has benefits and drawbacks; which really depends on your personal needs. Those of you who want more control will go with a VPS provider like Linode. Where those of you who only care about the application you are creating will choose Heroku or App Engine. With so many options the price will be reasonable and features competitive enough that you should find a good solution.

Thanks to Brian Ketelsen (@bketelsen) for looking over this post.

Edit: Other options I didn’t known about