SlideShare uma empresa Scribd logo
1 de 26
Asynchronous Processing
in Big System
Lê Minh Nghĩa
Solution Architect at Tiki.vn
Big System’s Targets
• High Performance
• High Scalability
• High Reliable
• Low Cost Maintenance
Problems
• IO Bottleneck
• Scale Processing
• Handle a Huge Concurrent Request
• Availability and Partition Fault Tolerance
• Deal with consistency and concurrency
Split to Scale
• If you can’t split, you can’t scale it
• From Monolithic System to Distributed System
• From One to Many Processing
• From One to Many Persistent
• From Single to Parallel Processing
• From Synchronous to Asynchronous
Data Replication
• Every nodes need a way to communicate with
other
• Data replication is the most important in
distributed system
• The reliability of a system depends on the way
data replication
Replicate Model
• Primary Data Backup
• State Machine Model
(Active Active Model)
What’s Reliable
Replication?
• No Lost Data
• Guarantee Ordering
• High Scalability
• Easy Integration
Message Queue
• Message Queue is the key to split and scale
system
• It’s the solution for reliable replication
• But It’s not simple as we think…
Message Queue
1. Guarantee No Lost Data
We usually do both:
- Write Data To DB
- Send Message To
Queue
Database
Message
Queue
Processing
Problems, In fact:
- Can Write But Can’t
Send
- Can Send But Cant’
Write
1. Guarantee No Lost Data
• Solutions:
• Use One Way data flow:
Process —> Database —> Message Queue
• Use Transaction Log to Dispatch Data Changes
1. Guarantee No Lost Data
2. Guarantee
Sending Ordering
• Problems:
• Each request sending out
one message at the
same time, in different
threads
• One of the messages can
be fail in sending
• That cause the messages
are not in ordering
2. Guarantee
Sending Ordering
• Use Transaction Log To Append Un-dispatched
Message in Order
• Asynchronous Sending Un-Dispatched Message
to Message Queue
2. Guarantee
Sending Ordering
Transaction
Undispatched
Message
Write
Polling
Worker
1. Poll Messages
Message Bus
2. Publish Messages
3. Remove Messages
3. Guarantee
Delivery Ordering
E2 E3 E4E1
Worker 1 Worker 2 Worker 3 Worker 4
- Events are dequeued in
concurrency by many
workers
- Message Queue can
guarantee first in first out
- The later event can be
processed faster than the
earlier event —> cause lost
ordering
3. Guarantee
Delivery Ordering
• Solutions:
• if use Rabbit MQ/Active MQ: use only one
consumer for a queue
• If use Kafka, Kafka guarantee ordering delivery
message per each partition. Only one thread of a
consumer group can receive message from a
partition
4. Idempotemcy Filtering
• This is about duplicate message
• A message can be delivery more than one time
• Example: can deposit twice because receive
deposit message twice
4. Idempotemcy Filtering
• Solutions:
• Use UUID/GUID v4 for message id
• Use timestamp or version of message to detect
duplicate
5. Versoning Message
• Replicated data is
always eventually
consistency
• Sometime we
need to know
about how stale
data is
V4 V3 V2V5
Write V5 Read V1
5. Versoning Message
• Use timestamp
• Use incremental version (integer)
• Guarantee increase version consistency when
write data
6. Non Blocking IO
• How to handle million
messages in a queue?
• Solutions:
• Processing message in
pipeline.
• Split processing in three
separated phases: receiving,
handling and completing
message
• Each phase is processing in
parallel
receiving
handling
completing
7. Capture Data Changes
• Is the way capture data changes of DB to
replicate data to Message Queue
• Use specific mechanism of DB to know the
changes of Data
MySQL Bin Log
• Decode My
SQL Bin Log
to know new
data changes
MySQL My SQL Binlog
Event Handler
Decode Bin Log
Message Queue
Postgresql Notification
• Use Postgres
Notification to
notify the
changes of
data
Postgresql
Notification
Receiver
Message Queue
Notify
Thank You
• Contact: Lê Minh Nghĩa
• Email: nghia.fit@gmail.com
• Facebook: /nghialeminh

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Sapo Microservices Architecture
Sapo Microservices ArchitectureSapo Microservices Architecture
Sapo Microservices Architecture
 
