Skip to content

Commit

Permalink
Add support for total connections limit per vhost level
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinmay1412 committed Jul 21, 2022
1 parent 376179d commit 05c75ef
Show file tree
Hide file tree
Showing 18 changed files with 1,175 additions and 67 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ DATACENTER SET name | PRINT
EXIT Exit the program gracefully.
FARM (ADD name selector backend* | PARTITION name policy | DELETE name | PRINT) - Change farms
HELP Print this help text.
LIMIT (CONN_RATE_ALARM | CONN_RATE) (VHOST vhostName numberOfConnections | DEFAULT numberOfConnections) - Configure connection rate limits (normal or alarmonly) for incoming clients connections
LIMIT (CONN_RATE_ALARM | CONN_RATE) (DEFAULT | VHOST vhostName) numberOfConnections - Configure connection rate limits (normal or alarmonly) for incoming clients connections
LIMIT (TOTAL_CONN_ALARM | TOTAL_CONN) (DEFAULT | VHOST vhostName) numberOfConnections - Configure total connection limits or alarms for incoming client connections
LIMIT (DATA_RATE_ALARM | DATA_RATE) (DEFAULT | VHOST vhostName) BytesPerSecond - Configure data rate limits or alarms for incoming client data
LIMIT DISABLE (CONN_RATE_ALARM | CONN_RATE | DATA_RATE_ALARM | DATA_RATE) (VHOST vhostName | DEFAULT) - Disable configured limit thresholds
LIMIT DISABLE (CONN_RATE_ALARM | CONN_RATE | TOTAL_CONN_ALARM | TOTAL_CONN | DATA_RATE_ALARM | DATA_RATE) (VHOST vhostName | DEFAULT) - Disable configured limit thresholds
LIMIT PRINT [vhostName] - Print the configured default or specific connection rate limits for specified vhost
LISTEN START port | START_SECURE port | STOP [port]
LOG CONSOLE verbosity | FILE verbosity
Expand Down
35 changes: 30 additions & 5 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ DATACENTER SET name | PRINT
EXIT Exit the program gracefully.
FARM (ADD name selector backend* | PARTITION name policy | DELETE name | PRINT) - Change farms
HELP Print this help text.
LIMIT (CONN_RATE_ALARM | CONN_RATE) (VHOST vhostName numberOfConnections | DEFAULT numberOfConnections) - Configure connection rate limits (normal or alarmonly) for incoming clients connections
LIMIT (CONN_RATE_ALARM | CONN_RATE) (DEFAULT | VHOST vhostName) numberOfConnections - Configure connection rate limits (normal or alarmonly) for incoming clients connections
LIMIT (TOTAL_CONN_ALARM | TOTAL_CONN) (DEFAULT | VHOST vhostName) numberOfConnections - Configure total connection limits or alarms for incoming client connections
LIMIT (DATA_RATE_ALARM | DATA_RATE) (DEFAULT | VHOST vhostName) BytesPerSecond - Configure data rate limits or alarms for incoming client data
LIMIT DISABLE (CONN_RATE_ALARM | CONN_RATE | DATA_RATE_ALARM | DATA_RATE) (VHOST vhostName | DEFAULT) - Disable configured limit thresholds
LIMIT DISABLE (CONN_RATE_ALARM | CONN_RATE | TOTAL_CONN_ALARM | TOTAL_CONN | DATA_RATE_ALARM | DATA_RATE) (VHOST vhostName | DEFAULT) - Disable configured limit thresholds
LIMIT PRINT [vhostName] - Print the configured default or specific connection rate limits for specified vhost
LISTEN START port | START_SECURE port | STOP [port]
LOG CONSOLE verbosity | FILE verbosity
Expand Down Expand Up @@ -142,6 +143,21 @@ Apply limit on allowed average number of connections per second for all the vhos
#### LIMIT CONN_RATE VHOST vhostName numberOfConnections
Apply limit on allowed average number of connections per second for specified vhost. The specific limit takes priority over the default limit for any vhost.

#### LIMIT TOTAL_CONN_ALARM DEFAULT numberOfConnections

