DEV Community

Cover image for Web Services 101: The client is downstream, the service is upstream
scottshipp
scottshipp

Posted on • Edited on

10 1

Web Services 101: The client is downstream, the service is upstream

Sometimes I read a conversation between two devs online or I overhear one while filling up my water bottle that goes something like this:

Dev 1:

"I think there's something wrong with the downstream service. It keeps timing out so we keep sending 500's to our clients and it's becoming a big issue."

Dev 2:

"That service actually talks to like four others to return the response. I bet its some issue even further downstream."

This usage of "downstream" is actually wrong, and this is not a subjective observation.

What does up/downstream actually mean?

In web services, upstream and downstream are actually defined by the HTTP specification as follows:

upstream/downstream

Upstream and downstream describe the flow of a message: all messages flow from upstream to downstream.

In other words, in any HTTP interaction, the requesting service is downstream. The service responding is upstream.

This isn't just a random definition thrown into the opening portion of the specification and then ignored thereafter, either. You will find this specific usage of up/downstream throughout the specification. Consider the definition of a 504 Gateway Timeout response for example:

The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.

You will also find the same usage in documentation for things like nginx.

To visualize this, consider a series of service calls initiated by some external client, as follows:

client -> service A -> service B -> service C
Enter fullscreen mode Exit fullscreen mode

The above is the request flow, but the response flow is:

client <- service A <- service B <- service C
Enter fullscreen mode Exit fullscreen mode

The response flow is the flow that is the basis for "upstream" and "downstream" in web services.

For another take on this, check out this old Stack Overflow question.

Hope it helps!

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed
  • 2:34 --only-changed
  • 4:27 --repeat-each
  • 5:15 --forbid-only
  • 5:51 --ui --headed --workers 1

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video 📹️

Top comments (1)

Collapse
 
soongle profile image
SOONG-E • Edited

thanks for good post ~ _ ~

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay