Cross-platform lightweight redis and ssdb proxy servers (written in C ++ 11 ),
Dbproxy is a cross-platform proxy server that uses C ++ 11 in my spare time (and uses lua and its own network library) to expand the system load and use multiple backend databases at the same time, backend databases support redis and ssdb.
You need to write lua scripts to control sharding. The test efficiency is slightly higher than codis and consumes less CPU and memory.
Below is the readme on github. I copied it directly:
Introduction
Dbproxy is a proxy server written in C ++ 11. It supports redis and ssdb databases. It is mainly used to resize and increase system load. Use lua to control sharding and map different key-values to different backend redis or ssdb servers.
Build
Dbproxy supports windwos and linux.
- Windows: Open DBProxy. sln compilation in the root directory.
- Linux:
- 1: run the command in the project root directory.
cd 3rdparty/luasrc/src/
Command to enter the lua src directory, and then executemake generic
Buildliblua.so
- 2: Return to the project root directory for execution
cp 3rdparty/luasrc/src/liblua.so .
Setliblua.so
Copy to the current directory.
- 3: continue to run in the root directory
make server
Builddbserver
You can.
- 4: directly run./dbserver to start the proxy server.
Configuration File
The configuration file of dbproxy is Config. lua andProxyConfig
Ofbackends
Key to configure the list of backend servers.sharding_function
Indicates the sharding function. As an example,test_sharding
The specified sharding function returns the corresponding server number based on the key parameter. Here 0 is returned, indicating that the key is mapped127.0.0.1
:6379
This server.
There is almost no difference between using a proxy server in redis or ssdb and using redis or ssdb. You can use any redis or ssdb client, and the Code does not need to be adjusted, you only need to direct the ip address and port to the proxy server address.
Supplement
Currently, dbproxy is only used as a proxy ing. It does not contain read/write splitting and extra caching, and does not resolve distributed issues. Of course, the C ++ code body on its server does not involve any sharding scheme, and the user must configure it by himself. implement the sharding function by yourself in lua (of course, you can also find existing functions on the Internet, such as consistent hash lua-consistent-hash in lua)
Thanks
Redis-shatter and codis are used for reference to some extent.
Follow-up:
The efficiency can be further improved and optimized. Thank you for your attempt and comments.