Golang in the cloud?

Hi all, I’ve started to play around with golang more seriously and plan to build some REST backend with a SinglePage front mostly for getting the “real feel for it”.
I tried to put up a simple prototype on an Openshift gear yesterday but noticed, of course, problems with my gorilla/mux package… I guess openshift won’t run any “go get” commands for me.
So, what is the easiest way to get something up in the cloud?
A virtual machine on Azure and put it behind IIS/nginx? Googles appengine?

Thanks and Regards

koding.com has support for Go. Plus you get full editing controls etc. For a quick playaround it’s ok.

I’m personally very pleased with my Digital Ocean vm. But that requires a lot more setup.

2 Likes

Thank you, I think I have an old Koding account, better look into it.
Guess I better fix myself a dedicated golang VM somewhere in the near future, but it’s nice to have something for prototyping that’s not only local.

I use appengine with Go a lot, I can’t recommend it enough.
It scales pretty much to infinity and is pretty cheap to get started with.

Google compute engine and google container engine also both run go apps perfectly fine, ofcourse.

1 Like

I’ve had a pleasant experience running Go applications on Heroku. The free tier requires your application to sleep every now and then but for testing purposes it should do fine.

Check out https://devcenter.heroku.com/articles/getting-started-with-go

EDIT: I should note that I’m building my applications on Travis which has support for deploying to Heroku.

3 Likes

Google App Engine will be fine, you can also use Amazon EC2, they have a free tier which lasts a year.

1 Like

I’m partial to Heroku, but GAE, AWS Elastic Beanstalk, Engine Yard and Openshift are all good options. Not sure what issues you’re running into on Openshift though: you should be able to specify build steps.

A big plus with Heroku is that you don’t need to change your app to migrate to/from as there aren’t any custom packages to worry about. I deploy from GitHub => Travis => Heroku automatically on pushes to master.

2 Likes

Great answers thank you all, there’s definitely a lot of options to play with.
I Guess I could get it going on openshift, I simply wrote my REST service (using gorilla/mux) and committed and pushed to my Gear… It wasn’t that easy I suppose.

I’ll think I’'ll try them all, a man can’t have enough cloud-accounts these days.

Regards

1 Like

I run a couple of small Go apps on Digital Ocean using Dokku. The setup is pretty easy and is very Heroku like. I am running them on the $5 a month VM – they don’t require much memory or any disk.

I think this blog post is still current:
http://www.mircozeiss.com/host-your-golang-app-on-digital-ocean/

It took me about two hours to stumble through the first time to launch a Go app.

2 Likes

I am using DO/Dokku as well. Several smaller websites and still using only 40% of memory and disk (USD 5 / month VM).

1 Like

DO $5 + Nginx = many Go powered sites!

2 Likes

Can you give me an example: what kind of app are you running and price please.

With aws free tier, you need to remember to close your account or delete the instance if you’re not going to use it, because they will charge you after one year, it happened to me, but they were kind and refunded the payment.

What do you use nginx for that can’t be done using net/http?

I have found for my reverse proxy/http serving needs that net/http and ~50 lines of code are sufficient.

– Charles

There is completely no problem with directly using net/http.

But for dozens of domains and a Go web site/service for each of them, visit without carrying port number is the key idea.

If you’re interested in how to be done without Nginx, @matt 's Caddy explains well by itself.

To be fair to nginx, it’d be hard to write gzip middleware, FD caching for static assets, a full OCSP stapling implementation, etc in a safe manner. A big benefit to nginx is that’s heavily battle-tested and you configure it via a DSL, not a full blown programming language. Can be a benefit to keep web server logic out of your web service.

nginx (and Caddy, both being reverse proxies) also allow your Go application to restart in the background while they queue requests.

3 Likes

Oh sure! There are definitely things nginx does that are important at
scale, and that would be a lot of work to replicate by hand coding. I use
nginx. But in a lot of cases I see people use nginx as a simple reverse
proxy, even with name based virtual hosts, where a tiny go app would have
done the job.

I’m not saying “never use nginx” I’m trying to say “use the right tool for
the job.”

+1 for Digital Ocean running nginx. Never had an issue running multiple sites on the $5/mo instance.

3 Likes

Actually you should be able to run it on openshift also, i would not recommend using “go get” on a environment different than you machine / development, and use a vendoring to runt it on a cloud provider, there are some good talks about it:

1 Like

Yes I guess I should, better look into it a little more. I got it working on heroku though, but I prefer a proper VM under my control I guess, so I can play around with databases and whatever comes to mind.