An API gateway is an entry point for clients who want to use your API. It can then route the incoming requests into a specific instance or cluster of services. This can simplify your client code, as it no longer needs to know all the backend nodes, or how they cooperate with each other. All a client needs to know is the address of an API gateway — the gateway will handle the rest. Thanks to hiding the backend architecture from the client, it can be easily remodeled without even touching the client's code.
The gateway can aggregate multiple parts of your system's API into one, and then use layer-7 routing (for example, based on the URL) to a proper part of your system. Layer-7 routing is offered by both cloud providers themselves, as well as tools such as Envoy.
As with many patterns described in this chapter, always consider whether it's worth it to add more complexity by introducing another pattern to your architecture. Think about how adding it will...