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 this 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 and as a result retains 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. The KVS request dispatcher will, whenever possible, 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 such re-routing of requests is not possible.

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

The limits set by this function only matter 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, it would result in an error being raised. If only 7 requests were active at the client, the 8th request would be directed at the node with 5 active requests and the request would be processed normally.

Parameters

config

The config parameter points to the configuration structure for which you want to set request limits. This structure was intially 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. It only uses this parameter as the basis for calculating the requests 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.

See Also

Store and Library Operations