Golang Hosting

Supermighty · · 2533 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

Image courtesy of wicker-furniture

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.

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


有疑问加站长微信联系(非本文作者)

本文来自:Walled City

感谢作者:Supermighty

查看原文:Golang Hosting

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2533 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传