Setting configuration parameters on module load
Setting configuration parameters at load-time is done by appending arguments after the
--loadmodule argument when starting a server from the command line or after the
loadmodule directive in a Redis config file. For example:
loadmodule ./redisgraph.so [OPT VAL]...
127.0.0.6379> MODULE LOAD redisgraph.so [OPT VAL]...
From the command line:
$ redis-server --loadmodule ./redisgraph.so [OPT VAL]...
Setting configuration parameters at run-time (for supported parameters)
RedisGraph exposes the
GRAPH.CONFIG endpoint to allowing for the setting and retrieval of configuration parameters at run-time.
To set the value of a configuration parameter at run-time (for supported parameters), simply run:
GRAPH.CONFIG SET OPT1 VAL1
Similarly, current configuration parameter values can be retrieved using:
GRAPH.CONFIG GET OPT1 GRAPH.CONFIG GET *
RedisGraph configuration parameters
The following table summarizes which configuration parameters can be set at module load-time and which can be set on run-time:
The number of threads in RedisGraph's thread pool. This is equivalent to the maximum number of queries that can be processed concurrently.
THREAD_COUNT defaults to the system's hardware threads (logical cores).
$ redis-server --loadmodule ./redisgraph.so THREAD_COUNT 4
The max number of queries for RedisGraph to cache. When a new query is encountered and the cache is full, meaning the cache has reached the size of
CACHE_SIZE, it will evict the least recently used (LRU) entry.
CACHE_SIZE default value is 25.
$ redis-server --loadmodule ./redisgraph.so CACHE_SIZE 10
The maximum number of threads that OpenMP may use for computation per query. These threads are used for parallelizing GraphBLAS computations, so may be considered to control concurrency within the execution of individual queries.
OMP_THREAD_COUNT is defined by GraphBLAS by default.
$ redis-server --loadmodule ./redisgraph.so OMP_THREAD_COUNT 1
The node creation buffer is the number of new nodes that can be created without resizing matrices. For example, when set to 16,384, the matrices will have extra space for 16,384 nodes upon creation. Whenever the extra space is depleted, the matrices' size will increase by 16,384.
Reducing this value will reduce memory consumption, but cause performance degradation due to the increased frequency of matrix resizes.
Conversely, increasing it might improve performance for write-heavy workloads but will increase memory consumption.
If the passed argument was not a power of 2, it will be rounded to the next-greatest power of 2 to improve memory alignment.
NODE_CREATION_BUFFER is 16,384 by default.
The minimum value for
NODE_CREATION_BUFFER is 128. Values lower than this will be accepted as arguments, but will internally be converted to 128.
$ redis-server --loadmodule ./redisgraph.so NODE_CREATION_BUFFER 200
Setting the maximum number of queued queries allows the server to reject incoming queries with the error message
Max pending queries exceeded. This reduces the memory overhead of pending queries on an overloaded server and avoids congestion when the server processes its backlog of queries.
MAX_QUEUED_QUERIES is effectively unlimited by default (config value of
$ redis-server --loadmodule ./redisgraph.so MAX_QUEUED_QUERIES 500 $ redis-cli GRAPH.CONFIG SET MAX_QUEUED_QUERIES 500
Timeout is a flag that specifies the maximum runtime for read queries in milliseconds. This configuration will not be respected by write queries, to avoid leaving the graph in an inconsistent state.
TIMEOUT is off by default (config value of
$ redis-server --loadmodule ./redisgraph.so TIMEOUT 1000
Result set size is a limit on the number of records that should be returned by any query. This can be a valuable safeguard against incurring a heavy IO load while running queries with unknown results.
RESULTSET_SIZE is unlimited by default (negative config value).
127.0.0.1:6379> GRAPH.CONFIG SET RESULTSET_SIZE 3 OK 127.0.0.1:6379> GRAPH.QUERY G "UNWIND range(1, 5) AS x RETURN x" 1) 1) "x" 2) 1) 1) (integer) 1 2) 1) (integer) 2 3) 1) (integer) 3 3) 1) "Cached execution: 0" 2) "Query internal execution time: 0.445790 milliseconds"
Setting the memory capacity of a query allows the server to kill queries that are consuming too much memory and return with the error message
Query's mem consumption exceeded capacity. This helps to avoid scenarios when the server becomes unresponsive due to an unbounded query exhausting system resources.
The configuration argument is the maximum number of bytes that can be allocated by any single query.
QUERY_MEM_CAPACITY is unlimited by default; this default can be restored by setting
QUERY_MEM_CAPACITY to zero or a negative value.
$ redis-server --loadmodule ./redisgraph.so QUERY_MEM_CAPACITY 1048576 // 1 megabyte limit $ redis-cli GRAPH.CONFIG SET QUERY_MEM_CAPACITY 1048576
To lower the time Redis is blocked when replicating large graphs, RedisGraph serializes the graph in a number of virtual keys.
One virtual key is created for every N graph entities, where N is the value defined by this configuration.
This configuration can be set when the module loads or at runtime.
VKEY_MAX_ENTITY_COUNT is 100,000 by default.
The query timeout configuration may also be set per query in the form of additional arguments after the query string. This configuration is unset by default unless using a language-specific client, which may establish its own defaults.
The query flag
timeout allows the user to specify a timeout as described in TIMEOUT for a single query.
Retrieve all paths in a graph with a timeout of 1000 milliseconds.
GRAPH.QUERY wikipedia "MATCH p=()-[*]->() RETURN p" timeout 1000