Create Consumer Groups in Konnect
With consumer groups, you can define any number of rate limiting tiers and apply them to subsets of consumers, instead of managing each consumer individually.
For example, you could define three consumer groups:
- gold tier with 1000 requests per minute
- silver tier with 10 requests per second
- bronze tier with 6 requests per 30 seconds
The consumer_groups
endpoint works together with the Rate Limiting Advanced plugin.
Consumers that are not in a consumer group default to the Rate Limiting advanced plugin’s configuration, so you can define tier groups for some users and have a default behavior for consumers without groups.
To use consumer groups for rate limiting, you must:
- Create a consumer group and create or add consumers to it
- Configure the Rate Limiting Advanced plugin globally with the
enforce_consumer_groups
andconsumer_groups
parameters, setting up the list of consumer groups that the plugin accepts - Configure a rate limiting policy for each consumer group, overriding the plugin’s global configuration
This tutorial will walk through creating a bronze tier consumer group that allows consumers in the group to make five requests every 30 seconds.
Create a consumer
In this section, you will create a consumer.
- From the Konnect sidebar, open the Gateway Manager section.
- Select the default control plane.
- Open the Consumers tab, click Add consumer, and enter the following consumer information into the form:
- Username: Amal
- Custom ID: Amal
Assign a consumer to a consumer group
In this section, you will assign the consumer you just created to the Bronze tier consumer group.
- From the Gateway Manager section in the default Konnect workspace, open the Consumers tab.
- Click the Consumer Groups tab, and then click Add Consumer Group.
- Enter “Bronze” for the consumer group name and select the “Amal” consumer you just created from the drop-down.
- Click Create.
Configure the Rate Limiting Advanced plugin for all consumers
In this section, you will configure the Rate Limiting Advanced plugin to set the rate limit to 5 requests every 30 seconds for all consumers.
- In Konnect, click Gateway Manager in the sidebar.
- Click the default control plane.
- From the menu, open Plugins, then click Add plugin.
- Find the Rate Limiting plugin, then click Select.
-
Apply the plugin as Global This means the rate-limiting applies to all requests, including every service and route in the workspace.
If you switched it to Scoped, the rate limiting would apply the plugin to only one service, route, or consumer.
By default, the plugin is automatically enabled when the form is submitted. You can also toggle the This plugin is Enabled button to configure the plugin without enabling it. For this example, keep the plugin enabled.
- Complete only the following fields with the following parameters:
- Config.limit: 5
- Config.window_size: 30
- Config.window_type: Sliding
- Config.retry_after_jitter_max: 0
- Config.enforce_consumer_groups: true
- Config.consumer_groups: Bronze
Besides the above fields, there may be others populated with default values. For this example, leave the rest of the fields as they are.
- Click Save.
Configure rate limiting for consumer groups
In this section, you will configure the Rate Limiting Advanced plugin to set the rate limit to 6 requests every 30 seconds only for consumers in the Bronze tier.
- In Konnect, click Gateway Manager in the sidebar.
- Select the default control plane.
- From the menu, open Consumers, then click the Consumer Groups tab.
- Click the Bronze consumer group you just created.
- Click Add Configuration.
- In the dialog, complete only the following fields with the following parameters:
- Window Size: 30
- Window Type: Sliding
- Limit: 6
- Retry After Jitter Max: 0
- Click Save.
You have now set up a Bronze tier consumer group with one consumer, Amal, assigned to the group. Whenever the consumer Amal sends requests, they can make up to six requests every 30 seconds before hitting the rate limit. All other consumers are limited to only five requests every 30 seconds.