Create Consumer Groups in Kong Manager

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:

  • A “gold tier” with 1000 requests per minute
  • A “silver tier” with 10 requests per second
  • A “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 need to:

  • Create one or more consumer groups
  • Create consumers
  • Assign consumers to groups
  • Configure the Rate Limiting Advanced plugin globally with the enforce_consumer_groups and consumer_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

For all possible requests, see the Consumer Groups reference.

Set up a consumer group with consumers

In this section, you will create the Bronze tier consumer group with a consumer assigned to the group.

  1. Open the default workspace.
  2. From the menu, open Consumers, then click the Groups tab.
  3. Click New Consumer Groups.
  4. Enter Bronze for the consumer group name and click Create.
  5. From the menu, click Consumers, then click New Consumer.
  6. Enter a Username and Custom ID. For this example, you can use Amal for each field.
  7. Click Create.
  8. From the menu, click the Groups tab.
  9. Click the Bronze consumer group you just created.
  10. Click Consumers and Add consumers to add the Amal consumer you created to the Bronze consumer group.

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.

  1. Open the default workspace.
  2. From the menu, open Plugins, then click Install Plugin.
  3. Find the Rate Limiting plugin, then click Enable.
  4. Apply the plugin as Global, which 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.

  5. Complete only the following fields with the following parameters.

    1. config.limit: 5
    2. config.window_size: 30
    3. config.window_type: sliding
    4. config.retry_after_jitter_max: 0
    5. config.enforce_consumer_groups: true
    6. 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.

  6. Click Install.

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.

  1. Open the default workspace.
  2. From the menu, open Consumers, then click the Groups tab.
  3. Click the Bronze consumer group you just created.
  4. Click the Policy tab.
  5. Complete only the following fields with the following parameters.
    1. config.limit: 6
    2. config.window_size: 30
    3. config.window_type: sliding
    4. config.retry_after_jitter_max: 0
  6. Click Save.