英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论