News for hackers. Stuff that matters.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by francoismassot on Sunday October 22, 2023 @05:57PM (#37979462)
I heard several times that Kafka was put in front of elasticsearch clusters for handling traffic burst. You can also use Redpanda, Pulsar, NATS and other distributed queues.

One thing that is also very interesting with Kafka is that you can achieve exactly-once semantic without too much efforts: by keeping track of the positions of partitions in your own database and carefully acknowledging them when you are sure data is safely stored in your db. That's what we did with our engine Quickwit, so far it's the most efficient way to index data in it.

One obvious drawback with Kafka is that it's one more piece to maintain... and it's not a small one.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by pranay01 on Monday October 23, 2023 @12:36AM (#37981690)
Have you done/seen any benchmarks between Redpanda/NATS and Kafka for this use case?

Some folks in SigNoz community have also suggested NATS for this, but I have not deep dived into benchmarks/features yet

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by francoismassot on Monday October 23, 2023 @02:59AM (#37982372)
Unfortunately no :/
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by radicality on Monday October 23, 2023 @12:48AM (#37981746)
Exactly-once semantics of what specifically? Or do you mean at-least-once ?
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by francoismassot on Monday October 23, 2023 @03:02AM (#37982386)
Exactly-once semantic between Kafka and the observability engine.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by richieartoul on Monday October 23, 2023 @01:12AM (#37981867)
You have to do a bit more than that if you want exactly once end-to-end (I.E if Kafka itself can contain duplicates). One of my former colleagues did a good write up on how Husky does it: https://www.datadoghq.com/blog/engineering/husky-deep-dive/
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by francoismassot on Monday October 23, 2023 @03:06AM (#37982414)
Yeah, I was only talking about exactly once semantic between Kafka and Quickwit.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by viraptor on Monday October 23, 2023 @01:28AM (#37981934)
> exactly-once semantic without too much efforts: by keeping track of the positions of partitions in your own database and carefully acknowledging them when you are sure data is safely stored in your db

That's not really "exactly once". What happens when your system dies after it made sure the data is safely stored in the db and before ack-ing?

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by Svenskunganka on Monday October 23, 2023 @01:40AM (#37981996)
Depending on how you use the database it is. If you write the data as well as the offset to the DB in the same transaction, you can then seek to the offset stored in the DB after application restart and continue from there.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by viraptor on Monday October 23, 2023 @01:49AM (#37982031)
> after application restart and continue from there.

What if the application doesn't restart before the queue decides the message was lost and resends?

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by hashhar on Monday October 23, 2023 @02:27AM (#37982225)
In Kafka the "queue" is dumb, it doesn't lose messages (it's an append only durable log) nor does it resend anything unless the consumer requests it.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by viraptor on Monday October 23, 2023 @03:08PM (#37990159)
There has to be a retry system somewhere, otherwise you'd end up with a 0-or-more delivery system if the app crashes after picking up from the queue, but never processing or ack-ing.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by mirekrusin on Monday October 23, 2023 @01:51AM (#37982045)
You should drop "(...) and carefully acknowledging them when you are sure data is safely stored in your db (...)" part then, because it means it's not necessary, you don't rely on it.

One-or-more semantics + local deduplication gives one-and-only semantics.

In this case you're optimising local deduplication with strictly monotonic index.

One downside is that you leak internals of other system (partitions).

The other is that it implies serialised processing - you can't process anything in parallel as you have single index threshold that defines what has been and what has yet not been processed.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by Svenskunganka on Monday October 23, 2023 @02:36AM (#37982258)
I'm not the one who wrote the original comment, so I can't modify it. But one should still commit offsets because it is the happy-path; DB transaction successful? Commit offset. If the latter fails due to e.g application crash and you seek at startup to the partition offset stored in the DB + 1, you get exactly-once semantics. There's some more details, e.g you'd have to do the same during consumer group rebalance, and topic configuration also plays a role, for example if the topic is a compacted topic or not, and if you write tombstones, what its retention policy is.
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by mirekrusin on Monday October 23, 2023 @03:20AM (#37982487)
Yes, it's good option but it requires serialised processing in partition scope, which may or may not be desirable.

If one-and-only-one semantics are needed and processing should be parallel, other methods have to be used.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by robertlagrant on Monday October 23, 2023 @05:12AM (#37983283)
Presumably every exactly once processing scenario needs you to squeeze things through a serial pipe at some point, or you could have 2 messages with the same ID come in and be processed in parallel?
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by mirekrusin on Monday October 23, 2023 @05:45AM (#37983482)
Yes but scope/blocking/serialisation can be narrow or wide - ie. it can be per message id (highly parallel) or one for all messages of certain type/partition (not parallel).
Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by francoismassot on Monday October 23, 2023 @02:54AM (#37982344)
Good point: first you're right, we do the ack on Kafka but it's not necessary. Second, this is not what I wanted to stress... and I should have not used the verb "acknowledge". What we do is upload the data on S3, then we commit partitions + positions in what we call the metastore. I can't edit my comment unfortunately.

> One downside is that you leak internals of other system (partitions).

True, but we generalized the concept of partitions for other datasources, pretty convenient to use it for distributing indexing tasks.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by fulmicoton on Monday October 23, 2023 @04:56AM (#37983182)
> The other is that it implies serialised processing - you can't process anything > in parallel as you have single index threshold that defines what has been and > what has yet not been processed.

Fortunately Kafka is partitioned. You cannot work in parallel along partitions.

Also, you can streamline your process. If you are running your data through operation (A, B, C). (C on batch N) can run at the same time as (B on batch N+1), and (A on batch N+2)

We do both at quickwit.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by foota on Monday October 23, 2023 @02:05AM (#37982122)
Isn't exactly once delivery the kind of problem like the CAP thereom where it's not possible?

You can make the downstream idemptoent wrt what the queue is delivering, but the queue might still redeliver things.

Re:OpenTelemetry at Scale: Using Kafka to handle bursty traffic by ankitnayan on Monday October 23, 2023 @02:15AM (#37982164)