Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for total connections limit per vhost level #91

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Chinmay1412
Copy link
Contributor

@Chinmay1412 Chinmay1412 commented Jul 18, 2022

Currently, amqpprox supports two types of limit: connection rate and data rate limits for connecting clients. This PR implements total connection limit(allowed total number of connections) for connecting clients.

The limit will be applied at vhost level. So each vhost will have separate counters to maintain the existing number of connections. The limit can be configured using existing control command LIMIT. By default, amqpprox will not configure any limit for vhost. Using LIMIT control command, one will be able to configure total connection limit per vhost or default total connection limit for all the vhosts. After configured total connection limit, violating client connections will be closed with some async sleep(~750ms) during AMQP handshake. So the limited connections will not hit the broker in any way.

The total connection limit has high priority over connection rate limit. So basically, it is possible that any particular connection might not be violating connection rate limit, but it might violate total connection limit. And in that case, the proxy will limit that connection. If the total limit is configured after already existing connections for any vhost, then the limit will ignore those extra existing connections. So for example, if there were x connections already, when the total connection limit y configured for particular vhost, then the actual limit for that vhost will be x+y. The control command also allows to configure limit in alarm only mode. In alarm only mode, the violating client connection will not be closed. But amqpprox will log at warning level in case of any limit violation with AMQPPROX_CONNECTION_LIMIT as a substring, which can be used to set an early alarm for the clients.

Performance Tests

Testing by setting up amqpprox as per the performance tests README.md, and running the perf tester like:

$ ./amqpprox_perf_tester --address amqp://127.0.0.1:5673/rmq-lib --listen-address 0.0.0.0:5672 --clients 10000 --max-threads 100 --message-size 1 --num-messages 1

Results in seconds. Testing was done inside docker on physical machine having 6 2.6 GHz cores CPU and 32 GB RAM.

Test # No change (main branch) With the PR (without any limit) With the PR (with large limit (100000 total connections)) With the PR (with large limits (100000 total connections and 50000 connections/second))
1 20.94 22.16 20.67 21.52
2 21.47 20.50 21.44 22.57
3 21.24 21.28 22.76 22.34

This shows there isn't any significant performance issue with this code change.

TODO:

  • Performance tests with configured limits and without configured limits
  • Verify the total connection counter value, in different connection close scenarios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant