Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka GlobalKTable Latency Issue

I have a topic which is read as GlobalKTable and Materialized in a store. The issue is if I update a key on the topic and then read from store, for a while(~0.5sec) I get the old value.

What could be the reason for this issue?

Is it that globalktable stores the data in rocksDB per application instance so if the key on another partition is updated it takes some time to pull data from all partitions and update its local rocksDB. If not, please explain how does globalktable store maintain its state internally?

How can the above issue be resolved ? Should we not use globalktable in such scenarios where consistency is expected to match that of say a mysql database?

like image 364
Nidhi Kaushal Avatar asked Jan 09 '19 06:01

Nidhi Kaushal


People also ask

How does Kafka achieve low latency?

Kafka can achieve around millisecond latency, by using synchronous messaging. With synchronous messaging, the producer does not collect messages into a patch before sending.

What is the latency of Kafka?

Kafka was traditionally used for high throughput rather than latency-sensitive messaging, but it does have a low-latency configuration. (Mostly setting linger.ms=0 and reducing buffer sizes). In this configuration, you can get below 1-millisecond latency a good percentage of the time for modest throughputs.

What is Kafka GlobalKTable?

Only the Kafka Streams DSL has the notion of a GlobalKTable . Like a KTable, a GlobalKTable is an abstraction of a changelog stream, where each data record represents an update.

What is grace period in Kafka streams?

« Kafka Summit Americas 2021. The grace period is a parameter of windowed operations such as Window or Session aggregates, or stream-stream joins. This configuration determines how long after a window ends any new data will still be processed.


1 Answers

Is it that globalktable stores the data in rocksDB per application instance so if the key on another partition is updated it takes some time to pull data from all partitions and update its local rocksDB. If not, please explain how does globalktable store maintain its state internally?

Absolutely yes. There is always some latency until Kafka Streams poll() the topic again and updates is local RocksDB.

Should we not use globalktable in such scenarios where consistency is expected to match that of say a mysql database?

It depends on what guarantees you need -- if the producer writes into the GlobalKTable topic and the write was successful, this does not guarantee that a Kafka Streams application has consumed this write and has updated the GlobalKTable. Producers and Consumers are decoupled in Kafka by design.

like image 200
Matthias J. Sax Avatar answered Nov 15 '22 10:11

Matthias J. Sax