Up/Down stream? What is it?
You may heard the terms “Upstream” & “Downstream” in the context of software development. Most likely you encountered such a word in an open source project or a book about distributed systems.
These terms are coming originally from manufacturing / production theory. Let’s look at a simple electric car production example. We should first collect all the parts, then assemble them all together and finally ship it to the happy customer :)
The process flows from the start to the ends adding more values to the final product. It is also clear that each step depends on the previous step. We can not ship a car in parts! we’re moving downstream.
Let’s take a monolithic 3-tier web application as example to apply the same concept.
- Dependency Rule: each component depends on all the components upstream from its viewpoint.
- Value Rule: moving downstream, each component adds more value to the end user.
Keep in mind that the Business Logic component is an upstream of the UI and a downstream of the Data Access layer!
In a distributed system or microservices architecture, there’s also talk about upstream and downstream services. An in-memory distributed cache service is the upstream service (called X) of a shopping cart service (called Z) in a ecommerce system. The service Z depends on X. And service Z is the downstream service since it adds to the value of service X.
Another context where the words “upstream” and “downstream” are used a lot is in open source development. It’s actually very similar to the component dependencies discussed above.
If you fork the HashiCorp Nomad repository, your fork is called the downstream. You may create a fork of the project to fix a bug or add a feature and then submit a patch to the original project. You added a value!
In any context where the concept of “upstream” and “downstream” is used, we can apply two simple rules to find out which item is upstream or downstream of another. If an service / component / docker adds value to another or depends on it in any other way, it’s most certainly downstream.