Performance-optimized exceptions and the handling of normal logic.

Source: Internet
Author: User
Tags commit

There is a trading business with multiple business logic, to give a simple example of a payment transaction that may have cash, shopping coupons, discount cards and the like to pay at the same time. The normal logic is that each payment type is a transaction, which requires multiple transactions to be opened at the same time, and if there are other combinations later, the transaction will be more.


In this case, if the transaction is abnormal, one idea is to save the successful transaction and commit the unsuccessful transaction the next time it is resubmitted.

This looks good and can save the overhead of a previously successful transaction when the exception is handled.

However, we need to know that in the case of 99.x% we do not require such a logic, such processing is each commit whether it is normal or retry to check whether there have been successfully committed transactions. This adds a burden to the normal business logic of 99.x%, so optimization can only happen by chance with abnormal logic and increase the burden of absolute majority of normal logic, and the result is counterproductive. So after the optimization we are in the normal logic of the direct linear processing, no longer breakpoint save. All transactions are resubmitted after an exception, although the overhead is greater in the exception logic, but overall performance is greatly improved. (Unless your business has a 50% chance of an exception)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.