In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to understand distributed transactions, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.
1. Let's start with the stress test, where 10, 000 buyers buy things at the store's Shang1, and each buyer's account pays for the shang1 account.
In this example, there are several steps: the buyer creates a commodity order = > send to the trading system = > the transaction receives a payment request to create a transaction order = > determine whether the buyer's account balance is sufficient = > deduct the buyer's balance = > increase the merchant's shang1 account balance = > bookkeeping = > return the payment success information.
After the stress test, the oracle waiting event was called up and found that the bottleneck was in the step of deducting the customer balance. Obviously, there was only one store, and the balance update had to be queued. 10,000 customers can buy things concurrently, deducting the customer balance can be concurrent, but the store balance can only be updated one by one. How to solve it?
Solution: divided into two steps, the first step, after deducting the buyer's balance, increase the buyer's frozen funds at the same time, and then immediately return the prompt to return the payment success information. But the merchants did not receive the money. The second step is to deduct the frozen funds of the buyer = > increase the merchant's shang1 account balance = > bookkeeping = > return the update successfully during the low peak period of the system. As long as the merchants are informed in advance that the peak transaction funds do not arrive in real time, but to ensure that the settlement is completed within a certain period of time, the merchants should also be understandable.
two。 Scenario: how many connections can an oracle database support? 4000. What if you need to connect after you go beyond these connections?
Answer: divide the system into two services and turn it into a 2oracle instance to provide business, then it becomes 8000 connections, which is fine.
3. Air ticket booking service of air ticket agents
The ticket service provides multi-way ticket booking service, which can book multiple flights at the same time, such as from Beijing to St. Petersburg, the first journey from Beijing to Moscow and the second journey from Moscow to St. Petersburg.
When users book tickets, they must want to book tickets for both flights at the same time. Booking only one flight does not make sense for users. Therefore, for such business services also put forward atomic requirements, if one flight reservation fails, the other flight needs to be able to cancel the reservation.
However, as airlines belong to external business relative to ticket agents, they only provide booking interface and cancellation interface, so it is extremely difficult to promote the transformation of airlines. Therefore, for such business services, you can use a compensated TCC distributed transaction solution, as follows:
The gateway service adds the Compensate interface to the original logic and is responsible for calling the cancellation interface of the corresponding airline.
When a user initiates a ticket reservation request, the ticket service first calls the reservation interface of each airline through the gateway Do interface, and if all flights are booked successfully, the whole distributed transaction is executed successfully; once a flight reservation fails, the distributed transaction rolls back, and the TCC transaction framework calls the Compensate compensation interface of each gateway, and then calls the cancellation API of the corresponding airline. In this way, the atomicity of the multi-way air ticket booking service can also be guaranteed.
4. Scenario: there is a counter on each product page of the website, which is used to calculate the number of visits each time, and the buyer adds 1 per visit. If it becomes a database update, it will directly drag down the database, but if you use cache data, you can easily solve this problem.
5. Scenario: the business scenario of account split is as follows. Accounts A, B, C, An and B located in three different sub-databases transfer a total of 80 CNY to C together:
(1) Try: try to execute the business.
(2) Confirm: confirm the execution of the business.
(3) Cancel: cancel the execution of business
Summary: whether you want to use TCC or not, whether or not to use TCC transactions depends on the following points:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.