Protocol layer

Protocol layer design #

A good access method of the application can accelerate the growth of the application ecology, and a good protocol design can reduce the transformation cost of the stock application, so the protocol layer is an important component of the IceFireDB software stack. The communication protocol of IceFireDB-NoSQL fully integrates the Redis RESP protocol, which mainly includes the following two parts of the protocol:

  1. Data control protocol: Complete support for RESP clients, supporting functional requirements for database data access.

  2. Cluster control protocol: Satisfy the client’s command protocol for controlling the nodes of the IceFireDB cluster and viewing the status and availability status of the cluster nodes.

+-------------------------------------------------------------+
|                           Transport                         |
| +---------------+    +---------------+    +---------------+ |
| |    Cluster    |    |    Cluster    |    |    Cluster    | |
| | communication |    | communication |    | communication | |
| +---------------+    +---------------+    +---------------+ |
+-+---------------+----+-------^-------+----+---------------+-+
                               |
+------------------------------v------------------------------+
|                        Query Processor                      |
|   +-----------------------------------------------------+   |
|   |                     Query Parser                    |   |
|   +-----------------------------------------------------+   |
|   +-----------------------------------------------------+   |
|   |                   Query Optimizer                   |   |
|   +-----------------------------------------------------+   |
+-------------------------------------------------------------+

As can be seen from the figure above, the cluster control protocol is located above the data read and write protocol. The client (redis cluster client, IceFireDB-Proxy) obtains the master-slave structure of the cluster nodes according to the cluster status, and selects the relevant master and slave nodes Perform data read and write operations. For the request traffic carried by IceFireDB, it will enter the request processing cycle. During the request processing cycle, it will analyze and optimize the client request.

Protocol advantages #

At present, the web2 ecology of RESP protocol clients is very rich, and mainstream computer languages have been fully covered. IceFireDB is firstly compatible with the RESP NoSQL protocol, which can quickly meet the needs of existing application systems to access IceFireDB-NoSQL.

image

As a decentralized database, IceFireDB is compatible with the RESP protocol, and can hide high technical intelligence from the user layer. Users do not need to understand P2P, RAFT, CRDT, IPFS-LOG and other technologies, and only need to follow the RESP protocol to choose the appropriate client for application You can operate the database to read and write, and quickly meet the access and transformation of the business system.

Data control protocol #

StringsHashesListsSetsSorted Sets
APPENDHSETRPUSHSADDZADD
BITCOUNTHGETLPOPSCARDZCARD
BITOPHDELLINDEXSDIFFZCOUNT
BITPOSHEXISTSLPUSHSDIFFSTOREZREM
DECRHGETALLRPOPSINTERZCLEAR
DECRBYHINCRBYLRANGESINTERSTOREZRANK
DELHKEYSLSETSISMEMBERZRANGE
EXISTSHLENLLENSMEMBERSZREVRANGE
GETHMGETRPOPLPUSHSREMZSCORE
GETBITHMSETLCLEARSUNIONZINCRBY
SETBITHSETEXLCLEARSUNIONSTOREZREVRANK
GETRANGEHSTRLENLMCLEARSCLEARZRANGEBYSCORE
GETSETHVALSLEXPIRESMCLEARZREVRANGEBYSCORE
INCRHCLEARLEXPIREATSEXPIREZREMRANGEBYSCORE
EXISTSHMCLEARLKEYEXISTSSEXPIREZREMRANGEBYRANK
GETHEXPIRELTRIMSEXPIREAT
GETBITHEXPIREATLTTLSTTL
SETBITHKEYEXISTSPERSIST
GETRANGEHTTLSKEYEXISTS
GETSET
INCRBY
GET
MGET
MSET
SET
SETEX
SETEXAT
SETRANGE
EXPIRE
EXPIREAT
TTL

Cluster control protocol #

IceFireDB-NoSQL integrates some Redis cluster status instructions in the RAFT parallel database scenario.

VERSION                                 # show the application version
MACHINE                                 # show information about the state machine
RAFT LEADER                             # show the address of the current raft leader
RAFT INFO [pattern]                     # show information about the raft server and cluster
RAFT SERVER LIST                        # show all servers in cluster
RAFT SERVER ADD id address              # add a server to cluster
RAFT SERVER REMOVE id                   # remove a server from the cluster
RAFT SNAPSHOT NOW                       # make a snapshot of the data
RAFT SNAPSHOT LIST                      # show a list of all snapshots on server
RAFT SNAPSHOT FILE id                   # show the file path of a snapshot on server
RAFT SNAPSHOT READ id [RANGE start end] # download all or part of a snapshot