Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable caching for some kafka topics?

Tags:

apache-kafka

So I have a scenario in kafka where there are 2 topics : A and B. Topic A's consumers are online (and need to consume data fast) and topic B's consumers are offline. Since topic B's consumers are offline, I don't need to cache any message related to topic B right now and want topic A to get the whole cache. Is it possible to disable caching for some kafka topics?

Edit: What I mean by caching is that the messages are being stored in memory and consumers are also reading from the memory (instead of the disk). In this scenario, I would want messages related to topic A to be cached in memory. And messages related to topic B don't have to be cached in memory. I want topic A to use the space in memory that would have been given to topic B

like image 970
brokendreams Avatar asked Jan 30 '23 17:01

brokendreams


2 Answers

You can disable caching for particular consumers:

If you would like to disable the caching for Kafka consumers, you can set spark.streaming.kafka.consumer.cache.enabled to false.

from the [Spark Streaming + Kafka Integration Guide] and I would suggest you follow it for further clarifications.

like image 102
Mathews Sunny Avatar answered Feb 23 '23 01:02

Mathews Sunny


Kafka relies heavily on the filesystem for storing and caching messages. The only configuration available in Kafka for caching is the client's streaming buffer size which is used to buffer incoming messages -- cache.max.bytes.buffering.

like image 27
alirabiee Avatar answered Feb 23 '23 00:02

alirabiee