Cross-platform lightweight redis and ssdb proxy servers (written in C ++ 11 ),

Source: Internet
Author: User

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 genericBuildliblua.so
    • 2: Return to the project root directory for executioncp 3rdparty/luasrc/src/liblua.so .Setliblua.soCopy to the current directory.
    • 3: continue to run in the root directorymake serverBuilddbserverYou can.
    • 4: directly run./dbserver to start the proxy server.
Configuration File

The configuration file of dbproxy is Config. lua andProxyConfigOfbackendsKey to configure the list of backend servers.sharding_functionIndicates the sharding function. As an example,test_shardingThe 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:6379This 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.