DEV Community

Discussion on: Explain API gateway to me like I’m five

Collapse
 
kayis profile image
K

An API gateway is like a supermarket.

You could go to a farmer and buy vegetables and go to a bakery to buy bread, but you could also simply go to a supermarket and buy both.

The supermarket doesn't make these things, it just gives it to you after it bought them from a producer.

An API gateway doesn't make data, it just gives it to you after it got them from a microservice.

Collapse
 
190245 profile image
Dave

Quite possibly the best definition I've heard/read.

Maybe add in something about rate limiting/smoothing though (like the farmers etc having a set quota every month thanks to bulk purchase from the supermarket), but then you're probably talking to a 14 year old, rather than a 5 year old.

Collapse
 
kayis profile image
K

In Germany we have some laws for rate limiting.

You are not allowed to buy bulk (unreasonable amounts for one household) from a supermarket, only from bulk traders.

But in practice nobody follows them, because its really rare that someone buys all pizzas. (I did once, haha)

Thread Thread
 
190245 profile image
Dave

We have similar in the UK, especially thanks to Covid restrictions.

What I meant though, was that the individual farmers/bakers/etc are protected from spikes & low periods in demand, by the supermarket doing bulk orders with each supplying service, and caching (effectively) the products. Simultaneously, the customers can buy the products they need near instantly, no need to wait for a cow to grow, in order to get milk, etc.

Switching to microservice terminology for a moment, rate limiting at the gateway allows you to decide if each microservice should live in an EC2, or a Lambda (etc), because of the load profile. There's no point paying for an EC2 if you have large periods of inactivity, and equally, if your load is always constant, Lambda's probably won't save you much money (in fact, more often than not, it'd be more expensive).

Rate limits can also be used to help with scalability - eg, if there's too many customers, the supermarket can open more checkouts to serve more customers in parallel.