HomeRoadmapsSynthetic Day 3
Synthetic Test Data Track Β· Day 3 Β· 20 min

Microservice Event Stream & Kafka Synthesis
Synthetic Test Data Sprint β€” Day 3

Generate high-throughput temporal event streams, partition key hashing, simulated network jitter, and streaming watermark filters.

🌊 Streaming: Kafka Envelopes & WatermarksπŸ›‘οΈ Synthetic Data & Privacy Quality Architect
Event StreamsKafkaPartition HashingWatermarksOut-of-Order Events
About this lab

Event-driven microservices rely on Kafka or Kinesis topics where events arrive with partition keys, offsets, and non-deterministic network delays. In this lab, you build an event stream generator that simulates monotonic partition offsets, temporal jitter, and watermark filters.

πŸ“¦Sample Codebase & Working Solution (Day 3)Available Now
View on GitHub

The official reference codebase for Day 3 is hosted in the repository. Clone the repository and navigate to day-3-kafka-event-streams to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/777abhi/synthetic-test-data-roadmap.git
cd synthetic-test-data-roadmap/day-3-kafka-event-streams
🏭Production Context & Enterprise Implementation
πŸ’‘ Why We Are Doing This: Distributed stream processing (Flink, Spark, Kafka Streams) fails when events arrive out-of-order or late. Generating realistic synthetic event streams tests stateful window aggregations and late-arrival quarantine policies.
🏒 Real-World Production Usecase: Simulating high-volume IoT telemetry and financial checkout events across 4 Kafka partitions with configurable late-arrival probabilities.
βš™οΈ How Implemented in Production: Deterministic hash partitioner and watermark sliding-window filter in synthlab/event_streamer.py.
Phase 1

Inspect Event Stream Synthesis

Review partition key distribution, monotonic offset tracking, and watermark logic.

Step 3.1: View Event Streamer
Terminal β€” View Event Streamer
cat synthlab/event_streamer.py | head -45
Step 3.2: Event Streaming Unit Tests
test_day3.py
import unittest
from synthlab.event_streamer import EventStreamer, EventRecord

class TestDay3EventStreaming(unittest.TestCase):
    def setUp(self):
        self.streamer = EventStreamer(topic="orders.v1", partitions=4, seed=42)

    def test_partition_mapping_is_deterministic(self):
        p1 = self.streamer.partition_for_key("tenant_alpha")
        p2 = self.streamer.partition_for_key("tenant_alpha")
        self.assertEqual(p1, p2)

    def test_watermark_filter_drops_late_records(self):
        records = [
            EventRecord("e1", "orders.v1", 0, 0, "k1", 10000, {"seq": 1}),
            EventRecord("e2", "orders.v1", 0, 1, "k1", 15000, {"seq": 2}),
            EventRecord("e3", "orders.v1", 0, 2, "k1", 11000, {"seq": 3}),  # Late event
        ]
        accepted, dropped = EventStreamer.apply_watermark_filter(records, watermark_delay_ms=2000)
        self.assertEqual(len(dropped), 1)
Phase 2

Execute Day 3 Tests

Run the event streaming and watermark test suite.

Step 3.3: Run Test Suite
Terminal β€” Run Day 3 Tests
npm run test:day3
Day 3 Key Learnings
  • Engineered deterministic partition key hashing matching Kafka murmur/MD5 partition assignment.
  • Simulated temporal jitter and late-arriving events for stream processing robustness.
  • Implemented low-watermark threshold calculation to quarantine late data in streaming pipelines.

🧠 Knowledge Check

What is the purpose of a watermark delay threshold in streaming event pipelines?