Blog
  • AI Gateway
  • AI Security
  • AIOps
  • API Security
  • API Gateway
|
    • API Management
    • API Development
    • API Design
    • Automation
    • Service Mesh
    • Insomnia
    • View All Blogs
  1. Home
  2. Blog
  3. Engineering
  4. Set API Bandwidth Limits With This Hackathon Award-Winning Plugin
Engineering
December 21, 2021
3 min read

Set API Bandwidth Limits With This Hackathon Award-Winning Plugin

Narendra Patel
Topics
AutomationPlugins
Share on Social

More on this topic

Videos

Make it Easy: Automating Tests and Deployment of Custom Plugins

Videos

Leveraging Kong for Secure Healthcare Interoperability

See Kong in action

Accelerate deployments, reduce vulnerabilities, and gain real-time visibility. 

Get a Demo

This year, we hosted our inaugural Kong Summit Hackathon. This virtual competition engaged our open source community and offered recognition and prizes for hacks in various categories. The community delivered with ingenious plugins, hacks and documentation.

This blog post highlights our Kong Gateway plugin winner, Narendra Patel. Narendra is a senior DevOps engineer at Egnyte with close to 10 years of experience as a developer, DevOps engineer, SRE and in RPA (robotics process automation). See Narendra's API bandwidth limit plugin on GitHub, and look into his thought process for creating this plugin below.

Interested in participating in next year’s Hackathon? Sign up for updates here.

Bandwidth pricing is a major component of the cloud services model. And for a content-heavy service like a video or document store, egress costs can quickly spiral out of control. To mitigate this, it is important to limit the amount of data that can be downloaded in a given interval. However, bandwidth limiting for a multi-tenant SaaS product adds a few interesting challenges.

At Egnyte, we deal with petabytes of data, and as such, we must keep a close eye on bandwidth consumption. Cloud services need protection against sudden high volume spikes or brute force attempts.

We consolidated our needs into one comprehensive bandwidth limiting plugin to address this issue internally. And now, we have open sourced the bandwidth rate limiter because we believe this is a common problem, and our solution applies to a lot of content-heavy services.

The download rate limiter plugin includes the following capabilities:

  • Rate limiting based on bandwidth consumption
  • Configurable per customer, user or entity
  • Able to filter specific requests in or out
  • Allows limit extensions on weekends
  • Configurable jitter

How the Rate Limiter Works

Our plugin, developed on Kong Gateway (OSS), helps you define per-day download limits on your APIs, which ultimately helps avoid runaway egress fees. You can configure it to filter specific requests or APIs, extract user-defined headers and enforce limits based on custom rules. It can also rate limit/throttle requests based on bandwidth consumption per user, customer or custom entity on a daily consumption basis.

See the Kong documentation for more information on using Kong Gateway and its plugins.

Here is a sample configuration using the plugin:

The configuration instructs Kong Gateway to:

  • Rate limit whenever we have an incoming request with the header set as "X-Domain" (configurable) with a value of test and request URI beginning with /mock/200.
  • Set the limit threshold to 1,000 bytes; an extension of 20% is allowed on weekends, with a max jitter of 10%.
  • Exclude from rate limiting all requests with "X-Domain" as test and "X-Header" as bypass.
  • Make all requests with "X-Domain" as test and "X-Agent" as limit eligible for rate limiting.

Once the set threshold of 1,000 bytes is breached, the plugin would start rate limiting the requests with the HTTP 429 error response status code.

We designed the plugin with considerations for performance and monitoring. And since we built it on OSS, it can be used by everyone.

Check out the plugin here. The GitHub repository contains a detailed description, along with a configuration example to walk you through the setup.

See the API Bandwidth Limit Plugin in Action

I demoed how the plugin works at a Kong user call. Check out the full video below (or on YouTube).

Have questions or want to stay in touch with the Kong community? Join us wherever you hang out:

⭐ Star us on GitHub

