This topic summarizes the FAQs related to the features of Cache for Redis.
Does Redis support read/write splitting?
Only the primary-secondary Redis instances support read/write splitting, while the single-node instances do not support it. For specific procedures, refer to Setting read/write splitting. Can I send read and write requests to the primary node only?
All read and write requests are sent to the primary node of Redis by default. The secondary node is for backup. For more details about read/write splitting, refer to Setting read/write splitting. tip
The primary-secondary Redis instances support read/write splitting. Single-node instances only contain a primary node and do not support read/write splitting. All read and write requests must be sent to the primary node.
What is the data persistence policy used by Redis?
Cache for Redis supports two instance types. Among them:
- AOF persistence policy is enabled for primary-secondary instances by default.
tip
Each Redis instance supports saving AOF files of the same size as the instance memory. For example, if the instance memory is 1 GiB, up to 1 GiB of AOF files can be saved in the instance and any portion exceeding 1 GiB will be deleted. For more details, refer to Constraints and limits. - Single-node instances do not have data persistence capabilities and do not support any data persistence policies. For details about the feature differences between the two instance types, refer to Feature differences.
What is the impact of failover?
The failover may have following impact:
- The node being switched has a temporary disconnection of a few seconds.
- The node being switched may be not writable briefly (less than 30 seconds), which aims to avoid potential data loss risks caused by failover and data double-write caused by the DNS cache.
tip
- Your application should have an automatic reconnection mechanism and the ability to handle exceptions. If not, the application will prompt an exception message during the failover of an instance, such as READONLY You can't write against a read only replica. For more details about failover, refer to Failover.
- Only Redis instances of the primary and secondary type support failover, not single node instances.
What is the execution time threshold for slow logs?
Cache for Redis supports viewing the slow logs of both server nodes and proxy nodes:
- Slow log of server node: The default threshold for execution time is 20 milliseconds. You can change the threshold for execution time through the slowlog-log-slower-than parameter. For specific procedures, refer to Setting instance parameters.
- Slow log of proxy node: The constant threshold for execution time is 500 milliseconds. You do not need to set any parameters.
Can Cache for Redis be used as a database?
Cache for Redis supports persistence. The persistence and primary-secondary replication of Redis are performed asynchronously, making it unsuitable for applications with high requirements for data reliability and consistency. You can put some data (for example, data with high real-time requirements) into Redis, which is used as a cache. It is not recommended to use Redis as a database.Cache for Redis is a memory-based database.
The business load and memory allocator can affect the amount of memory fragments. Excessive memory fragments can lower memory usage. Redis only supports basic data types such as String, List, Set, and ZSet. It does not support Integer, Data, or other commonly used data types. Redis does not support partition, schema, index, or foreign keys. The inlining and connection must be integrated to indirectly achieve multi-condition queries. It is generally not recommended to use Redis as an independent database.
What are the differences in the features supported by primary-secondary instances and single-node instances?
Refer to the table below for the differences in the features of single-node instances and primary-secondary instances.