当前位置:网站首页>Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis
Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis
2022-06-24 23:04:00 【Huawei cloud developer community】
This article is shared from Huawei cloud community 《 Huawei cloud enterprise class Redis Uncover secrets 16 period : Beyond open source Redis Of ACID" really " Business 》, author : gaussian Redis The official blog .
In daily life shopping、 traffic 、 Mobile games are inseparable from high-frequency financial consumption 、 Virtual trading . be familiar with MySQL Readers of , You must know about database transactions (Transaction) Can handle such key scenes , Transaction not only greatly simplifies the programming model of the upper business , Bring convenience to developers , At the same time, it also makes “ transaction ” And other core businesses are correct and reliable .
Actually ,Redis There's business , But the community version is only implemented in a simple version , Unable to meet ACID requirement , Therefore, the application is limited .
This article will introduce Huawei cloud enterprise database GaussDB(for Redis)( Hereinafter referred to as Gauss Redis) The transaction function of , Different from the Community Edition , gaussian Redis Provides satisfaction ACID Enterprise level transaction features .
1. What is business ?
Imagine the following scenario :
On a dark and windy night , A deal is under way . The player B Collection succeeded , but A But I didn't get the equipment .
Okay , a PK Be unavoidable .

Players can complete the transaction with a few clicks , But inside the underlying database , But at least 4 Key operations :

Just imagine , As in step 4 Failure , And the previous step succeeded , There will be logical confusion , This will lead to a disastrous user experience .
How do transactions solve such scenarios ? It depends on 4 Big characteristic :
- Atomicity (Atomicity): A set of operations is either all successful , Or it's a total failure .
- Uniformity (Consistency): That is to meet the established constraints , Ensure that the system does not deviate from the reasonable state . for example , If A、B Each has 50 Gold coins , Then the global total should always remain 100.
- Isolation, (Isolation): The execution of multiple transactions is isolated from each other , They don't influence each other .
- persistence (Durability): Committing a successful transaction should result in a permanent state change , Even if the power is off , Data should not be lost .
among , Consistency is the key , And atomicity 、 Isolation, 、 Persistence is all about consistency . Of course , In order to ensure the consistency of the overall system , It also needs the joint design and implementation of the business layer , This paper does not expand in detail .
that , Open source Redis What are the problems with the transaction ,GaussDB(for Redis) What is the enterprise transaction function of ? Let's take a look at it in detail .
2. From the four characteristics Redis The business of
2.1 Atomicity
Community Edition Redis
Open source Redis Transaction is a minimalist design , Rollback operation in case of transaction failure is not supported , Does not satisfy the atomicity of transactions .
In addition, there are the following questions :
- Incomplete team check : Check only simple syntax , Can't recognize key Wrong type of ;
- Incomplete error handling : Skip mistakes directly , Continue to execute subsequent commands .
GaussDB(for Redis)

As shown in the figure , Open source Redis The transaction still executes the following command when the first command is wrong , And Gauss Redis This avoids such problems .
- Each transaction is executed in Wrong judgment will be made before submission , If there is an error, the rollback logic will be triggered , Give up the previous operation , No impact on the original data
gaussian Redis While preserving the logic used by community transactions , At the bottom of the system Roll back Support for , It satisfies the atomicity of transactions .
2.2 Isolation,
Community Edition Redis
When a transaction is executed concurrently , Various isolation issues should be addressed .
Open source Redis The execution of commands is a single threaded design , Therefore, it can be guaranteed that No two transactions will be executed at the same time , The specific term :
- Open source Redis There is no isolation problem ;
- The cost is the reduction of performance and the impact on the overall throughput , Transactions can only be processed in a single thread , High interference with other requests .
GaussDB(for Redis)
gaussian Redis Is a multi-threaded architecture , Automatically slice the data internally , Preserve the isolation level of serialization within the same data fragment , At the same time, it greatly improves the concurrency of the whole instance .

