55

I have heard of the terms "Upstream Services" and "Downstream Services" in general terms but I came across some articles on microservices architecture where they have used these terms. I wasn't able to understand what an upstream and downstream service in a microservices based architecture would be? Can somebody give me a brief explanation?

I already know that upstream services are those that do not depend on any other services and downstream services depend on the upstream services. For example, the front-end would be a downstream service to the backend as it depends on it.

I am developing the microservices in .Net Core.

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
Shubham Tiwari
  • 959
  • 1
  • 11
  • 32
  • 1
    There are tons of resources in the internet explaining this topic in detail. This could be good start point - https://softwareengineering.stackexchange.com/questions/312401/which-way-are-downstream-and-upstream-services – Atanu Roy Oct 30 '19 at 11:49
  • I have already seen this source but this is mainly in general terms not specific to micro-services , can you provide me a link for micro-services ? i have tried searching on the net but i haven't found one ! – Shubham Tiwari Oct 30 '19 at 12:02
  • 2
    If you are building an API Gateway for micro-services, maybe looking at the documentation of Ocelot will give you some idea about how they define downstream and upstream - https://ocelot.readthedocs.io/en/latest/features/routing.html – Atanu Roy Oct 30 '19 at 12:12
  • 1
    Add this question to the list of unsolved problems in computer science. :) – Lee Grissom Feb 12 '22 at 01:00

5 Answers5

76

Definition 1: The direction of action

Upstream: receiving requests from / sending responses to

  • A service upstream is calling me.

Downstream: making requests to / receiving responses from

  • I am calling a service downstream.

Definition 2: The direction of dependency

Upstream: making requests to / receiving responses from

  • I am calling a service upstream.

Downstream: receiving requests from / sending responses to

  • A service downstream is calling me.

So,

There are resources on the internet which support both of these definitions. Maybe we will resolve this question one day, but for now the answer is: it's either.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • 9
    I had the same understanding. Until today when I learned it's the other way around. With good arguments. See https://softwareengineering.stackexchange.com/questions/312401/which-way-are-downstream-and-upstream-services, and in https://reflectoring.io/upstream-downstream/ as pointed out below by Michael in the comment. – Bernd Jul 16 '20 at 16:11
  • Hi @Bernd very interesting discussion. Maybe we should have a vote and settle it once and for all! – tom redfern Jul 16 '20 at 16:17
  • 1
    So helpful how you wrote out those 2 opposing sentences. I have been working with upstream and downstream services for years but have a hard time keeping it straight. This will help. – Brian Peterson Oct 12 '22 at 14:57
  • Can I define "Upstream" like core or domain and "Downstream" conectors and orchestrators? – ohrlando Aug 11 '23 at 12:55
  • @ohrlando sorry I do not understand your question – tom redfern Aug 14 '23 at 09:46
  • Thinking about Clean Architecture, could I identify upstreams like the components encountered at center? – ohrlando Aug 25 '23 at 10:16
19

The downstream services are the ones that consume the upstream service. In particular, they depend on the upstream service. More generally, upstream services don't need to know or care about the existence of downstream services. Downstream services care about the existence of upstream services, even if they only optionally consume them.

http://reflectoring.io/upstream-downstream

Ashish Pani
  • 933
  • 1
  • 12
  • 19
16

I see it is a metaphor of water flow: the origin of a river is upstream, the outlet is downstream.

But in practice it is gibberish. Nowadays services exchange data through different means. A service can call another service to fetch data, it can also call the other service to push data. A service can receive data from another service by calls out first or it can receive data passively, like receiving push notification.

At work, you can use it judiciously: if someone who's more senior than your calls a service upstream service, go with it; if you are the most senior one on the team, name whatever you like.

Shijing Lv
  • 6,286
  • 1
  • 20
  • 12
11

Upstream and Downstream in a Production Process enter image description here

Upstream and Downstream Software Dependencies enter image description here

Source

A picture is worth a thousand words !!

Tom Taylor
  • 3,344
  • 2
  • 38
  • 63
1

It's the stream of service, so the provider is upstream and the consumer is downstream.

http://reflectoring.io/upstream-downstream

Daniel B
  • 4,145
  • 1
  • 21
  • 21