5 Event-Driven Architecture Pitfalls to Avoid

I am developer/code-reviewer/debugger/bug-fixer/architect/teacher/builder from dubai, uae
Search for a command to run...

I am developer/code-reviewer/debugger/bug-fixer/architect/teacher/builder from dubai, uae
No comments yet. Be the first to comment.
with T.A.C.T

Isolation is part of a database's ACID guarantees. It ensures that concurrent transactions don't affect each other. The goal is to maintain the state of the data as if transactions are run serially. H

You Should Tell Yourself

A URL shortener is a proxy service that provides a mapping between the short and full representation of a URL. The short URL has the advantage of being small. The service can also provide useful analy

Listening to the Mel Robbins's podcast on regrets was a 'ear'-opener. One can have reqrets of action or inaction. 4 types of reqrets foundation - should've done the work boldness - should've taken t

I needed to understand the gotchas in event-driven architecture before migrating more services. Wix's engineering team documented 5 painful lessons learned from moving over 2300 microservices from request-reply to event-driven patterns.
Writing to a database and firing an event isn't atomic. If either the DB or message broker fails, you get data inconsistency.
Solutions:
Resilient producer that retries until the event reaches Kafka
CDC (Change Data Capture) with Debezium - captures DB changes via binlog and produces them as events automatically
Event sourcing stores events instead of entity state. You reconstruct current state by replaying events. Sounds cool but adds serious complexity:
Need snapshots to avoid performance degradation
Harder to create generic libraries (unlike CRUD ORMs)
Only eventual consistency
Better approach: CRUD + CDC. Simple reads from the database, with CDC publishing changes for downstream materialized views. Get the benefits without the complexity.
Debugging distributed event flows is hard. Unlike HTTP chains, events scatter across topics and services.
# Add request context to event headers
event_headers = {
'requestId': request_id,
'userId': user_id
}
Automatically propagate these IDs through your event chain. Makes filtering logs and events trivial during incident investigation.
Events over 5MB kill broker performance. Three remedies:
Compression - Kafka and Pulsar support lz4, snappy. Broker-level compression beats application-level
Chunking - Split payloads into chunks with metadata for reassembly
Object store reference - Store payload in S3, pass URL in event
Most brokers guarantee at-least-once delivery. Events can be processed multiple times.
# Use optimistic locking with revisionId
def process_event(event):
revision_id = event['revisionId']
# Read current version
entity = db.get(event['entityId'])
if entity.revision_id != revision_id:
return # Already processed
# Update with new revision
entity.update(revision_id=revision_id + 1)
For Kafka, use topic-partition-offset as unique transaction ID.
Migrate gradually. Mix HTTP/RPC with event-driven patterns as needed. CDC is the sweet spot - ensures consistency without full event-sourcing complexity.
Context propagation (pitfall #3) is critical for operations. Fix that early.
Compression and transaction IDs are good defaults even if you don't hit pitfalls #4 and #5 yet.
Happy hackin'!