Request-Reply

    The increased complexity of modern systems necessitates features like location transparency, scale-up and scale-down, observability (measuring a system’s state based on the data it generates) and more. In order to implement this feature-set, various other technologies needed to incorporate additional components, sidecars (processes or services that support the primary application) and proxies. NATS on the other hand, implemented Request-Reply much more easily.

    • NATS supports the Request-Reply pattern using its core communication mechanism — publish and subscribe. A request is published on a given subject using a reply subject. Responders listen on that subject and send responses to the reply subject. Reply subjects are called “inbox“. These are unique subjects that are dynamically directed back to the requester, regardless of the location of either party.

    • NATS applications “drain before exiting” (processing buffered messages before closing the connection). This allows the applications to scale down without dropping requests.

    The pattern

    Try NATS request-reply on your own, using a live server by walking through the request/reply walkthrough.