Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MTC2018 - Why Are We Trying to Turn Payment Processing Into a Microservice?

mercari
October 04, 2018

MTC2018 - Why Are We Trying to Turn Payment Processing Into a Microservice?

Speaker: Yuichiro Saito

Merpay will provide users with the means to use their Mercari sales balance as a form of electronic money. This feature will of course be available for shopping on Mercari itself, but in order to do that, we have to face the issue of processing payments over Mercari. A monolithic program that has been built up over years now finds itself confronted with the challenge of implementing a new method of payment. To resolve this, we are taking a Go Bold approach of moving to microservices, but many difficulties lie within. In this session, Saito will talk about:
1) Why we decided to make the move to microservices
2) Deciphering the control flow of complex intertwined switch statements
3) The battle with potential errors caused by distributed transactions
4) How to reduce the effect on accounting systems"

mercari

October 04, 2018
Tweet

More Decks by mercari

Other Decks in Technology

Transcript

  1. Why Are We Trying to Turn Payment Processing Into a

    Microservice? Yuichiro Saito Software Engineer (Backend)
  2. Specifically, with regard to payment processes... • Existing payment processes

    aren’t scalable • New electronic payments need to be added • Only a limited number of people understand the payment processes This could hinder our growth.
  3. Problems • The current structure of payment processes is not

    scalable. • It’s become necessary to develop loose coupling between the electronic payment services in development. Solutions • Migrate to microservices using the grpc interface • Reimplement payment processing (PaymentService) • At the same time, move toward a sparse organizational structure
  4. Results Achieved • Better maintainability • Ability to separate responsbilities

    • Easier to add new payment methods • Increased number of people who understand payment processing through reimplementation
  5. But it’s still too early to celebrate! Let’s take another

    look at the current payment processing.
  6. payment->consume() is executed as an independent process. If point payment

    and card payment occur simultaneously and one of them fail, the result will be incorrect.
  7. Solution 1: Separate 1. Authorize payment method. 2. Continue the

    purchase process in a state where payment abilities are guaranteed. 3. If no errors, finalize payment. 4. If there are errors, release authorization of payment method. Idempotency of the process is guaranteed.
  8. Characteristics • Asynchronous processing is possible. • Automatic re-queuing and

    retry upon failure. High availability. • Can revert the state of unrecoverable failures. The successive addition of new payment methods also becomes possible. compensating transaction Solution 2: State Machine retry retry success point consump- tion card payment succ- ess start fail
  9. 1. When migrating payment systems, logs are processed in parallel

    in the current and new systems. 2. Parallel processing ends after the migration to PaymentService is complete. Payment Business Payment Service Current System Done DB DB Pub/ Sub
  10. Separating responsibilities allows for easier development and maintainability. Separation of

    responsibilities Flexible expansion Eliminating dependence As the system scales, reorganizing the organizational structure allows for independent teams. Through redesign, re-implementation and documentation, we can ensure that each task can be understood and completed by anyone.
  11. Understand the nature of distributed transactions during implementation of payment

    processing. Ensure that there is a method to revert to previous state.