Choosing API Gateway
Recently we’ve started working on an experimental internal project based on microservices principles. We’ve broken down our application into contexts using several event storming sessions, defined events, commands and aggregates. When it all took shape, we sat and started working on services.
Two months into development I went talking to the frontend team only to find that they would be more than happy to see a single entry point into API.
API Gateways many nice sides. They let one decouple API from the actual services realizing these functions, handle authentication and authorization, cache, throttle and much more. The cost of it is a possible bottleneck where all your application depends on one single entry point. If it’s slow, down or malfunctioning, your app is doomed.
Some years ago there were no such thing as boxed API Gateway. Now we have them and writing our own makes very little sense. In most cases there’s one right for your use case.
With all these thoughts I went shopping and found three projects I liked the most:
- Tyk - Cloud Native API Management for the modern stack
- Kong - Cloud Native API Management for the modern stack
- Krakend - The fastest API gateway comes with true linear scalability
Of all these three I had a play with the last two and (for now) chosen Krakend for the serveral nice things it has to offer:
- It’s written in Go and being both small and ultra-fast,
- It supports lots of actions (processing requests and responses) declaratively,
- It has a scripting option with Lua,
- Can be extended with Go plugins easily,
- Community Edition of Krakend is OSS and free for use.
But what really drew my attention was the ability to use multiple underlying services return data for one request from the client. Krakend runs thse requests concurrently or sequentially and merges results when they are ready. To my knowledge, none of the other two allow that. On top of that, it lets you use abovementioned scripts / plugins to alter requests and responses individually. (I’ll talk more about that in my next post.)
We are at the very beginning of our way with it, but I am pretty happy with what Krakend brings to the table. We’ll see how it goes.