itlchn 20 - Kien truc he thong chung khoan - Phan 1
itlchn 20 - Kien truc he thong chung khoan - Phan 1itlchn 20 - Kien truc he thong chung khoan - Phan 1
itlchn 20 - Kien truc he thong chung khoan - Phan 1
 
Introducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring StatemachineIntroducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring Statemachine
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
 
Building Bizweb Microservices with Docker
Building Bizweb Microservices with DockerBuilding Bizweb Microservices with Docker
Building Bizweb Microservices with Docker
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2
 
Grokking Techtalk #39: How to build an event driven architecture with Kafka ...
 Grokking Techtalk #39: How to build an event driven architecture with Kafka ... Grokking Techtalk #39: How to build an event driven architecture with Kafka ...
Grokking Techtalk #39: How to build an event driven architecture with Kafka ...
 
Kafka: All an engineer needs to know
Kafka: All an engineer needs to knowKafka: All an engineer needs to know
Kafka: All an engineer needs to know
 
Saga about distributed business transactions in microservices world
Saga about distributed business transactions in microservices worldSaga about distributed business transactions in microservices world
Saga about distributed business transactions in microservices world
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
DDD - DuyLV - VINID - 17.07.2019
DDD - DuyLV - VINID - 17.07.2019DDD - DuyLV - VINID - 17.07.2019
DDD - DuyLV - VINID - 17.07.2019
 
ITLC HN 14 - Bizweb Microservices Architecture
ITLC HN 14  - Bizweb Microservices ArchitectureITLC HN 14  - Bizweb Microservices Architecture
ITLC HN 14 - Bizweb Microservices Architecture
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Introduction to Event-Driven Architecture
Introduction to Event-Driven Architecture Introduction to Event-Driven Architecture
Introduction to Event-Driven Architecture
 
LMAX Architecture
LMAX ArchitectureLMAX Architecture
LMAX Architecture
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
 

Semelhante a Asynchronous processing in big system

Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systems
sumitjain2013
 
Intern PPT Template FINAL
Intern PPT Template FINALIntern PPT Template FINAL
Intern PPT Template FINAL
Michael Gerhart
 

Semelhante a Asynchronous processing in big system (20)

Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systems
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Lecture-4_Process Management.pdf
Lecture-4_Process Management.pdfLecture-4_Process Management.pdf
Lecture-4_Process Management.pdf
 
DDB_lec_05_Concurrency_Control.pdf
DDB_lec_05_Concurrency_Control.pdfDDB_lec_05_Concurrency_Control.pdf
DDB_lec_05_Concurrency_Control.pdf
 
Megastore: Providing scalable and highly available storage
Megastore: Providing scalable and highly available storageMegastore: Providing scalable and highly available storage
Megastore: Providing scalable and highly available storage
 
Kafka at scale facebook israel
Kafka at scale   facebook israelKafka at scale   facebook israel
Kafka at scale facebook israel
 
IPC
IPCIPC
IPC
 
IPC
IPCIPC
IPC
 
9 fault-tolerance
9 fault-tolerance9 fault-tolerance
9 fault-tolerance
 
Architecting for the cloud elasticity security
Architecting for the cloud elasticity securityArchitecting for the cloud elasticity security
Architecting for the cloud elasticity security
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Monitoring microservices
Monitoring microservicesMonitoring microservices
Monitoring microservices
 
Best Features of Azure Service Bus
Best Features of Azure Service BusBest Features of Azure Service Bus
Best Features of Azure Service Bus
 
Reactive Messaging Patterns.
Reactive Messaging Patterns.Reactive Messaging Patterns.
Reactive Messaging Patterns.
 
Event Driven Microservices architecture
Event Driven Microservices architectureEvent Driven Microservices architecture
Event Driven Microservices architecture
 
Apache kafka- Onkar Kadam
Apache kafka- Onkar KadamApache kafka- Onkar Kadam
Apache kafka- Onkar Kadam
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
 
Intern PPT Template FINAL
Intern PPT Template FINALIntern PPT Template FINAL
Intern PPT Template FINAL
 
