프로듀서가 메시지를 보낼 때 예외가 난다.
org.apache.kafka.common.errors.RecordTooLargeException:
The message is 2097164 bytes when serialized which is larger than 1048576,
which is the value of the max.request.size configuration.
브로커 쪽에서 거부되면 메시지가 다르다.
org.apache.kafka.common.errors.RecordTooLargeException:
The request included a message larger than the max message size the server will accept.
메시지 하나의 크기가 경로 어딘가의 한도를 넘었다. 한도는 네 군데에 따로 있고, 가장 작은 값이 실제 한도가 된다.
| 위치 | 항목 | 기본값 |
|---|---|---|
| 프로듀서 | max.request.size |
1 MiB |
| 브로커 | message.max.bytes |
1 MiB |
| 토픽 | max.message.bytes |
브로커 값 상속 |
| 컨슈머 | max.partition.fetch.bytes |
1 MiB |
buffer.memory를 올리는 것으로는 해결되지 않는다. 버퍼는 전송 대기 총량이고, 이 오류는 개별 레코드 크기 때문에 난다.
예외 메시지에 max.request.size 가 나오면 프로듀서, the server will accept 가 나오면 브로커·토픽 쪽이다.
# 토픽에 걸린 값 확인
/opt/kafka/bin/kafka-configs.sh --bootstrap-server kafka01:9092 \
--describe --entity-type topics --entity-name <토픽>
# 브로커 기본값 확인
/opt/kafka/bin/kafka-configs.sh --bootstrap-server kafka01:9092 \
--describe --entity-type brokers --entity-name 1
전체를 올리기보다 필요한 토픽만 올리는 편이 낫다. 재기동이 필요 없다.
/opt/kafka/bin/kafka-configs.sh --bootstrap-server kafka01:9092 \
--alter --entity-type topics --entity-name <토픽> \
--add-config max.message.bytes=10485760
max.request.size=10485760
받는 쪽도 올려야 읽을 수 있다.
max.partition.fetch.bytes=10485760
/opt/kafka/bin/kafka-configs.sh --bootstrap-server kafka01:9092 \
--describe --entity-type topics --entity-name <토픽>
큰 메시지를 그대로 보내는 것이 맞는지 먼저 따진다. 수 MB 짜리 메시지는 브로커 메모리와 복제 대역폭을 크게 쓴다.
compression.type=lz4)으로 한도 아래로 들어오는 경우도 있다. 한도는 압축 후 크기 기준이다.max.request.size 와 관련 항목.max.partition.fetch.bytes.