Apply limit on allowed total number of connections in alarm only mode for all the vhosts. So whenever the in-coming connection violates the limit, the proxy will only emit log at warning level with AMQPPROX_CONNECTION_LIMIT as a substring and the relevant limiter details, instead of actively limiting any actual connection.

#### LIMIT TOTAL_CONN_ALARM VHOST vhostName numberOfConnections

Apply limit on allowed total number of connections in alarm only mode for specified vhost. The specific limit takes priority over the default limit for any vhost.

#### LIMIT TOTAL_CONN DEFAULT numberOfConnections

Apply limit on allowed total number of connections for all the vhosts. So whenever the in-coming connection violates the limit, the proxy will close that connection with appropriate error message and will not allow that client connection to connect to the broker.

#### LIMIT TOTAL_CONN VHOST vhostName numberOfConnections
Apply limit on allowed total number of connections for specified vhost. The specific limit takes priority over the default limit for any vhost.

#### LIMIT DATA_RATE_ALARM DEFAULT BytesPerSecond

Apply limit on allowed max bytes per second in alarm only mode for all the vhosts. So whenever any in-coming connection violates the data rate limit, the proxy will only emit log with Data Rate Alarm as a substring and the relevant limiter details, instead of actively limiting any data.
Expand All @@ -152,7 +168,8 @@ Apply limit on allowed max bytes per second in alarm only mode for specified vho

#### LIMIT DATA_RATE DEFAULT numberOfConnections

Apply limit on allowed max bytes per second for all the vhosts. So the data limit is enforced by counting the number of bytes read from the socket during each read operation, and pausing for one second before starting a read operation if the in-coming client connection violates the data.
Apply limit on allowed max bytes per second for all the vhosts. So the data limit is enforced by counting the number of bytes read from the socket during each read operation, and pausing for one second before
starting a read operation if the in-coming client connection violates the data.

#### LIMIT DATA_RATE VHOST vhostName numberOfConnections
Apply limit on allowed max bytes per second for specified vhost. The specific limit takes priority over the default limit for any vhost.
Expand All @@ -165,13 +182,21 @@ Remove default connection rate limit (allowed average number of connections per

Remove specific connection rate limit (allowed average number of connections per second) for the specified vhost. The default limit will be applied to the specified vhost, if the default limit is already configured.

#### LIMIT DISABLE TOTAL_CONN_ALARM DEFAULT numberOfConnections

Remove default total connection limit (allowed total number of connections) in alarm only mode for all the vhosts.

#### LIMIT DISABLE TOTAL_CONN VHOST vhostName numberOfConnections

Remove specific total connection limit (allowed total number of connections) for the specified vhost. The default limit will be applied to the specified vhost, if the default limit is already configured.

#### LIMIT DISABLE DATA_RATE_ALARM DEFAULT numberOfConnections

Remove default data rate limit (allowed max bytes per second) in alarm only mode for all the vhosts.
Remove default data rate limit (allowed average bytess per second) in alarm only mode for all the vhosts.

#### LIMIT DISABLE DATA_RATE VHOST vhostName numberOfConnections

Remove specific data rate limit (allowed max bytes per second) for the specified vhost. The default data limit will be applied to the specified vhost, if the default data limit is already configured.
Remove specific data rate limit (allowed average bytes per second) for the specified vhost. The default data limit will be applied to the specified vhost, if the default data limit is already configured.

#### LIMIT PRINT [vhostName]

Expand Down
1 change: 1 addition & 0 deletions libamqpprox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ add_library(libamqpprox STATIC
amqpprox_connectionlimiterinterface.cpp
amqpprox_connectionlimitermanager.cpp
amqpprox_fixedwindowconnectionratelimiter.cpp
amqpprox_totalconnectionlimiter.cpp
amqpprox_limitcontrolcommand.cpp
amqpprox_closeerror.cpp)

Expand Down
6 changes: 6 additions & 0 deletions libamqpprox/amqpprox_connectionlimiterinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class ConnectionLimiterInterface {
*/
virtual bool allowNewConnection() = 0;

/**
* \brief Called when an aquired connection is closed. Useful for changing
* the state of the limiter based on close connection event.
*/
virtual void connectionClosed() {}

// ACCESSORS
/**
* \return information about connection limiter as a string
Expand Down
Loading

0 comments on commit 05c75ef

Please sign in to comment.