英文:
In AWS ECS, how to communicate between services? (Protocols, best practice)
问题
在AWS ECS中,我有一个作为Web应用程序运行的服务(有4个任务)。现在我希望实现一个新的消息队列服务(RabbitMQ),这个服务将被所有4个任务/容器共享。如何做到最佳实践?
进一步的问题:
-
如果情况是我们必须在消息队列上编写一个小包装器;假设我们使用Python来解析输入,然后将它们发送到消息队列;我们是否必须使用HTTP或TCP协议进行数据传输?(这种通信是在服务/容器之间进行的,但TCP是设计用于在网络上传输数据的)如果不是,有哪些选项?
-
对于在不同端口上监听的服务/容器之间的数据通信,有什么标准/常见的方式?
英文:
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:
-
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?
-
What is the standard/common way for data communication among services/containers that are listening on different ports?
答案1
得分: 1
我正在回答自己的问题。
有两种常见的策略可供使用。
- 使用带有直接端口通信的AWS服务发现。(协议取决于特定的应用,例如:Redis及其自身的协议)
- 使用gRPC,这是基于HTTP/2的协议,具有长连接的TCP连接。它轻巧,通常支持多种语言,并且具有包括类型检查、输入验证在内的特性。
英文:
I'm answering my own question.
There're two common strategies we can use.
- Use AWS Service Discovery with direct port communication. (protocols depends on the specific application, ex: Redis and its own protocol)
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论