0Pricing
Advanced Spring Boot 4: Event-Driven Architecture (Kafka) · Lekcja

Grupy konsumentów i równoważenie

Zrozumieją Państwo, jak grupy konsumentów Kafka skalują odczyt, jak przydzielane są partycje oraz co dzieje się podczas równoważenia, z uwzględnieniem Spring Kafka.

Grupy konsumentów i równoważenie to bezpłatna lekcja Advanced Spring Boot 4: Event-Driven Architecture (Kafka) na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Advanced Spring Boot 4: Event-Driven Architecture (Kafka), a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Advanced Spring Boot 4: Event-Driven Architecture (Kafka) zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Why Consumer Groups?

A consumer group lets multiple consumer instances share the work of reading a topic. Kafka assigns each partition to exactly one consumer in the group.

Group ID

Consumers join a group by sharing a group.id. Kafka tracks the offset position per group, so each group reads the topic independently.

spring.kafka.consumer.group-id=order-service

Partitions Drive Parallelism

The number of partitions sets the maximum parallelism. With four partitions, at most four consumers in a group can work at once.

topic orders: 4 partitions
group with 4 consumers -> 1 partition each

Extra Consumers Idle

If a group has more consumers than partitions, the extras sit idle. Scale partitions to scale consumption beyond the current limit.

6 consumers, 4 partitions -> 2 idle

What Triggers a Rebalance

A rebalance reassigns partitions when group membership changes.

  • A consumer joins or leaves
  • A consumer is considered dead
  • Partitions are added

Rebalance Cost

During a rebalance, consumers stop processing briefly while partitions are reassigned. Frequent rebalances hurt throughput.

Heartbeats and Liveness

Consumers send heartbeats. Missing them past session.timeout.ms marks a consumer dead and triggers a rebalance.

session.timeout.ms = 10000
heartbeat.interval.ms = 3000

Poll Loop Health

If processing between polls exceeds max.poll.interval.ms, the consumer is evicted. Keep per-message work bounded or increase the limit.

max.poll.interval.ms = 300000

Committing Offsets

Offsets record progress per partition per group. Spring Kafka can auto-commit or commit manually after successful processing for at-least-once delivery.

spring.kafka.consumer.enable-auto-commit=false

Cooperative Rebalancing

The cooperative rebalance protocol reassigns only the partitions that must move, avoiding a full stop-the-world reassignment.

partition.assignment.strategy=CooperativeStickyAssignor

Spring Kafka Listeners

A @KafkaListener joins the configured group automatically; running multiple app instances scales the group with no code change.

@KafkaListener(topics = "orders", groupId = "order-service")
void onOrder(Order o) { ... }

Quick Check

Reason about parallelism.

Recap

You learned that a consumer group shares a topic by assigning each partition to one consumer, so partition count caps parallelism. Rebalances reassign partitions when membership changes and briefly pause processing; heartbeats and poll intervals govern liveness. Cooperative rebalancing and manual offset commits keep Spring Kafka consumers efficient and reliable.

Często zadawane pytania

Czy lekcja „Grupy konsumentów i równoważenie” jest bezpłatna?

Tak — pełny tekst „Grupy konsumentów i równoważenie” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Advanced Spring Boot 4: Event-Driven Architecture (Kafka), przejdź na CoddyKit PRO. Kurs Advanced Spring Boot 4: Event-Driven Architecture (Kafka) zawiera 4 lekcji w sumie.

Co nauczysz się w „Grupy konsumentów i równoważenie”?

Zrozumieją Państwo, jak grupy konsumentów Kafka skalują odczyt, jak przydzielane są partycje oraz co dzieje się podczas równoważenia, z uwzględnieniem Spring Kafka. Ćwiczysz Advanced Spring Boot 4: Event-Driven Architecture (Kafka) z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Advanced Spring Boot 4: Event-Driven Architecture (Kafka)?

Nie wymagamy żadnego doświadczenia. Advanced Spring Boot 4: Event-Driven Architecture (Kafka) w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Grupy konsumentów i równoważenie”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Advanced Spring Boot 4: Event-Driven Architecture (Kafka)?

Tak. Każda lekcja Advanced Spring Boot 4: Event-Driven Architecture (Kafka) zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Przegląd architektury Kafki
  2. Tematy, partycje i offsety
  3. Konfiguracja lokalnej Kafki z Dockerem
  4. Grupy konsumentów i równoważenie
← Powrót do Advanced Spring Boot 4: Event-Driven Architecture (Kafka)