Prompt

How do I process millions of events per second without dropping messages?

Technology / Data Infrastructure1 observationLast seen Oct 24, 2026

Latest observation

Oct 24, 2026OpenAI APIWeb search: off

To process millions of events per second reliably, you need to optimize the whole pipeline: ingest, buffer, process, and persist. The main goal is to avoid unbounded queues, blocking calls, and single-thread bottlenecks.

Core principles

1) Use a durable buffer in front of processing

Don’t send events directly to workers. Put them into a high-throughput log or queue:

  • Kafka
  • Pulsar
  • Redpanda
  • NATS JetStream
  • RabbitMQ (usually lower throughput than log-based systems at extreme scale)

This gives you:

  • backpressure handling
  • replay after failures
  • decoupling of producers and consumers

2) Partition for parallelism

Split events across many partitions/shards by a stable key:

  • user ID
  • device ID
  • account ID
  • session ID

Then scale consumers horizontally:

  • one partition can be consumed by one consumer in a group
  • more partitions = more parallelism
  • avoid hot partitions by choosing a good key

3) Keep the hot path minimal

In the critical ingestion path:

  • avoid heavy validation
  • avoid synchronous remote calls
  • avoid serialization overhead when possible
  • avoid per-event allocations
  • avoid logging each event on the hot path

Do only:

  1. receive event
  2. validate minimally
  3. enqueue/append to durable buffer
  4. acknowledge

4) Batch everything

Batching is essential:

  • batch network writes
  • batch disk writes
  • batch acknowledgements
  • batch downstream DB inserts
  • batch metric/log emission

This reduces syscall and network overhead dramatically.

5) Use async/non-blocking I/O

Use event-driven or async I/O rather than one thread per connection/event. Examples:

  • epoll/kqueue/io_uring
  • async runtimes
  • reactive streams

6) Make processing idempotent

Assume duplicates can happen. To avoid data loss while allowing retries:

  • include unique event IDs
  • deduplicate downstream if needed
  • design consumers to be idempotent

This lets you safely retry on failure.

7) Separate ingestion from heavy processing

Split the system into stages:

  • ingest
  • normalize
  • enrich
  • aggregate
  • store

Each stage can scale independently and use its own queue.

8) Control backpressure

When downstream slows down:

  • slow producers
  • shed low-priority load
  • spill to disk
  • scale consumers
  • alert before buffers fill

Never let memory grow without limit.

9) Persist checkpoints/offsets correctly

For stream processors:

  • commit offsets only after processing is durable
  • use transactional or exactly-once features where available
  • otherwise use at-least-once + idempotency

10) Monitor saturation points

Watch:

  • queue lag
  • consumer lag
  • p95/p99 latency
  • dropped events
  • retry rate
  • disk usage
  • GC pause time
  • CPU steal / network saturation
  • partition skew

You usually fail first due to one saturated component, not the whole system.


A practical architecture

Producers → Kafka/Pulsar → partitioned consumers → batch processor → DB/data lake/cache

Example:

  1. Producers publish events to Kafka with key = user_id
  2. Kafka partitions the stream across brokers
  3. Consumer group scales horizontally
  4. Each consumer processes in batches of 1k–10k events
  5. Results are written in bulk to storage
  6. Failed batches retry from the queue

If you truly need “no drops”

You need:

  • durable queueing
  • producer acknowledgements
  • retry logic
  • idempotent consumers
  • sufficient storage and retention
  • load shedding only for explicitly acceptable low-priority traffic

Note: “no drops” usually means no silent drops. Under extreme overload, you may still need to reject requests rather than accept and lose them.


Common mistakes

  • Using in-memory queues only
  • Synchronous writes to databases per event
  • Too few partitions
  • One giant lock around shared state
  • Excessive object creation and GC pressure
  • Not handling producer retries
  • Ignoring hot keys
  • No backpressure policy
  • Committing offsets before work is durable

Rule of thumb

If you want millions/sec reliably:

  • use a distributed log
  • batch aggressively
  • partition well
  • make consumers idempotent
  • scale horizontally
  • measure everything

If you want, I can also give you:

  1. a reference architecture diagram,
  2. a Kafka-based design, or
  3. a code-level implementation strategy for a specific language.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.