티스토리 뷰
ByteByteGo 의 정기메일 <EP106: How Does JavaScript Work?> 에서 발췌한 부분이다.
Error handling is one of the most important aspects of building reliable systems.
Today, we will discuss an important topic: Can Kafka lose messages?
A common belief among many developers is that Kafka, by its very design, guarantees no message loss. However, understanding the nuances of Kafka's architecture and configuration is essential to truly grasp how and when it might lose messages, and more importantly, how to prevent such scenarios.
The diagram below shows how a message can be lost during its lifecycle in Kafka.
- Producer
When we call producer.send() to send a message, it doesn't get sent to the broker directly. There are two threads and a queue involved in the message-sending process:
1. Application thread
2. Record accumulator
3. Sender thread (I/O thread)
We need to configure proper ‘acks’ and ‘retries’ for the producer to make sure messages are sent to the broker. - Broker
A broker cluster should not lose messages when it is functioning normally. However, we need to understand which extreme situations might lead to message loss:
1. The messages are usually flushed to the disk asynchronously for higher I/O throughput, so if the instance is down before the flush happens, the messages are lost.
2. The replicas in the Kafka cluster need to be properly configured to hold a valid copy of the data. The determinism in data synchronization is important. - Consumer
Kafka offers different ways to commit messages. Auto-committing might acknowledge the processing of records before they are actually processed. When the consumer is down in the middle of processing, some records may never be processed.
A good practice is to combine both synchronous and asynchronous commits, where we use asynchronous commits in the processing loop for higher throughput and synchronous commits in exception handling to make sure the the last offset is always committed.
'아카이브' 카테고리의 다른 글
[아카이빙] 25 Papers That Completely Transformed the Computer World (0) | 2024.05.12 |
---|
- Total
- Today
- Yesterday
- S4
- Java
- 백준
- S1
- tree
- CPU
- tomcat11
- 개발 공부 자료
- core c++
- 톰캣11
- 연관관계 편의 메서드
- 객체 변조 방어
- reader-writer lock
- servlet
- thread
- Dispatcher Servlet
- condition variable
- sleep lock
- 엔티티 설계 주의점
- generic sort
- pocu
- 논문추천
- JPA
- PS
- generic swap
- C
- Spring MVC
- Memory
- 이진탐색
- OOP
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |