Event Driven Architecture: Organizing Services Using an Event Bus

Almaty Python Meetup #2

СА
Султан Абильдин
Ergeon.com

Когда сервисы общаются напрямую по HTTP, система быстро становится жёстко связанной: один упавший сервис тянет за собой остальные. Event-Driven Architecture предлагает другой подход — асинхронную реакцию на события через шину.

На примере обработки заказа (сгенерировать PDF, уведомить отдел продаж в Slack, отправить письмо клиенту) доклад показывает, чем событийная модель отличается от прямых вызовов и какой ценой даётся её гибкость.

Султан — Senior Software Engineer и Team Lead в Ergeon с опытом более 9 лет.

В докладе: — базовые понятия EDA: producer, consumer, event — где событийная модель уже встречается: Flux/Redux, event bus в Android, сигналы Django, шина ядра Linux — прямые HTTP-вызовы против асинхронной слабосвязанной коммуникации — плюсы и минусы: гибкость и масштабируемость против сложности отладки и латентности — как это устроено в Ergeon: Director bus, маршрутизация через YAML, SNS и SQS, бэкенд на Go — реальные трудности: лимит размера сообщений SQS, передача больших данных через S3, retry-логика и dead queue

Презентация

Слайд 1: Event-driven Architecture 1 / 16
Текст презентации

Слайд 1: Event-driven Architecture

Event-driven Architecture: Organizing Services Using an Event Bus December 23, 2023 Sultan A.

Слайд 2: Who I am?

Who I am? ● 9+ years experience ● Senior SE | Team lead @ Ergeon ● Father of 3 children

Слайд 3: EDA

EDA ● What is EDA? ● Common usage ● Examples ● Pros/Cons

Слайд 4: What is Event-Driven Architecture?

What is Event-Driven Architecture? Event-Driven Architecture (EDA) is a design paradigm in which a system reacts to and processes events or messages asynchronously. Base concepts: ● Producer - Store service ● Consumer - Notification service ● Event - "order:created" event

Слайд 5: Common Usage Patterns

Common Usage Patterns Frontend: ● Flux ● React Redux Android: ● Event bus General: ● Linux kernel bus ● PCI/PCI Express Django: ● Signals

Слайд 6: Example

Example Order processing workflow: ● Generate PDF for order ● Notify sales team in the slack channel ● Send confirmation email to customer ● Etc.

Слайд 7: Direct HTTP Requests

Direct HTTP Requests ● Synchronous communication ● Tightly coupled systems ● Direct data exchange between services

Слайд 8: Event-Driven

Event-Driven ● Asynchronous communication ● Loosely coupled systems ● Indirect, message-based communication

Слайд 9: Advantages and Challenges

Advantages and Challenges Pros: ● Flexibility: Easy to add or modify components without disrupting the system ● Resilience: Reduces risk of system failure due to decoupling ● Scalability: Handles high loads and traffic variations efficiently Cons: ● Complexity: Can be more complex to design and manage ● Debugging Difficulty: Tracing and debugging can be challenging ● Latency: Potential delays due to asynchronous processing

Слайд 10: Case study

Case study ● Ergeon Architecture ● Implementation details ● Challenges

Слайд 11: Director bus

Director bus ● Routing events ● Logging ● Filtering ● Concurrency ● Failure handling ● Timeout

Слайд 12: Implementation

Implementation ● Config routing with YAML config ● SNS for recording an event ● SQS as message broker ○ No message auto-deletion ● Backend on Go

Слайд 13: Challenges

Challenges ● SQS message size limitation ○ Sending big data over S3 files ● Failure handling ○ Retry logic ○ Sentry notification ○ Dead queue

Слайд 14: No Silver Bullet!

No Silver Bullet!

Слайд 15: Any questions?

Any questions?

Слайд 16: Thank you for

Thank you for your attention!

Другие доклады митапа