Table of contents
1.
Introduction
2.
Redis Graph
3.
Configurations in Redis Graph
3.1.
Setting configuration parameters at runtime
3.2.
Setting configuration parameters at load time
4.
Configuration parameters 
4.1.
THREAD_COUNT
4.1.1.
DEFAULT VALUE
4.1.2.
EXAMPLE
4.2.
CACHE_SIZE
4.2.1.
DEFAULT VALUE
4.2.2.
EXAMPLE
4.3.
OMP_THREAD_COUNT
4.3.1.
DEFAULT VALUE
4.3.2.
EXAMPLE
4.4.
NODE_CREATION_BUFFER
4.4.1.
DEFAULT VALUE
4.4.2.
EXAMPLE
4.5.
MAX_QUEUED_QUERIES
4.5.1.
DEFAULT VALUE
4.5.2.
EXAMPLE
4.6.
TIMEOUT
4.6.1.
DEFAULT VALUE
4.6.2.
EXAMPLE
4.7.
RESULTSET_SIZE
4.7.1.
DEFAULT VALUE
4.7.2.
EXAMPLE
4.8.
QUERY_MEM_CAPACITY
4.8.1.
DEFAULT VALUE
4.8.2.
EXAMPLE
4.9.
VKEY_MAX_ENTITY_COUNT
4.9.1.
DEFAULT VALUE
5.
Query Configurations
5.1.
QUERY TIMEOUT
6.
Frequently Asked Questions
6.1.
What is TIMEOUT? Why is it only set for read queries?
6.2.
What is RedisGraph?
6.3.
What do you mean by configuration parameters?
6.4.
When can you set the values to the configuration parameters in Redis Graph?
6.5.
What configuration parameters can be set at run time in Redis Graph?
7.
Conclusion
Last Updated: Mar 27, 2024

Configurations in Redis Graph

Author Teesha Goyal
0 upvote

Introduction

Millions of developers use Redis. It is an open-source in-memory data store used as a database, cache, streaming engine, and message broker. Redis is a NoSQL database. To learn more about NoSQL databases, go to NoSQL Databases

This article will discuss configurations in Redis Graph and the different configuration parameters available in Redis Graph.

Redis Graph

RedisGraph is a database that uses a graphical format to store the data in the Redis databases. It is built on a one-of-a-kind technique and architecture that converts Cypher queries into matrix operations executed over the GraphBLAS engine. 

It is based on a property graph model where the graphs are represented as sparse adjacency matrices.

Configurations in Redis Graph

There are separate commands to configure parameters at run time and load time. We have discussed both the commands below.

Setting configuration parameters at runtime

The Redis graph has a GRAPH.CONFIG endpoint for setting the configuration parameters at runtime. It takes the parameter and the value to be set to the parameter. 

You can set a value to the parameter at runtime by running the following command.

GRAPH.CONFIG SET OPT1 VALUE

The GRAPH.CONFIG also provides a command to retrieve the set values of configuration parameters in Redis Graph. To fetch the set values, you can run the following command:

GRAPH.CONFIG GET OPT1
GRAPH.CONFIG GET *

Setting configuration parameters at load time

To set the configuration parameters at load time, we have two options: 

One by setting the value in the Redis config file by appending the arguments after the loadmodule directive. The following command is used to do so:

loadmodule ./redisgraph.so OPT1 VAL1

The other method is to set the values from the command line by appending the set arguments after the --loadmodule argument when starting a server. Run the following command to do so:

$ redis-server --loadmodule ./redisgraph.so OPT1 VAL1

Configuration parameters 

Multiple module configuration parameters are supported in Redis Graph, which is used to configure the databases. Some parameters can be set either on runtime or load time, but not all. The remaining parameters can only be configured at load time.

Following are the configuration parameters that are set at load time:

  • THREAD_COUNT
  • CACHE_SIZE
  • OMP_THREAD_COUNT
  • NODE_CREATION_BUFFER

 

Following are the configuration parameters that can be set at both run time and load time:

  • MAX_QUEUED_QUERIES
  • TIMEOUT
  • RESULTSET_SIZE
  • QUERY_MEM_CAPACITY
  • VKEY_MAX_ENTITY_COUNT

 

We will discuss each of the parameters mentioned above in detail. We will also discuss what the parameter does and its default value with an example of setting a new value to the parameter. 

THREAD_COUNT

Thread in Redis Graph is responsible for the read and write operations. THREAD_COUNT gives the value for the number of threads available in the thread pool of the Redis Graph. Threads allow concurrent read and write operations; hence the THREAD_COUNT gives the upper limit for the number of queries executed concurrently.

DEFAULT VALUE

Equal to the system's hardware threads

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so THREAD_COUNT 8

CACHE_SIZE

Cache memory is the closest to the hardware, so keeping the querying in cache improves the performance by reducing the time to fetch the data from the database. The cache memory is the most expensive, so we must set it wisely. 

The maximum number of queries that can stay in cache at a time gives the CACHE_SIZE. When we get a new query that is not present in the cache, and the CACHE_SIZE is full, we must bring the query into the cache by discarding the least recently used query from the cache.

DEFAULT VALUE

Default CACHE_SIZE is 25.

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so CACHE_SIZE 30

