It is based on the Token Bucket Algorithm and should run as a service (daemon). The service initializes using the quota.cnf file, which specifies the maximum number of tokens allowed per second.
Every second, each user's bucket is refilled with the maximum allowed tokens. When a client requests a token (GetToken), the service checks the bucket:
If tokens are available, it decrements the count by one and responds with "Allow".
If no tokens remain, it responds with "Deny".
Runs on Port 8077
Request Format: "GetToken UserName"
Respone Format: "Allow"
"Deny"
-
cmake --version
cmake version 3.19.0 -
gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
-
c++ 11 or higher
-
Source files: throttleserver/server
-
Config file : throttleserver/quota.cnf
-
Client tool src : throttleserver/server/generate_throttle_request.cpp
-
Generate cmake build files
$cd throttleserver
$cmake server -
Build throttleserver and generate_throttle_request client tool
$cd throttleserver
$cmake --build .
-
Prepare quota.cnf file
User:max_tokens_per_second
sample below
$cat quota.cnf
John:5
Amit:15
Peter:5
Bob:10
Eve:5
Tom:20 -
Run throttles server
$cd throttleserver
$./throttleserver
Usage: throtlleserver <quota.cnf>
$./throttleserver quota.cnf -
Run client tool
./generate_throttle_request
Usage: generate_request <request_count_per_sec>Send 50 requests per second for user Tom
./generate_throttle_request Tom 50Sample output
[root@dev throttle_server]# ./generate_throttle_request Bob 50
Generating Request for User:Bob Request Count:50[Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Allow [Bob] Deny [Bob] Deny