• The API Platform for AI.

      Explore More
      Platform Runtimes
      Kong Gateway
      • Kong Cloud Gateways
      • Kong Ingress Controller
      • Kong Operator
      • Kong Gateway Plugins
      Kong AI Gateway
      Kong Event Gateway
      Kong Mesh
      Platform Core Services
      • Gateway Manager
      • Mesh Manager
      • Service Catalog
      Platform Applications
      • Developer Portal
      • API and AI Analytics
      • API Products
      Development Tools
      Kong Insomnia
      • API Design
      • API Testing and Debugging
      Self-Hosted API Management
      Kong Gateway Enterprise
      Kong Open Source Projects
      • Kong Gateway OSS
      • Kuma
      • Kong Insomnia OSS
      • Kong Community
      Get Started
      • Sign Up for Kong Konnect
      • Documentation
    • Featured
      Open Banking SolutionsMobile Application API DevelopmentBuild a Developer PlatformAPI SecurityAPI GovernanceKafka Event StreamingAI GovernanceAPI Productization
      Industry
      Financial ServicesHealthcareHigher EducationInsuranceManufacturingRetailSoftware & TechnologyTransportation
      Use Case
      API Gateway for IstioBuild on KubernetesDecentralized Load BalancingMonolith to MicroservicesObservabilityPower OpenAI ApplicationsService Mesh ConnectivityZero Trust SecuritySee all Solutions
      Demo

      Learn how to innovate faster while maintaining the highest security standards and customer trust

      Register Now
  • Customers
    • Documentation
      Kong KonnectKong GatewayKong MeshKong AI GatewayKong InsomniaPlugin Hub
      Explore
      BlogLearning CentereBooksReportsDemosCase StudiesVideos
      Events
      API SummitWebinarsUser CallsWorkshopsMeetupsSee All Events
      For Developers
      Get StartedCommunityCertificationTraining
    • Company
      About UsWhy Kong?CareersPress RoomInvestorsContact Us
      Partner
      Kong Partner Program
      Security
      Trust and Compliance
      Support
      Enterprise Support PortalProfessional ServicesDocumentation
      Press Release

      Kong Expands with New Headquarters in Downtown San Francisco

      Read More
  • Pricing
  • Login
  • Get a Demo
  • Start for Free
Blog
  • Engineering
  • Enterprise
  • Learning Center
  • Kong News
  • Product Releases
    • API Gateway
    • Service Mesh
    • Insomnia
    • Kubernetes
    • API Security
    • AI Gateway
  • Home
  • Blog
  • Engineering
  • 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

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:Automation
|
Plugins
Powering the API world

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

Sign up for Kong newsletter

Platform
Kong KonnectKong GatewayKong AI GatewayKong InsomniaDeveloper PortalGateway ManagerCloud GatewayGet a Demo
Explore More
Open Banking API SolutionsAPI Governance SolutionsIstio API Gateway IntegrationKubernetes API ManagementAPI Gateway: Build vs BuyKong vs PostmanKong vs MuleSoftKong vs Apigee
Documentation
Kong Konnect DocsKong Gateway DocsKong Mesh DocsKong AI GatewayKong Insomnia DocsKong Plugin Hub
Open Source
Kong GatewayKumaInsomniaKong Community
Company
About KongCustomersCareersPressEventsContactPricing
  • Terms•
  • Privacy•
  • Trust and Compliance
  • © Kong Inc. 2025