From 7b148e51b5b4f71d79300f3a8c53200a94b2254d Mon Sep 17 00:00:00 2001 From: hwware Date: Wed, 23 Oct 2024 13:51:43 +0000 Subject: [PATCH] Second commit Signed-off-by: hwware --- ValkeyProxy.md | 62 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/ValkeyProxy.md b/ValkeyProxy.md index 2ee91a5..a0303bd 100644 --- a/ValkeyProxy.md +++ b/ValkeyProxy.md @@ -31,23 +31,68 @@ Therefore, we need a proxy to make the customer unaware of the above problems, a 2. Shield the functional/API differences between cluster mode and primary-replica mode, so that clients do not need to care about the underlying operating mode when using it. -3. Support multi-tenant mode + Now, If the client is directly connected to the server, then in primary-replica mode and cluster mode, the client may need to execute different code logic for the two modes in the following scenarios: + a. The client needs to save sharding metadata information in cluster mode. + b. When failover happens in these 2 different modes, the client needs to do different processing. + c. In cluster mode, if data migration occurs, the client must handle it. -4. Support multi-database mode even server runs as cluster mode + So if the client is only connected to the Proxy instead of server node, then as long as the client is not connected inSentinel mode, then when the client sends a command, it does not need to pay too much attention to the underlying connection mode. The Proxy will handle the execution of different modes for the client. -5. By using Proxy, clients have no perception for server failover, slot migration, adding/removing server nodes, proxy nodes and other exceptions. +3. Support multi-database mode even server runs as cluster mode -6. Support some enhancement proxy commands to count the time consumption or high CPU cost in memory: min/max/avg/p95/p99 +4. By using Proxy, clients have no perception for server failover, slot migration, adding/removing server nodes, proxy nodes and other exceptions. + + Through Proxy, we can avoid the client being directly connected to the underlying server stage. All client connections, reading and writing request will only be aware of the Proxy, so the client does not need the underlying Valkey server or +how data is storaged. + + Therefore, no matter whether failover happens, re-electing the primary node, resharding after adding a server node, or even adding a Proxy node, clients don't need to worry about it. + + It greatly simplifies the programming complexity of the client, allowing the client to focus more on business logic without caring too much about changes in the underlying architecture. + +5. Performance optimization + + We can use Proxy to optimize in different ways for different clients. For example, we can support Pipeline technology on the Proxy side to improve the overall system response efficiency. + + For some time-consuming or high CPU cost commands, we can make statistics in Proxy side, and for some results, such as min/max/avg/p95/p99 from memtier_benchmark or valkey_benchmark, clients can get timely statistical information. + + +6. Support audit log + + Audit log is a log that records the operations of clients accessing Proxy and Valkey server, and can provide storage, +query, and analysis functions. With the audit log function, Proxy will automatically log the read and write requests through +the proxy and standardize various information such as system security events, user access records, system operation logs, and system operation status in the information system. + + Cloud providers or system administrators can utilize this information to perform rich log statistical summary and +correlation analysis functions to achieve a comprehensive audit of information system logs. + +7. Provide reading/writing separation features + + In production environments, most scenarios involve more reading requests and less writing requests. By enabling +read-write separation feature in the Proxy, we can let the primary node focus on processing write operations and let the +replica handle read operations. It is very suitable for scenarios with relatively large read operations and can reduce the +pressure on the primary. + + The disadvantage of read-write separation is that there is no guarantee that there will be no delay in the primary +node. If there are large batches of data operations, the replica may experience a large delay. At this time, the data +obtained by the read operation may be inconsistent with the primary data. -7. Support audit log and reading/writing separation features 8. Provide a connection pool to facilitate client connection -9. For the customer's persistent connection, the proxy will not actively disconnect, but only returns the error message; If the client is disconnected, the connection will be disconnected immediately + Connection pooling can reduce the overhead associated with opening and closing connections and with keeping many +connections open simultaneously. This overhead not only includes memory needed to handle each new connection, also involves +CPU overhead to close each connection and open a new one. + + Connection pooling simplifies client application logic. Clients need to write application code to minimize the number of simultaneous open connections. + + We can also provide Valkey a feature similar to the connection multiplexing in RDS, also known as connection reuse. +With multiplexing, the RDS can perform all the operations for a transaction using one underlying database connection, then it can use a different connection for the next transaction. Clients can open many simultaneous connections to the proxy of RDS, and the proxy keeps a smaller number of connections open to the DB instance or cluster. Doing so further minimizes the memory overhead for connections on the database server. This technique also reduces the chance of "too many connections" errors. + + For the client's persistent connection, the connection will not actively disconnect, but only returns the error message; If the client is disconnected actively, the connection will be disconnected immediately. -10. Support CLIENT LIST etc commands aggregate return: return the client of all proxy nodes +9. Support CLIENT LIST etc commands aggregate return: return the client of all proxy nodes -11. Some commands such as set and zset are supported for aggregation processing across slot cluster connections +10. Some commands such as set and zset are supported for aggregation processing across slot cluster connections ## Specification @@ -64,3 +109,4 @@ Therefore, we need a proxy to make the customer unaware of the above problems, a ## References https://github.com/RedisLabs/redis-cluster-proxy +https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.howitworks.html