DEV Community

Cover image for What API Gateway to choose: Kong, Gravitee, Tyk or HAProxy?
Mel♾️☁️
Mel♾️☁️

Posted on • Originally published at softwaresennin.io

What API Gateway to choose: Kong, Gravitee, Tyk or HAProxy?

API Gateways are becoming increasingly popular since they allow you to have a single component handle authentication rather than coding it numerous times, manage CORS, and so on. However, selecting the one that best fits your situation is a difficult challenge.

APIGateway

Today, we'll analyse four API gateway options and weigh their advantages and disadvantages. I'll be comparing four different API Gateways: Kong, Gravitee, Tyk, and HAProxy.

Kong

Kong

Kong is Open Source API Gateway in coded in Lua and Perl since 2017 by Kong Inc. Kong API Gateway is an open source solution, while Kong Enterprise is an enterprise version that includes additional tools around the gateway, such as dashboards and monitoring tools.

Architecture

Architecture

Kong just requires PostgreSQL to keep its configurations and may be installed in a variety of setups and operating systems.

Kong, as seen in the architecture plan, includes a plugin element. That is his most significant advantage: Kong Inc. and its community (over 20k stars on GitHub) are creating plugins for practically anything you might possibly need: authentication, logging, monitoring, rate restriction, and so on. The community is vibrant, and Kong is rapidly evolving. Furthermore, Kong is simple to comprehend and deploy: it takes only 1 hour for someone who has never used it before, less if you are familiar with it, and a few minutes for a custom install script.

Performances

Even with a large number of connections, Kong requires less than 300MB of RAM to run. On the contrary, it requires CPU, therefore raising your CPU count would improve its performance. Kong can scale horizontally since the API Gateway is stateless and the database is one-of-a-kind. It means that when you make a change, it affects every gateway connected to the database. The horizontal scaling is really effective: I emphasise this because it is not true for every solution.

Because of the various plugins, Kong can meet practically any demand, and the community is a strong point.

Gravitee

Gravitee

Gravitee is a Java-based open-source API gateway developed by Gravitee Source since January 2015. The system is more sophisticated than Kong, relying on three apps. The first two are components of the Management block: the portal is an Angular front that interacts with the Management API to manage the Gateway's configuration. The configuration is saved in MongoDB and used by the third app - the Gateway.

Architecture

Architecture

The dashboard is one of Gravitee's advantages: it is clean, easy to grasp for a developer, and manages everything you can do with Gravitee (routes, authentication, alerting, and so on). Gravitee has less features than Kong, but if you don't have unusual requirements, it will suffice.

The installation and documentation are the most difficult aspects of Gravitee. The first time you install it, you may struggle because the approach is unclear; you must install at least three components, including a MongoDB and possibly an ElasticSearch. Searching for troubleshooting in the documentation is difficult, and there isn't much activity because the community is small (about 1k stars on GitHub).

Performances

Gravitee, unlike other API Gateways, requires RAM (as is typical for Java applications). If you don't want your Gateway to interfere with your Management API, you must run it on a separate machine. If you wish to manage a large number of connections, each Gateway requires at least 4GB of Java heap. Horizontal scaling is effective, but vertical scaling is considerably more so (when CPU and RAM are increased, performance increases significantly). It should be noted that the performance of this method is really outstanding once the Gateway uses the RAM.

Gravitee is difficult to install but provides excellent performance and a comprehensive interface.

Tyk

Tyk

Tyk.io is an Open Source API Gateway created in Go since 2014 by Tyk Technologie. Gravitee needs three processes to execute, on the other hand Tyk also requires a Redis and a MongoDB.

The 3 apps are the gateway, the dashboard, and the pump, which pulls data from Redis and injects it into MongoDB.

Architecture

Architecture

The dashboard is the solution's strong point. As a developer, you can do nearly anything with it (alerting, rate-limiting, update requests, and so on) and the user interface is simple.

It takes longer to setup than Kong because you must set up a Redis and a MongoDB, but the documentation is nicely written, so you should have no problems with the three elements of the programme. The community is small (5k stars on GitHub), therefore there aren't many issues, but the support is responsive and eager to assist you: don't hesitate to contact them if you need anything.

Performances

Tyk does not require much RAM (less than 250 Mo), but it requires a lot of CPU. Scaling vertically and horizontally improves performance, but let's get right to the point: Tyk's performance is his Achilles' heel. According to the documentation, the maximum capacity is 4000 requests/sec, which is significantly lower than the other alternatives. I ran performances tests on over 4000 requests and the solution couldn't keep up.

To summarise, Tyk can be a fantastic API Gateway with a comprehensive and user-friendly interface providing your traffic does not exceed its specifications.

HAProxy

HAProxy

HAProxy is a free and open source solution written in Lua and C. HAProxy differs from the previous solutions in that it is designed to be a load balancer rather than an API Gateway, but it can be utilised as such. The architecture is straightforward: there is just one process to start, which reads a configuration file when it boots up.

Architecture

Architecture

Because HAProxy's primary purpose is not to be an API Gateway, the solution lacks a comprehensive interface for managing API Gateway functions. HAProxy, on the other hand, is aware of this flaw and is developing a dashboard to address it.

Not every basic function is available (for example, OpenId authentication), but the majority of them are if you add plugins or code from their website. If a feature is missing, you can write it in Lua using the extremely adjustable configuration file.

The installation is the easiest, the documentation is comprehensive, and the community and support are both excellent.

Performances

The essential element of this approach is its performance: it utilises fewer resources (CPU and RAM) than the others to achieve better results. It appears normal when we consider that HAProxy's original usage is as a load balancer, and its reputation is not to make. It can be scaled horizontally and vertically as well.

If you already use HAProxy as a load balancer, you already know how it works and have already created a configuration in Lua, so adding an authentication setting will be easier for you.

Here's an example of a recapitulative array:

Recap Array

Kong is the best choice for most of your use cases, but alternative API Gateways may be more appropriate based on your situation:

  • HAProxy - If you already use HAProxy as a load balancer,
  • Tyk - If your traffic is less than 4000 connections per second
  • Gravitee - If you prefer a no-plugins solution and are experienced with the JVM.

Of course, there are additional API Gateways you may utilise, and I've only scratched the surface, so if you have any suggestions, please share them with us!

Wrap-Up

Kudos for getting all the way to the end of this article.

Stay tuned :) Feel free to reach out should you have any questions.

YouAreAwesome #StayAwesome

Article posted using bloggu.io. Try it for free.

Top comments (0)