nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.82k stars 307 forks source link

Redis Cluster Support #221

Open srimithravemula opened 2 years ago

srimithravemula commented 2 years ago

Hi Nicolasff,

Have a query on whether webdis supports redis cluster. If it is not supported, can you please let me know what is recommended way of configuring webdis with redis cluster - like to configure one webdis node per each redis node in cluster and sending queries to right webdis node depending on key hash?

Thanks

nicolasff commented 2 years ago

Hello,

Webdis does not support any of the client-based logic around hash slots like redirects and migrations. With Redis Cluster, the amount of processing that is moved from Redis to the client makes the client so complex that very few client libraries seem to implement all the logic defined in the "Cluster spec" document.

Webdis supports one Redis host and port, and does not "understand" the commands you send but simply translates the HTTP requests it receives into the Redis protocol and sends that. When a response is received, it similarly translates it back to a format of your choice (like JSON or MessagePack), but does not interpret the response like what would be needed to follow a MOVED response from Redis Cluster, for example.

One way to use Webdis with multiple Redis nodes is indeed to have one Webdis instance per Redis node, and either use a simple sharding model or actually handle the cluster-specific responses yourself. Doing the sharding yourself seems much easier than implementing the Redis Cluster logic.

In addition to the simplicity of a pool that uses something like consistent hashing, I'm also concerned about the reliability of Redis Cluster and the comments made by its primary author in response to simulations that demonstrated the possibility of data loss multiple times. With these deficiencies being fundamental properties of the protocol, I do not want to encourage Webdis users to deploy such a deeply unsafe system that would also need Webdis to implement a complex and half-baked protocol that shifts a major amount of work onto the client.

caojiajun commented 6 months ago

add a proxy which support redis-cluster between webdis and redis-cluster?

such as redis-cluster-proxy and camellia and predixy ?