2.3 persistence
Community Edition Redis
Open source Redis It's a pure memory design , Does not provide reliable data storage capacity . Data loss after power failure , Even if it turns on RDB or AOF, It can only recover part of the data to a certain extent , The specific term :
- RDB Some data will be lost in this way , Data can only be restored to the time of the last snapshot
- Even if it's AOF The way , Persistence is also a problem , From command execution to saving to hard disk , There is still a time difference
- AOF Slow recovery 、 Maintenance files are huge , The cost of maintenance and management will be very high , Reconstruction takes a long time
Taken together , Community Edition Redis The persistence ability of is limited , Not enough to support the persistence requirements of transactions .
GaussDB(for Redis)
gaussian Redis Adopt the design concept of separation of storage and calculation , The bottom layer uses high-performance distributed storage pool to save the full amount of data , combination RocksDB Storage engine , It can ensure the reliable storage of core data , Architecture diagram :

GaussDB(for Redis) Core strengths :
- Core data storage : Full data down ,3 Replica redundancy , Not afraid to lose data
- High availability : Second level fault , Even if N-1 Node failure , Full data is also available
- Low latency : Automatic hot and cold separation , Sub millisecond delay , can Hold Caching scenarios
- High throughput : All nodes are writable ,QPS Scalable horizontally , It can resist peak flow
- Strong consistency :3 Replica strong consistent synchronization , No dirty reading , Business is free from stepping on the pit
- Second expansion : for example ,8G To 64G Expansion only needs 1 second , And for business 0 influence
- lower the cost : The greater the amount of data, the better the price , Can really help users save costs
gaussian Redis Strong persistence guarantee , Support reliable storage of core data , It also provides a strong guarantee for the execution of transactions .
2.4 Uniformity
From the database level , Database through atomicity 、 Isolation, 、 Persistence to ensure consistency , Can say in ACID Consistency is the purpose of the transaction , Other features are means .
As mentioned above , Open source Redis There are problems with atomicity and persistence , Consistency is naturally not guaranteed . Under the guarantee of the above characteristics , Whether it is normal execution or there is a command failure scenario , gaussian Redis Transactions have reliable consistency .
2.5 conclusion
Through the above introduction, we introduce Gauss in detail from the four characteristics of transactions Redis The business of , Finally, a summary :

3. Conclusion
In recent years , With Redis As a representative of the KV Databases are gradually playing a role in more and more scenarios , And Gauss Redis As the flagship of Huawei cloud KV database , It can meet the reliable storage requirements of enterprise core data .
gaussian Redis Compared with the community version Redis There's a big boost , stay ACID Under the blessing of affairs , More available in “ stock ”、“ transaction ” And other key scenarios to simplify business design , Bring reliable data storage capacity .
4. appendix
- The author of this article : Huawei cloud database GaussDB(for Redis) The team
- Hangzhou / Xi'an / Shenzhen resume delivery :[email protected]
- Navigation products : https://bbs.huaweicloud.com/blogs/248875
Click to follow , The first time to learn about Huawei's new cloud technology ~
边栏推荐
猜你喜欢

Pousser l'information au format markdown vers le robot nail

Servlet
![[Wuhan University] information sharing of the first and second postgraduate entrance examinations](/img/ec/884e656a921e20a5679a2960c9ac4d.jpg)
[Wuhan University] information sharing of the first and second postgraduate entrance examinations

Analyze the implementation process of oauth2 distributed authentication and authorization based on the source code

Docker installation MySQL simple without pit

Annotation

Recommended movies: Northeast tiger, licorice pizza

2022 safety officer-b certificate examination question bank and answers

The core concept of JMM: happens before principle

The usage difference between isempty and isblank is so different that so many people can't answer it
随机推荐
Talk about GC mechanism often asked in interview
C language operators and expressions
剑指 Offer 13. 机器人的运动范围
Learn more about redis' eight data types and application scenario analysis
07_SpingBoot 实现 RESTful 风格
laravel 验证器的使用
Research Report on market supply and demand and strategy of China's solar charging controller industry
The difference between interceptor and filter
Learning bit segment (1)
Research Report on research and investment prospects of China's container coating industry (2022 Edition)
【nvm】
Panorama of enterprise power in China SSD industry
【武汉大学】考研初试复试资料分享
JWT(Json Web Token)
[untitled]
Solution to the login error of tangdou people
Market trend report, technical innovation and market forecast of solar roof system in China
Docker installation MySQL simple without pit
Leetcode: push domino (domino simulation)
MySQL kills 10 people. How many questions can you hold on to?