-
Notifications
You must be signed in to change notification settings - Fork 97
Implement rate limit feature for SMAPI requests through zvmsdk #868
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
base: master
Are you sure you want to change the base?
Implement rate limit feature for SMAPI requests through zvmsdk #868
Conversation
| - [Interfaces](#interfaces) | ||
| - [Implmentation Details](#implmentation-details) | ||
| - [Sequence diagram](#sequence-diagram) | ||
| - [How oustanding requests limit is checked ?](#how-oustanding-requests-limit-is-checked-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
| * After putting the client connection details in queue, worker thread is started. Maximum number of worker threads possible is controlled by `max_worker_count` configuration parameter. Number of threads already running within process is taken into account before starting new worker thread. | ||
| * Each worker thread picks (non-blocking) client connection details from the queue and tries to fulfil (hit SMAPI) the request. | ||
|
|
||
| #### How oustanding requests limit is checked ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
|
|
||
| #### How oustanding requests limit is checked ? | ||
|
|
||
| The oustanding requests refer to requests made to SMAPI on behalf of z/vm driver. The `SDKServer` maintains in-memory counters to check if this limit has passed for any of the requests received from z/vm driver. Just before hitting the `SMAPI`, this counter is incremented and after receiving the response (or failure), this counter is decremented. This an atomic counter and is thread-safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
| |---------|----|-------------|-----------| | ||
| |smapi_rate_limit_window_size_seconds|int|1|The duration to consider for rate limit window. For example, if we want 30 requests per 5 seconds, then specify 5 as the value here. Setting this value to 0 disables the rate-limit check.| | ||
| |smapi_rate_limit_per_window|str|total:30|The configuration for limiting the rate at which functions can be invoked. The "total" count must be specified. Other function limits can be specified optionally, e.g. "smapi_rate_limit_per_window = total:30, guest_list:10, guest_get_info:5, ...". The cumulative value specified for other function keywords should be less than the "total" value. The option to specify custom limit for certain functions can be helpful in limiting functions which are more resource/time intensive. If the rate limit has been reached, the request received by client is postponed for execution. A request can be postponed for anywhere between 1 and 3 seconds.| | ||
| |smapi_max_outstanding_requests|int|10|Maximum number of requests allowed for which response is not yet received. If current oustanding requests exceeds allowed limit, the request is postponed for processing in future. Under this situation, a request can be postponed for a duration between 1 second and 3 seconds. Setting this value to 0 disables the outstanding requests check.| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
| #smapi_rate_limit_per_window=total:30 | ||
|
|
||
| # Maximum number of requests allowed for which response is not yet received. | ||
| # If current oustanding requests exceeds allowed limit, the request is postponed for processing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
| default='10', | ||
| help=''' | ||
| Maximum number of requests allowed for which response is not yet received. | ||
| If current oustanding requests exceeds allowed limit, the request is postponed for processing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outstanding
|
@shekhar-himanshu sorry for the delay in doing a first review. I did not approve nor decline the PR, it is way too high level for me. I hope someone else will have a look. Could you please:
|
This feature enhances zvmsdk to have rate limit and max outstanding filters. This prevent zmvsdk to flood the SMAPI with too many simultaneous requests.