在AWS ECS中,如何在服务之间进行通信?(协议、最佳实践)

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

In AWS ECS, how to communicate between services? (Protocols, best practice)

问题

在AWS ECS中,我有一个作为Web应用程序运行的服务(有4个任务)。现在我希望实现一个新的消息队列服务(RabbitMQ),这个服务将被所有4个任务/容器共享。如何做到最佳实践?

进一步的问题:

  1. 如果情况是我们必须在消息队列上编写一个小包装器;假设我们使用Python来解析输入,然后将它们发送到消息队列;我们是否必须使用HTTP或TCP协议进行数据传输?(这种通信是在服务/容器之间进行的,但TCP是设计用于在网络上传输数据的)如果不是,有哪些选项?

  2. 对于在不同端口上监听的服务/容器之间的数据通信,有什么标准/常见的方式?

英文:

In AWS ECS, I have a service (that has 4 tasks) running as web applications. Now I wish to implement a new service for message queue (RabbitMQ) that is shared by all 4 tasks/containers. What is the best practice for doing so?

Further questions:

  1. If the scenario is that we have to write a small wrapper over the message queue; say we use python to parse the input before they reach to message queue; do we have to use HTTP or TCP protocols for data transmission? (such communication is among services/containers but TCP is designed for data transmission over the network) If not, what are some options?

  2. What is the standard/common way for data communication among services/containers that are listening on different ports?

答案1

得分: 1

我正在回答自己的问题。
有两种常见的策略可供使用。

  1. 使用带有直接端口通信的AWS服务发现。(协议取决于特定的应用,例如:Redis及其自身的协议)
  2. 使用gRPC,这是基于HTTP/2的协议,具有长连接的TCP连接。它轻巧,通常支持多种语言,并且具有包括类型检查、输入验证在内的特性。
英文:

I'm answering my own question.
There're two common strategies we can use.

  1. Use AWS Service Discovery with direct port communication. (protocols depends on the specific application, ex: Redis and its own protocol)
  2. Use gRPC, which is a protocol based on HTTP/2 with long-lived TCP connections. It's light-weight, generally supported in multiple languages, and has features including type check, input validation built-in.

huangapple
  • 本文由 发表于 2020年1月4日 12:23:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/59587861.html
匿名

发表评论

匿名网友

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

确定