kv_config_set_request_limits()

#include <kvstore.h>

kv_error_t 
kv_config_set_request_limits(kv_config_t *config, 
                         kv_int_t max_active_requests, 
                         kv_int_t request_threshold_percent, 
                         kv_int_t node_limit_percent); 

Configures the maximum number of requests that the client can have active for a node in the KVStore. Limiting requests in this way helps minimize the possibility of thread starvation in situations where one or more nodes in the store exhibits long service times. As a result, nodes retain threads, making them unavailable to service requests to other reachable and healthy nodes.

The long service times can be due to problems at the node itself, or in the network path to that node. Whenever possible, the KVS request dispatcher will minimize use of nodes with long service times automatically, by re-routing requests to other nodes that can handle them. So the mechanism provided by this function offers an additional margin of safety when re-routing requests is not possible.

The request limiting mechanism of this function is activated only when the number of active requests exceeds the threshold specified by the parameter request_threshold_percent. Both the threshold and limit parameters that you provide to this function are expressed as a percentage of max_active_requests.

The limits that this function sets are applicable only if the client is mult-threaded.

When the mechanism is active, the number of active requests to a node is not allowed to exceed node_limit_percent. Any new requests that would exceed this limit are rejected and the function making the request returns with an error.

For example, consider a configuration with max_active_requests=10, request_threshold_percent=80 and node_limit_percent=50. If 8 requests are already active at the client, and a 9th request is received that would be directed at a node which already has 5 active requests, the latest request would cause an error. If only 7 requests were active at the client, the 8th request would be directed at the node with 5 active requests. The request would then be processed normally.

Parameters

  • config

    The config parameter points to the configuration structure for which you want to set request limits. This structure was initially created using kv_create_config().

  • max_active_requests

    The max_active_requests parameter is the maximum number of active requests permitted by the KV client. This number is typically derived from the maximum number of threads that the client has set aside for processing requests. The default is 100. Note that the KVStore does not actually enforce this maximum directly. Instead, it uses this parameter only as the basis for calculating the request limits to be enforced at a node.

  • request_threshold_percent

    The request_threshold_percent parameter is the threshold computed as a percentage of max_active_requests at which requests are limited. The default is 90.

  • node_limit_percent

    The node_limit_percent parameter determines the maximum number of active requests that can be associated with a node when the request limiting mechanism is active. The default is 80.