Development and O&M Rules
This section describes usage rules of the GeminiDB Redis database based on Huawei's years of experience in cloud database development and O&M, so as to help you effectively evaluate and improve service system stability.
Development Rules
When developing a service program, you need to pay attention to the following development rules to prevent service instability caused by improper usage.
No. |
Development Rules |
Description |
---|---|---|
1 |
The service program must have a proper automatic reconnection mechanism. |
In scenarios for the specification change, patch upgrade, HA switchover, network link jitter, or packet loss, the connection between the service program and the DB instance may be interrupted for a short period of time. The service program must support automatic reconnection.
NOTE:
Use Jedis instead of Lettuce because Lettuce is not automatically reconnected after multiple requests time out. |
2 |
Provide a connection pool and configure sufficient connections for a service program. |
To prevent the program from failing to obtain connections when the number of concurrent requests increases sharply, you are advised to use a connection pool for the service program and configure proper connection pool parameters. For details about the recommended configuration of the connection pool of the client, see Configuring Parameters for a Client Connection Pool. |
3 |
The service program must have a proper command retry mechanism for important operations. |
When the connection is interrupted or the request times out, requests from the service program may fail to be executed within a short period of time. Therefore, a service fault tolerance mechanism is needed. Proper command retry intervals and times can ensure important data is successfully written or modified. |
4 |
A correct HA connection address needs to be used to prevent services from being affected by a single point of failure. |
When connecting a service program to a database through a private network, use a load balancer IP address to achieve HA. Do not directly connect the service program to an independent compute node.
NOTE:
If a database is accessed from a public network, do not directly connect the service program to an independent compute node. |
5 |
A connection pool needs to be used to avoid using a single connection or a large number of short connections. |
A single connection has HA risks. The performance of short connections is poor, and short connections consume a large number of CPUs and network resources, which may cause bottlenecks. Therefore, you are advised to use mainstream SDK connection pools to connect a service program to GeminiDB Redis instances. |
6 |
You are not allowed to run the KEYS command when there are more than 1,000 keys in an instance. |
The KEYS command is a typical high-risk command. It obtains all data in the entire instance at a time and returns the data to the client. If there are a large number of keys in an instance, running the KEYS command will block requests or make the instance unavailable. |
7 |
Do not set element values to excessively large or small values and ensure the number of elements contained in a single key is not too large. |
According to best practices, the size upper limit of a string key is 10 KB, the number of elements in a Hash, List, Zset, or Set key should be less than 5,000, and the size of a single element should be 1 KB or smaller.
NOTE:
Similar to the community Redis, GeminiDB Redis does not strictly restrict the storage of big keys. Therefore, you need to develop service programs within the rule scope. |
8 |
A single command does not contain many elements at a time. Too large network packets cannot be generated by a single command. |
|
9 |
Properly distribute keys to avoid performance bottlenecks in hotspot keys or hash tags. |
Frequent access to a single key or a group of keys with the same hash tags may cause hot key problems, which may cause bottlenecks such as compute resource skew, request queuing, and slow response. Hot keys are usually created due to insufficient key splitting in service design. Therefore, service splitting needs to be optimized.
NOTE:
Negative examples:
|
10 |
Run less than 100 packaging commands at a time using the pipeline. |
Do not include a large number of commands in a pipeline.
Using pipelines improperly may cause bottlenecks in CPU and bandwidth resources and block requests.
NOTE:
Compared with the community Redis, GeminiDB Redis does not strictly restrict the use of pipelines. Therefore, you need to develop a service program within the rule scope. |
11 |
Do not use time-consuming code in Lua scripts. |
When using LUA scripts, excessive command execution times and time-consuming statements such as long-time sleep and large loop statements should be avoided. |
12 |
Do not pack too many commands in a transaction. |
When using a transaction, do not pack too many commands or complex commands in a single transaction. If a transaction contains too many commands, requests are blocked, or the instance may become abnormal. |
13 |
Different data types cannot use the same key. |
The community Redis allows no use of the same key in different data types. Although GeminiDB Redis has no requirements for this, avoid using the same key in different data types during program development to ensure the program is clear and easy to maintain. |
14 |
Exercise caution when running batch deletion commands. |
Do not delete too much data (tens or hundreds of thousands of elements) of the LIST and ZSET types via a single batch deletion command (for example, LREM, LTRIM, and ZREMBYSCORE). Deleting a large amount of data may take a long time, affecting other commands. Processes causing OOM may restart and the instance may be abnormal. In extreme scenarios, service processes may fail to be started repeatedly. |
O&M Rules
During routine O&M, you need to pay attention to the following O&M rules to prevent potential risks and master key emergency solutions.
No. |
Rule |
Description |
---|---|---|
1 |
Ensure that the phone number and email address bound to your Huawei Cloud account are valid so that you can receive notifications in a timely manner. |
Huawei Cloud will send notifications to you through websites, emails, SMS messages, or internal messages in scenarios for changes, upgrades, and fault notifications. Ensure that the contact information bound to your account is valid. |
2 |
Subscribe to major alarms. |
|
3 |
When the LB address is used for access, you need to configure access control instead of security groups. |
A load balancer address does not support security groups. After instance creation is complete, configure IP address access control. If no whitelist is configured, all IP addresses that can communicate with the VPC can access the instance. |
4 |
Configure autoscaling for instances. |
GeminiDB Redis supports autoscaling, which effectively prevents sudden data volume surge. Enable autoscaling by referring to Configuring Auto Scale. |
5 |
Keep the load at the healthy level. |
|
6 |
Rename high-risk commands. |
Disable or rename high-risk commands such as FLUSHALL, or KEYS to enhance instance security. For details, see Renaming Commands. |
7 |
Exercise caution when performing the FLUSHALL operation during account management. |
|
8 |
Perform periodical online diagnosis of big keys. |
You can periodically view the big key diagnosis report of the instance on the console to view keys that are the most frequently accessed in the Redis database. For details, see Big Key Diagnosis. |
9 |
Run the DBSIZE command after data migration. |
Running DBSIZE can ensure data consistency. For example, if there are no expired keys, you can run DBSIZE several minutes after data is imported to obtain the accurate number of keys and ensure data consistency. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot