The Real Fullstack

The Growing Kafka Lag

We scaled the consumer group from 12 to 48 pods. Why is the lag still climbing?

Ingénieur senior9 minLaboratoire de performanceSimulateur de flux
kafkakubernetespostgresqljava

Ce défi n'est pas encore traduit en Français. Vous lisez la version anglaise.

Mission:Stop the lag from growing with every component below 80% utilisation.Contexte · Objectifs d'apprentissage ▾

Quillfin ingests 4,000 click events per second from a 12-partition topic and writes each event to PostgreSQL with one INSERT. Lag grows during the day and recovers at night. The first reaction was to add consumer pods.

Mission: Stop the lag from growing with every component below 80% utilisation.

Objectifs d'apprentissage

  • Know that consumers beyond the partition count sit idle.
  • Find the real bottleneck downstream of the consumer.
  • Batch writes to raise throughput per database round trip.
Simulation
Simulé
clicks topicConsumer groupPostgreSQL
Lancer la simulation
@KafkaListener(topics = "clicks", concurrency = "12")public void onClick(Click c) {  jdbc.update("INSERT INTO clicks(...) VALUES (?, ?, ?)", c.user(), c.page(), c.at());  // 1 round trip per record}

Simplification

Steady-state queueing with a 40-connection database pool. Rebalancing pauses and skewed keys are ignored. Modèle pédagogique — les chiffres illustrent un comportement, ce ne sont pas des benchmarks.

Concepts

Utile avant celui-ci

Défis liés

Références