본문 바로가기
Data Engineering/Kafka

Kafka의 정확히 한 번 전달(exactly-once delivery)

by devson 2022. 3. 19.

분산 시스템 환경에서는 특히 EDA(Event-Driven Architecture)를 갖는 시스템 환경이라면

Message Broker를 사이에 두고 각 서비스가 메세지를 주고 받을 것이다.

 

이러한 아키텍처는 결합도를 낮추는 측면에서 엔지니어링에 장점을 갖지만 그와 동시에 여러가지 풀기 힘든 숙제들이 생기게된다.

분산 시스템에서는 오직 2가지 문제 밖에 없다.

2. 정확히 한 번 전달

1. 보장된 메세지 순서

2. 정확히 한 번 전달

 

이 글에서 말하고 싶은 내용은 Exactly-once delivery, 즉 정확히 한 번 전달이다.

 

분산 시스템 환경에서는 정확히 한 번 전달은 불가능하다라는 주장의 글이 있다.

https://bravenewgeek.com/you-cannot-have-exactly-once-delivery/

 

You Cannot Have Exactly-Once Delivery

I’m often surprised that people continually have fundamental misconceptions about how distributed systems behave. I myself shared many of these misconceptions, so I try not to demean or dismi…

bravenewgeek.com

비록 2015년도에 작성된 글이긴 하지만 메세지 전달 방식의 가능성에 대한 주장은 위 글에서 처음 보았고 그 논조 또한 굉장히 강하기 때문에 굉장히 흥미로웠다.

아래는 글의 일부를 발췌하였다.

Every major message queue in existence which provides any guarantees will market itself as at-least-once delivery.
현존하는 모든 메이저 메세지 큐는 at-least-once(적어도 한 번) 전달 보장을 제공한다고 스스로를 마케팅한다.

If it claims exactly-once, it’s because they are lying to your face in hopes that you will buy it or they themselves do not understand distributed systems.
만약 정확히 한 번을 얘기한다면, 당신이 그들의 제품을 살거라는 희망을 가지고 당신 면전에 거짓말을 하는 것이거나
그들 스스로 분산 시스템을 이해하지 못하기 때문이다.

Either way, it’s not a good indicator.
어느 쪽이든 간에, 좋은 지표는 아니다.

 

하지만 2017년도에 Kafka를 개발하고 있는 Confluent 사의 블로그에 Exactly-Once Semantics Are Possible: Here’s How Kafka Does It 라는 제목과 해당 기능의 릴리즈를 알리는 글이 올라왔다.

 

Exactly-once Semantics is Possible: Here's How Apache Kafka Does it

Exactly-once is a hard problem to solve, but we've done it. Available now in Apache Kafka 0.11, exactly-once semantics.

www.confluent.io

또한 글에서 성능적인 타협을 하지 않았음을 얘기하기도 한다.

 

과연 불가능하다는 측의 주장에서 처럼 허황된 거짓말일까?

그러기엔 Kafka는 이제 엔터프라이즈 개발 환경에서 de-facto가 되었고 수 많은 유저들이 거짓말을 알아차리지 못하진 않을 것이다.

또한 관련하여 지속적인 노력을 확인 할 수 있다.

https://www.confluent.io/blog/simplified-robust-exactly-one-semantics-in-kafka-2-5/

 

Apache Kafka’s Exactly-Once Semantics Are Now Easier & More Robust

Kafka 2.5 brings important improvements to exactly-once semantics: enhanced producer error handling and simplified transactional APIs for more powerful, simplified production use cases.

www.confluent.io

 

정확히 한 번 전달을 가능하게 하는 카프카의 알고리즘을 깊게 확인해보진 않았지만,

성능적인 면에서 크게 불이익이 없다면 exactly-once delivery를 굳이 마다할 일은 없지 않을까 싶다.

물론 exactly-once delivery가 exact 하다면 말이다 :)

 

댓글