OMP_THREAD_COUNT

It defines the maximum number of threads used by the OPENMP for computation per query. It controls concurrency within an individual query. It improves parallelism in GraphBLAS computations and hence improves performance.

DEFAULT VALUE

GraphBLAS sets the default value. 

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so OMP_THREAD_COUNT 2

NODE_CREATION_BUFFER

NODE_CREATION_BUFFER defines the size of the number of new nodes that can be created without resizing the matrices. The extra space is allocated to the matrices upon creation for adding new nodes. Once the matrice gets full, it is resized by adding the NODE_CREATION_BUFFER amount of memory to store more new nodes. 

If the value of NODE_CREATION_BUFFER is small, then there will be a lot of overhead for resizing the matrices, and if the value is large, then overhead would be less, but it will consume more memory. 

It should always be in the power of 2, and if we set a value to NODE_CREATION_BUFFER that is not the power of 2, it is rounded off to the nearest greater power of 2.

The minimum value of NODE_CREATION_BUFFER is 128; the values smaller than 128 will be accepted but will be changed internally to 128.

DEFAULT VALUE

The default value of NODE_CREATION_BUFFER is 16,384

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so NODE_CREATION_BUFFER 1200

MAX_QUEUED_QUERIES

It defines the maximum number of queries that can be queued at a time. If the number of queries reaches the MAX_QUEUED_QUERIES value, the incoming queries are rejected. Doing so reduces the memory overhead created by storing the queries in long queues. 

DEFAULT VALUE

The default value is almost unlimited equal to UINT64_MAX.

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so MAX_QUEUED_QUERIES 1000

$ redis-cli GRAPH.CONFIG SET MAX_QUEUED_QUERIES 1000

TIMEOUT

Maximum runtime for read queries in milliseconds. It is not used with the write queries. Setting timeout with write queries will make the database prone to inconsistency, so it is only set for the read operations. 

DEFAULT VALUE

The default value is off, i.e., 0

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so TIMEOUT 200

RESULTSET_SIZE

It specifies an upper limit to the number of records fetched by a query in the result. It is essential when dealing with heavy IO queries where the size of the result is unknown. 

DEFAULT VALUE

The default value is unlimited.

EXAMPLE

127.0.0.1:6379> GRAPH.CONFIG SET RESULTSET_SIZE 6

QUERY_MEM_CAPACITY

It defines the maximum number of bytes of memory that any query can allocate. It ensures that none of the queries consumes so much memory that the system becomes unresponsive due to the lack of system resources. Such queries are stopped with an error message, "Query's mem consumption exceeded capacity."

It can be set at both the run time and the load time.

DEFAULT VALUE

The default value is unlimited.

EXAMPLE

$ redis-server --loadmodule ./redisgraph.so QUERY_MEM_CAPACITY 1048576 

$ redis-cli GRAPH.CONFIG SET QUERY_MEM_CAPACITY 1048576

VKEY_MAX_ENTITY_COUNT

When large graphs are replicated in Redis Graph, a virtual key is created for a certain number (N) of graphs. VKEY_MAX_ENTITY_COUNT defines the value of N.

DEFAULT VALUE

The default value is 1,00,000.

Query Configurations

Besides the above-mentioned module configuration parameters, we have one more query configuration parameter: query timeout. 

QUERY TIMEOUT

As timeout was set for all the queries in the TIMEOUT parameter mentioned above, we can set a timeout or runtime for a specific query using the query timeout parameter. It is set right after the query string as an additional argument. 

Frequently Asked Questions

What is TIMEOUT? Why is it only set for read queries?

TIMEOUT defines the maximum runtime for read queries in milliseconds. It is not used with the write queries. Setting timeout with write queries will make the database prone to inconsistency, so it is only set for the read operations. 

What is RedisGraph?

RedisGraph is a database that uses a graphical format to store the data in the Redis databases. It is built on a one-of-a-kind technique and architecture that converts Cypher queries into matrix operations executed over the GraphBLAS engine. 

What do you mean by configuration parameters?

Configuration parameters are the arguments that allow users to manipulate the internal working of the Redis Graph. Multiple module configuration parameters are supported in Redis Graph, used to configure the databases.  

When can you set the values to the configuration parameters in Redis Graph?

Some parameters can be set either on runtime or load time, but not all. There are some parameters that can only be configured at load time.

What configuration parameters can be set at run time in Redis Graph?

Some parameters are only set and load time, while others can be set at both runtime and compiler time. Such configuration parameters that can be set at runtime are MAX_QUEUED_QUERIES, TIMEOUT, RESULTSET_SIZE, QUERY_MEM_CAPACITY, VKEY_MAX_ENTITY_COUNT.

Conclusion

In this article, we discussed the configurations in Redis Graph. We have also discussed the configuration parameters and how to set them. To learn more about Redis, visit our page, Redis. To learn about the different Redis tools, go to Tools That Use Redis

I hope you would have gained a better understanding of these topics now!

Are you planning to ace the interviews of reputed product-based companies like AmazonGoogleMicrosoft, and more? 

Attempt our Online Mock Test Series on Coding Ninjas Studio now!

Happy Coding!

Live masterclass