Settings

Theme

Ask HN: What type of communication between microservices you use by default

2 points by orsol 4 years ago · 4 comments · 1 min read


Here is a diagram to illustrate two commons way of communication https://ibb.co/Ch5Vsdz

Do you use direct communication or message bus by default? Are there any pros or cons that are missing from the diagram?

sethammons 4 years ago

I tend to reach for a queue when an item should processed by a single consumer and you have fancy retry logic.

I tend to reach for a message bus when N consumers may need to know about an event that happened.

I usually start with a synchronous API call to the target service over http and only reach for other methods when reliability, response time, or throughput concerns justify it.

  • orsolOP 4 years ago

    Thanks for the reply. What is the approximate percentage of connections that goes directly from service to service rather than from service to message bus/queue? I'm curious about the order of magnitude.

    • sethammons 4 years ago

      Just depends on what can be lost and how you handle retries. Last big service I worked on (throughput of a few billion work items / incoming api requests per day) had a dozen network dependencies. We leveraged an in house queuing system, kafka as a bus, and all calls to other services as direct calls with heavy caching. Every call interacted multiple times with the queue (minimum 2) and sent out ~8 events. Each call leveraged direct network calls to the dependent services but due to caching responses, batching, pre-pulling data to cache, etc we would typically keep calls under a couple thousand requests per second.

      So more direct to your question, I guess you could say 1 request became 2 queue calls, 8 bus events, and a dozen direct network calls at 90% cache hit ratio.

      • orsolOP 4 years ago

        Nice, thanks for sharing. Looks like direct communication prevails in your case.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection