跳至主内容
版本:4.3

用户级资源限制

概述

虚拟主机(vhost)资源限制类似,您可以限制特定用户可以打开的连接数和通道数。

在应用程序不可信或无法进行详细监控的环境中(例如将 RabbitMQ 集群作为服务提供时),这些限制可用作防护措施。

这些限制可以通过 CLI 工具或 HTTP API 进行配置。

最大连接数

要限制用户可以打开的连接数,请将 max-connections 限制设置为一个正整数

rabbitmqctl set_user_limits user1 '{"max-connections": 10}'

最大通道数

要限制用户总共可以打开的通道数,请将 max-channels 限制设置为一个正整数

rabbitmqctl set_user_limits guest '{"max-connections": 10, "max-channels": 20}'

该限制适用于用户打开的所有连接中的通道总数。因此,它必须大于或等于上述的最大连接数限制。

列出用户限制

要列出特定用户的限制

rabbitmqctl list_user_limits user1

清除用户限制

要清除用户的限制,请使用 CLI 工具或 HTTP API

# clears the maximum number of connections limit
rabbitmqctl clear_user_limits user1 'max-connections'

# clears the maximum number of channels limit
rabbitmqctl clear_user_limits user1 'max-channels'

# clears all limits in a single operation
rabbitmqctl clear_user_limits user1 all
© . This site is unofficial and not affiliated with VMware.