如何连接分布式的Go应用程序?

huangapple go评论65阅读模式
英文:

How to connect distributed Go apps?

问题

我有两个在不同机器上运行的Go应用程序。
我希望它们能以本地快速的方式进行通信。

我该如何更好地实现这一点?我之前使用过Erlang,并发现它的实现方式非常方便。

在Go应用程序之间进行通信的首选方式有哪些?

英文:

I have two go apps running on different machines.
I want them to communicate with each other in a native fast manner.

How do I do it better? I worked with Erlang and find very handy the way it's implemented there.

What are preferred ways to communicate between Go apps?

答案1

得分: 1

net/rpc - 开箱即用且快速

gRPC - 快速且通用(我认为是最好的选择)

net/rpc/jsonrpc - 当你需要可读性强的消息或者想要将Go与客户端的JavaScript代码集成时,这是一个不错的选择

plain HTTP - 对于Go程序之间的通信来说有些过度,你需要自己规划路由和数据编码,这是不必要的工作

message queue - 这是一种稍慢一些的方法,但你可以从它们提供的高级路由和持久性中受益。

英文:

net/rpc - out of the box & fast

gRPC - fast and universal (imo the way to go)

net/rpc/jsonrpc - good when you need human readable messages or want to integrate
go with client side js code

plain HTTP - overkill for communication between go programs, you'll have to plan routes and data encoding yourself, which is unnecessary effort

message queue - a bit slower approach, but you can benefit from advanced routing and persistence which they provide

huangapple
  • 本文由 发表于 2017年1月23日 23:55:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/41810397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定