Implement rate limit feature for SMAPI requests through zvmsdk#868
Open
shekhar-himanshu wants to merge 4 commits intoopenmainframeproject:masterfrom
Open
Implement rate limit feature for SMAPI requests through zvmsdk#868shekhar-himanshu wants to merge 4 commits intoopenmainframeproject:masterfrom
shekhar-himanshu wants to merge 4 commits intoopenmainframeproject:masterfrom
Conversation
Bischoff
reviewed
Sep 2, 2025
| - [Interfaces](#interfaces) | ||
| - [Implmentation Details](#implmentation-details) | ||
| - [Sequence diagram](#sequence-diagram) | ||
| - [How oustanding requests limit is checked ?](#how-oustanding-requests-limit-is-checked-) |
Bischoff
reviewed
Sep 2, 2025
| * 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 ? |
Bischoff
reviewed
Sep 2, 2025
|
|
||
| #### 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. |
Bischoff
reviewed
Sep 2, 2025
| |---------|----|-------------|-----------| | ||
| |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.| |
Bischoff
reviewed
Sep 2, 2025
| #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 |
Bischoff
reviewed
Sep 2, 2025
| 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 |
Contributor
|
@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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature enhances zvmsdk to have rate limit and max outstanding filters. This prevent zmvsdk to flood the SMAPI with too many simultaneous requests.