🐦 Follow us on Twitter

🌎 Join the Kong Community

🍻 Join our Meetups

❓ ️Ask and answer questions on Kong Nation

💯 Apply to become a Kong Champion

Topics
AutomationPlugins
Share on Social
Narendra Patel

Recommended posts

Semantic Processing and Vector Similarity Search with Kong and Redis

Kong Logo
EngineeringApril 29, 2025

Kong has supported Redis since its early versions. In fact, the integration between Kong Gateway and Redis is a powerful combination to enhance API management. We can summarize the integration points and use cases of Kong and Redis into three main g

Claudio Acquaviva

Terraform Your Way to the Cloud with Konnect Dedicated Cloud Gateways

Kong Logo
EngineeringApril 16, 2025

Automate Everything: Kong Gateway + API Management with Terraform Across Any Cloud Too many organizations manually manage their API gateways and policy enforcement today. As humans, we make mistakes. You’ve got one team manually configuring Kong or

Declan Keane

Implementing OpenTelemetry Observability with Kong Konnect & Dynatrace

Kong Logo
EngineeringApril 9, 2025

Observability has become critical to ensuring the effective monitoring of application and system performance and health. It focuses on understanding a system’s internal state by analyzing the data it produces in the context of real-time events and a

Claudio Acquaviva

Kong Konnect Observability and Analytics with Dynatrace

Kong Logo
EngineeringApril 7, 2025

Understanding and monitoring the performance and health of applications and systems is critical. This is where observability comes into play. Observability is about gaining a comprehensive understanding of a system's internal state by analyzing the

Claudio Acquaviva

How to Track Service Level Objectives with Kong and OpenTelemetry

Kong Logo
EngineeringFebruary 6, 2025

In this blog post, we will explore how organizations can leverage Kong and OpenTelemetry to establish and monitor Service Level Objectives (SLOs) and manage error budgets more effectively. By tracking performance metrics and error rates against pred

Sachin Ghumbre

Exposing and Controlling Apache Kafka® Data Streaming with Kong Konnect and Confluent Cloud

Kong Logo
EngineeringNovember 19, 2024

We announced the Kong Premium Technology Partner Program at API Summit 2024, and Confluent was one of the first in the program. This initial development was all about ensuring that the relationship between Kong and Confluent — from a business an

Claudio Acquaviva

How to Manage Your API Policies with OPA (Open Policy Agent)

Kong Logo
EngineeringOctober 18, 2024

APIs are essential to modern applications, but managing access and security policies can be complex. Traditional access control mechanisms can fall short when flexible, scalable, and fine-grained control over who can access specific resources is nee

Sven Bernhardt

Ready to see Kong in action?

Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.

Get a Demo
Powering the API world

Increase developer productivity, security, and performance at scale with the unified platform for API management, AI gateways, service mesh, and ingress controller.

Sign up for Kong newsletter

    • Platform
    • Kong Konnect
    • Kong Gateway
    • Kong AI Gateway
    • Kong Insomnia
    • Developer Portal
    • Gateway Manager
    • Cloud Gateway
    • Get a Demo
    • Explore More
    • Open Banking API Solutions
    • API Governance Solutions
    • Istio API Gateway Integration
    • Kubernetes API Management
    • API Gateway: Build vs Buy
    • Kong vs Postman
    • Kong vs MuleSoft
    • Kong vs Apigee
    • Documentation
    • Kong Konnect Docs
    • Kong Gateway Docs
    • Kong Mesh Docs
    • Kong AI Gateway
    • Kong Insomnia Docs
    • Kong Plugin Hub
    • Open Source
    • Kong Gateway
    • Kuma
    • Insomnia
    • Kong Community
    • Company
    • About Kong
    • Customers
    • Careers
    • Press
    • Events
    • Contact
    • Pricing
  • Terms
  • Privacy
  • Trust and Compliance
  • © Kong Inc. 2025