If you are a software developer, mainly working with data intensive application, chances are, you’ve already work with in-memory data as it will make our app runs fast. Redis usually becomes de-facto DBMS for caching. Redis mainly uses key-value data model but its modular architecture makes it possible to develop other tools or data models using Redis key-value as its underlying data model. That’s also happens with RedisGraph, a Redis module for property graph model. It uses OpenCypher as its query language. However, bad news came: Redis stopped its development. However, lucky for us, some developers decide to fork RedisGraph and continue its development as FalkorDB. This article explains how we can get started quickly with FalkorDB.
Installation
To install FalkorDB, install Redis first. You may use your own package manager or compile it by yourself. Here, I will build Redis from source and configure it.
Install Redis
- Get the source (here I use v7.2.4): https://redis.io/download/
- Compile and build:
$ tar -xvf 7.2.4.tar.gz
$ cd redis-7.2.4
$ make PREFIX=/home/bpdp/software/redis/redis-7.2.4 BUILD_TLS=yes install
...
...
Once finished, the result will be installed in /home/bpdp/software/redis/redis-7.2.4/bin
. Put that bin
directory in PATH environment variable.
Install FalkorDB
Currentnly, FalkorDB is a Redis module. When build process succeed, there will be one .so
file. Here, we will use stable version (4.0.4), directly cloned from GitHub. To install:
$ git clone --recurse-submodules -j8 --depth 1 --branch v4.0.4 https://github.com/FalkorDB/FalkorDB.git
$ cd FalkorDB
$ make
...
...
$
Result:
$ ls -la bin/linux-x64-release/src/
total 243908
drwxr-xr-x 3 bpdp bpdp 4096 Feb 24 11:46 ./
drwxr-xr-x 10 bpdp bpdp 4096 Feb 24 11:55 ../
-rw-r--r-- 1 bpdp bpdp 18750 Feb 24 11:45 CMakeCache.txt
drwxr-xr-x 6 bpdp bpdp 4096 Feb 24 11:46 CMakeFiles/
-rw-r--r-- 1 bpdp bpdp 1746 Feb 24 11:45 cmake_install.cmake
-rw-r--r-- 1 bpdp bpdp 580894 Feb 24 11:45 compile_commands.json
-rwxr-xr-x 1 bpdp bpdp 48220880 Feb 24 11:46 falkordb.so*
-rwxr-xr-x 1 bpdp bpdp 200529120 Feb 24 11:46 falkordb.so.debug*
-rw-r--r-- 1 bpdp bpdp 388247 Feb 24 11:45 Makefile
$
Copy falkordb.so
anywhere (to make it easy, i put that file in $REDIS_HOME/lib). Here’s the directory structure:
$ pwd
/home/bpdp/software/redis/redis-7.2.4
$ tree .
.
├── bin
│ ├── redis-benchmark
│ ├── redis-check-aof -> redis-server
│ ├── redis-check-rdb -> redis-server
│ ├── redis-cli
│ ├── redis-sentinel -> redis-server
│ └── redis-server
└── lib
├── falkordb.so
└── redisearch.so
3 directories, 8 files
Configuration
Here I created some directories inside redis-dont-delete
(this could be whatever as you wish). Inside that directory, I pull all configuration and any other files needed for the Redis and FalkorDB.
$ pwd
/home/bpdp/software/redis/redis-dont-delete
$ tree .
.
├── conf
│ └── redis.conf
├── data
│ ├── konversa-orig.rdb
│ └── konversa.rdb
├── log
│ └── redis.log
└── run
5 directories, 4 files
$
Configuration resides in redis.conf
file:
cat conf/redis.conf
port 6379
daemonize no
loadmodule /home/bpdp/software/redis/redis-current/lib/redisearch.so
loadmodule /home/bpdp/software/redis/redis-current/lib/falkordb.so
logfile /home/bpdp/software/redis/redis-dont-delete/log/redis.log
dbfilename konversa.rdb
dir /home/bpdp/software/redis/redis-dont-delete/data
Usage
Run Redis server:
$ redis-server software/redis/redis-dont-delete/conf/redis.conf
25432:C 24 Feb 2024 13:11:07.273 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
25432:C 24 Feb 2024 13:11:07.273 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
25432:C 24 Feb 2024 13:11:07.273 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=25432, just started
25432:C 24 Feb 2024 13:11:07.273 * Configuration loaded
25432:M 24 Feb 2024 13:11:07.274 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.2.4 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 25432
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
25432:M 24 Feb 2024 13:11:07.276 * <search> Redis version found by RedisSearch : 7.2.4 - oss
25432:M 24 Feb 2024 13:11:07.276 * <search> RediSearch version 2.6.14 (Git=HEAD-eef91a67)
25432:M 24 Feb 2024 13:11:07.276 * <search> Low level api version 1 initialized successfully
25432:M 24 Feb 2024 13:11:07.276 * <search> concurrent writes: OFF, gc: ON, prefix min length: 2, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results: 1000000, search pool size: 20, index pool size: 8,
25432:M 24 Feb 2024 13:11:07.276 * <search> Initialized thread pool!
25432:M 24 Feb 2024 13:11:07.276 * <search> Enabled role change notification
25432:M 24 Feb 2024 13:11:07.276 * Module 'search' loaded from /home/bpdp/software/redis/redis-current/lib/redisearch.so
25432:M 24 Feb 2024 13:11:07.280 * <graph> Enabled role change notification
25432:M 24 Feb 2024 13:11:07.280 * <graph> Starting up FalkorDB version 4.0.4.
25432:M 24 Feb 2024 13:11:07.281 * <graph> Thread pool created, using 8 threads.
25432:M 24 Feb 2024 13:11:07.281 * <graph> Maximum number of OpenMP threads set to 8
25432:M 24 Feb 2024 13:11:07.281 * <graph> Query backlog size: 1000
25432:M 24 Feb 2024 13:11:07.281 * Module 'graph' loaded from /home/bpdp/software/redis/redis-current/lib/falkordb.so
25432:M 24 Feb 2024 13:11:07.281 * Server initialized
25432:M 24 Feb 2024 13:11:07.281 * <search> Loading event starts
25432:M 24 Feb 2024 13:11:07.281 * Loading RDB produced by version 7.2.4
25432:M 24 Feb 2024 13:11:07.281 * RDB age 767 seconds
25432:M 24 Feb 2024 13:11:07.281 * RDB memory usage when created 2.31 Mb
25432:M 24 Feb 2024 13:11:07.282 * <graph> Done decoding graph social
25432:M 24 Feb 2024 13:11:07.282 * <graph> Done decoding graph movies
25432:M 24 Feb 2024 13:11:07.282 * <graph> Done decoding graph us_government
25432:M 24 Feb 2024 13:11:07.282 * <module> Deleted 0 virtual keys for graph social
25432:M 24 Feb 2024 13:11:07.282 * <module> Deleted 0 virtual keys for graph movies
25432:M 24 Feb 2024 13:11:07.282 * <module> Deleted 0 virtual keys for graph us_government
25432:M 24 Feb 2024 13:11:07.282 * Done loading RDB, keys loaded: 3, keys expired: 0.
25432:M 24 Feb 2024 13:11:07.282 # <search> Skip background reindex scan, redis version contains loaded event.
25432:M 24 Feb 2024 13:11:07.282 * <search> Loading event ends
25432:M 24 Feb 2024 13:11:07.282 * DB loaded from disk: 0.001 seconds
25432:M 24 Feb 2024 13:11:07.282 * Ready to accept connections tcp
Run redis client:
$ redis-cli
127.0.0.1:6379>