Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does kafka not use http?

According to the documention -

Kafka uses a binary protocol over TCP

Some people have asked why we don't use HTTP. There are a number of reasons, the best is that client implementors can make use of some of the more advanced TCP features--the ability to multiplex requests, the ability to simultaneously poll many connections, etc. We have also found HTTP libraries in many languages to be surprisingly shabby.

Are there any clear reasons because this didn't seem convincing?

like image 421
rnjai Avatar asked Sep 05 '26 16:09

rnjai


1 Answers

Kafka emphasizes performance.

Usually the overhead brought by HTTP over TCP is not big, as long as you keep your headers at a minimum size.

But if you have huge amount of small messages going back and forth, the overhead of HTTP should be considered.

The smaller your messages are, the larger percentage of size is of overhead.

--

Besides, the text-based HTTP protocol has so many features. Parsing HTTP request can be complicated, thus slower than optimized binary protocol.

(For example, even the simplest libmicrohttpd is complicated.)

like image 84
cshu Avatar answered Sep 07 '26 11:09

cshu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!