Updated on 2025-08-11 GMT+08:00

DCS Best Practices

This section summarizes best practices of Distributed Cache Service (DCS) in common scenarios. Each practice is given a description and procedure.

Table 1 DCS best practices

Best Practice

Description

Serializing Access to Frequently Accessed Resources

Describes how to implement locks on distributed applications with Redis. Serializing access to hot resources with locks avoids oversold inventory or disordered access in flash sales.

Ranking with DCS

Describes how to rank best-selling offerings using DCS for Redis.

Implementing Bullet-Screen and Social Comments with DCS

Describes how to display a key-value list, such as streaming or social comments, in descending order from different dimensions using DCS for Redis.

Merging Game Servers with DCS

Describes how to synchronize servers using Redis. During game server provisioning and merging, game developers must consider how to synchronize data among different servers. With the pub/sub message queuing mechanism of DCS for Redis, data changes on one game server can be published to Redis channels. Other game servers can subscribe to the channels to receive messages of changes.

Flashing E-commerce Sales with DCS

Describes how to satisfy high concurrency in e-commerce flash sales using DCS for Redis as the database cache. Clients can access Redis to query inventories and place orders.

Reconstructing Application System Databases with DCS

Describes how to migrate data, taking the example of migrating a table from a MySQL database to DCS for Redis.

Upgrading a Redis 3.0 Instance

Describes how to upgrade a DCS Redis 3.0 instance through data migration and IP switchover. You are advised to upgrade your DCS Redis 3.0 instances as soon as possible. DCS for Redis 4.0 and later are compatible with Redis 3.0.

Implementing Automatic DCS Redis Expansion During Peak Hours

DCS Redis instances support automatic memory and bandwidth scaling. Automatic scale-up or scale-out function with real-time metrics such as memory usage, network throughput, and number of concurrent connections. It is applicable to strong real-time scenarios such as e-commerce, gaming, and social networking, especially in peak hours.

Using Nginx for Public Access to DCS

Huawei Cloud DCS Redis 4.0 and later cannot be bound with elastic IP addresses (EIPs) and cannot be accessed over public networks directly. This best practice describes how to access a single-node, master/standby, read/write splitting, or Proxy Cluster DCS Redis 4.0, 5.0, or 6.0 instance by using a jump server. This solution is unavailable for public access to Redis Cluster instances.

Using SSH Tunneling for Public Access to DCS

Huawei Cloud DCS Redis 4.0 and later cannot be bound with EIPs and cannot be accessed over public networks directly. This best practice describes how to create an SSH tunnel as a proxy to connect your DCS instance and local computer to achieve proxy forwarding. In this way, single-node, master/standby, read/write splitting, and Proxy Cluster DCS Redis instances in a VPC can be accessed. This solution is unavailable for public access to Redis Cluster instances.

Using ELB for Public Access to DCS

Huawei Cloud DCS Redis 4.0 and later cannot be bound with EIPs and cannot be accessed over public networks directly. This best practice describes how to access a single-node, master/standby, read/write splitting, or Proxy Cluster instance or a node in a Redis Cluster instance through public networks by enabling cross-VPC backend on a load balancer.

Connecting a Client to DCS Through CCE

More and more applications are deployed in containers. This practice describes how to deploy Redis clients in cluster containers to access DCS through Cloud Container Engine (CCE).

Configuring Redis Client Retry

This best practice describes the retry configuration of the Jedis client. A complete automatic retry mechanism can greatly reduce the impact of infrastructure or running environment faults.

phpredis Retry

Phpredis is a common SDK for accessing Redis using a PHP script. Phpredis is only capable of basic connection and interaction. In scenarios where packets may be lost in a complex cloud network, or Redis master/standby switchover can be triggered when hardware is faulty, automatic reconnection and retry are unavailable. This document provides a practice for reliability reconstruction of a PHP script.

Detecting and Handling Big Keys and Hot Keys

This best practice describes how to find and optimize big keys and hot keys when using DCS for Redis.

Configuring a Redis Pipeline

This best practice describes how to use Redis pipelines. DCS for Redis supports the native pipelining.

Optimizing the Jedis Connection Pool

JedisPool is the connection pool of the Jedis client. This best practice describes how to configure JedisPool for better Redis performance and resource utilization.

DCS Data Security

This best practice provides actionable guidance for enhancing the overall security of using DCS.

Suggestions on Using DCS

This best practice describes suggestions on using DCS for Redis in terms of the service, data design, commands, SDKs, and O&M management.