(One of my summaries of the 2024 Dutch PyGrunn python&friends conference in Groningen, NL).
Note: it is “kraken d” not “kraken”: https://www.krakend.io/ .
From monolith to services: you have an application plus webclient. Then you add a mobile client. Suddenly you need an extra subscription service. And then a third party frontend needs to call your backend. And then you write a newer version of your first application… Lots of connections between the various parts.
The solution: put an API gateway in between. All the frontends call the gateway, the gateway calls all the backend applications.
If you have one gateway, that’s immediately a good place to handle some common functionality: auhthentication/authorization, logging/monitoring, load balancing, service discovery, response transformation, caching, throttling, circuit breaking, combining backend responses.
What they ended up with was krakenD. Open source. It provides a lot of middleware out of the box. Lots of plugins.
What krakenD suggests is that you have a gateway per frontend, so tailored to the use case.
There’s an online GUI to allows you to edit the configuration through a web interface. It is handy for exploring what’s on offer and to play with the system and to figure out how it works. (In production, you of course don’t want to do manual changes).
Tip: use the flexible configuration that krakenD allows. The regular single
krakend.json
file can get pretty big, so krakenD has support for configuration
templates, environment variable files. KrakenD cna than compile the various files into
one config file.
Even then, maintaining the configuration can be a challenge. If you have multiple
gateways, especially. Well, you can generate part of the configuration with python
scripts. Reading some openapi.json
and turning it into your preferred kind of
config.
Useful: there’s a check
command that will check your configuration for syntax errors
and an audit
command for improving your configuration regarding security and best
practices.
From the krakend config file, you can generate an openapi spec which you can then give to swagger to have nice online documentation for your API gateway.
He thinks it is a great tool to manage your APIs. It is lightweight and fast and simple to configure. Lots of functionality out of the box. Versatile and extensible. And… it makes your software architecture more agile.
Drawbacks: you need to manage the API gateway config, which is an extra step. And changing the config requires a restart.
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):