Search code examples
containersmicroservicesamazon-ecs

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


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?


Solution

  • 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.