Cloud Native 10 min read

Introduction to Kong API Gateway: Features, Deployment, and Configuration

This article introduces Kong, a cloud‑native API gateway, outlines its key features such as high performance, plugin architecture, and traffic control, explains why it solves common microservice challenges, and provides detailed deployment, clustering, plugin development, and troubleshooting guidance with practical code examples.

360 Tech Engineering
360 Tech Engineering
360 Tech Engineering
Introduction to Kong API Gateway: Features, Deployment, and Configuration

What is Kong

Kong is a next‑generation API gateway platform designed for modern architectures (hybrid cloud, hybrid organization). It is cloud‑native, high‑performance, easy to use, and extensible, suitable for API Gateway, Kubernetes Ingress, and Service Mesh sidecar scenarios.

Main Features

Cloud‑Native : Runs on bare metal to Kubernetes.

High Performance : Built on non‑blocking Nginx.

Plugin Mechanism : Offers many ready‑to‑use plugins and a Lua‑based custom plugin interface.

Circuit Breaking : Prevents system avalanche via plugins.

Logging : Records HTTP, TCP, UDP requests and responses.

Authentication : Supports HMAC, JWT, Basic, OAuth 2.0, etc.

Rate Limiting : Controls traffic per service.

SSL : Configurable SSL certificates.

Monitoring : Real‑time monitoring plugins.

Dynamic Routing : Inherits OpenResty+Lua dynamic routing.

Why Use Kong

It addresses common microservice problems such as the lack of a unified entry point for authentication, rate limiting, and logging; improves usability and extensibility during migration from LNMP to Spring Boot/Spring Cloud stacks; and supports continuous integration, blue‑green deployments, and hot‑reloading.

How We Use Kong

All nodes connect to a central data center using PostgreSQL master‑slave for high availability. Nodes periodically sync data (default every 5 seconds) and maintain local caches (default TTL 0 seconds) to ensure service continuity during database failures. The cluster can be dynamically scaled behind an LVS load balancer, with nodes added or removed by updating the LVS pool.

gRPC Support

# /etc/kong/kong.conf
proxy_listen = 0.0.0.0:8000, 0.0.0.0:8443 ssl, 0.0.0.0:9080 http2

Service Monitoring

Kong integrates natively with Prometheus and Grafana for real‑time metrics.

Kong Plugins

Kong provides many built‑in plugins (authentication, rate limiting, logging, etc.) and allows custom Lua plugins. After development, plugins are placed in the Lua package path and enabled via the plugins configuration.

# Create an upstream named "hello"
curl -X POST http://localhost:8001/upstreams --data "name=hello"
# Add two load‑balancing targets
curl -X POST http://localhost:8001/upstreams/hello/targets --data "target=localhost:8080" --data "weight=100"
curl -X POST http://localhost:8001/upstreams/hello/targets --data "target=localhost:8081" --data "weight=100"
# Create a service
curl -X POST http://localhost:8001/services --data "name=hello" --data "host=hello"
# Configure a route for the service
curl -X POST http://localhost:8001/routes --data "paths[]=/hello" --data "service.id={$service.id}"

Custom Plugin Development

A simple plugin consists of handler.lua and schema.lua. The handler extends BasePlugin and implements lifecycle functions such as access and body_filter.

local BasePlugin = require "kong.plugins.base_plugin"
local access = require "kong.plugins.my-custom-plugin.access"
local body_filter = require "kong.plugins.my-custom-plugin.body_filter"

local CustomHandler = BasePlugin:extend()

function CustomHandler:new()
    CustomHandler.super.new(self, "my-custom-plugin")
end

function CustomHandler:access(config)
    CustomHandler.super.access(self)
    access.execute(config)
end

function CustomHandler:body_filter(config)
    CustomHandler.super.body_filter(self)
    body_filter.execute(config)
end

return CustomHandler

The schema defines configuration fields and validation logic.

return {
    no_consumer = true,
    fields = {},
    self_check = function(schema, plugin_t, dao, is_updating)
        return true
    end
}

After placing the plugin files (e.g., /data/kong/plugins/simple-plugin/) and updating kong.conf with lua_package_path = /data/?.lua;($default); and plugins = bundled,simple-plugin, reload Kong to load the new plugin.

Troubleshooting

Increase Nginx buffers for large upstream responses:

nginx_proxy_proxy_buffer_size=128k
nginx_proxy_proxy_buffers=4 256k
nginx_proxy_proxy_busy_buffers_size=256k

Be aware of strip_path and preserve_host attributes when configuring routes.

Conclusion

Kong is a mature open‑source gateway that excels in performance, usability, and extensibility, making it an effective tool for service governance, including graceful degradation, circuit breaking, and traffic routing across complex hybrid cloud environments.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeMicroservicesKubernetesapi-gatewayLuaKongPlugin Development
360 Tech Engineering
Written by

360 Tech Engineering

Official tech channel of 360, building the most professional technology aggregation platform for the brand.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.