Event-driven architecture with Java technology stack
Event-driven architecture with Java technology stackEvent-driven architecture with Java technology stack
Event-driven architecture with Java technology stack
 
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Asynchronous processing in big system

  • 1. Asynchronous Processing in Big System Lê Minh Nghĩa Solution Architect at Tiki.vn
  • 2. Big System’s Targets • High Performance • High Scalability • High Reliable • Low Cost Maintenance
  • 3. Problems • IO Bottleneck • Scale Processing • Handle a Huge Concurrent Request • Availability and Partition Fault Tolerance • Deal with consistency and concurrency
  • 4. Split to Scale • If you can’t split, you can’t scale it • From Monolithic System to Distributed System • From One to Many Processing • From One to Many Persistent • From Single to Parallel Processing • From Synchronous to Asynchronous
  • 5. Data Replication • Every nodes need a way to communicate with other • Data replication is the most important in distributed system • The reliability of a system depends on the way data replication
  • 6. Replicate Model • Primary Data Backup • State Machine Model (Active Active Model)
  • 7. What’s Reliable Replication? • No Lost Data • Guarantee Ordering • High Scalability • Easy Integration
  • 8. Message Queue • Message Queue is the key to split and scale system • It’s the solution for reliable replication • But It’s not simple as we think…
  • 10. 1. Guarantee No Lost Data We usually do both: - Write Data To DB - Send Message To Queue Database Message Queue Processing Problems, In fact: - Can Write But Can’t Send - Can Send But Cant’ Write
  • 11. 1. Guarantee No Lost Data • Solutions: • Use One Way data flow: Process —> Database —> Message Queue • Use Transaction Log to Dispatch Data Changes
  • 12. 1. Guarantee No Lost Data
  • 13. 2. Guarantee Sending Ordering • Problems: • Each request sending out one message at the same time, in different threads • One of the messages can be fail in sending • That cause the messages are not in ordering
  • 14. 2. Guarantee Sending Ordering • Use Transaction Log To Append Un-dispatched Message in Order • Asynchronous Sending Un-Dispatched Message to Message Queue
  • 15. 2. Guarantee Sending Ordering Transaction Undispatched Message Write Polling Worker 1. Poll Messages Message Bus 2. Publish Messages 3. Remove Messages
  • 16. 3. Guarantee Delivery Ordering E2 E3 E4E1 Worker 1 Worker 2 Worker 3 Worker 4 - Events are dequeued in concurrency by many workers - Message Queue can guarantee first in first out - The later event can be processed faster than the earlier event —> cause lost ordering
  • 17. 3. Guarantee Delivery Ordering • Solutions: • if use Rabbit MQ/Active MQ: use only one consumer for a queue • If use Kafka, Kafka guarantee ordering delivery message per each partition. Only one thread of a consumer group can receive message from a partition
  • 18. 4. Idempotemcy Filtering • This is about duplicate message • A message can be delivery more than one time • Example: can deposit twice because receive deposit message twice
  • 19. 4. Idempotemcy Filtering • Solutions: • Use UUID/GUID v4 for message id • Use timestamp or version of message to detect duplicate
  • 20. 5. Versoning Message • Replicated data is always eventually consistency • Sometime we need to know about how stale data is V4 V3 V2V5 Write V5 Read V1
  • 21. 5. Versoning Message • Use timestamp • Use incremental version (integer) • Guarantee increase version consistency when write data
  • 22. 6. Non Blocking IO • How to handle million messages in a queue? • Solutions: • Processing message in pipeline. • Split processing in three separated phases: receiving, handling and completing message • Each phase is processing in parallel receiving handling completing
  • 23. 7. Capture Data Changes • Is the way capture data changes of DB to replicate data to Message Queue • Use specific mechanism of DB to know the changes of Data
  • 24. MySQL Bin Log • Decode My SQL Bin Log to know new data changes MySQL My SQL Binlog Event Handler Decode Bin Log Message Queue
  • 25. Postgresql Notification • Use Postgres Notification to notify the changes of data Postgresql Notification Receiver Message Queue Notify
  • 26. Thank You • Contact: Lê Minh Nghĩa • Email: nghia.fit@gmail.com • Facebook: /nghialeminh