Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Avoid creating a lot of MetadataCache instances #663

Conversation

BewareMyPower
Copy link
Collaborator

Motivation

When there're a lot of topics, there could be a lot of MetadataCache instances in memory.

image

This bug was introduced from #488 because the Pulsar side adopted a new class MetadataCache as ZK cache. However, each time MetadataStore#getMetadataCache is called, a new MetadataCache instance will be created. In KoP, it means that each time a topic lookup is performed, a new MetadataCache instance will be created.

Modifications

Only call MetadataStore#getMetadataCache once when KoP starts and reuse the same MetadataCache instance for each KafkaRequestHandler instance.

@BewareMyPower BewareMyPower merged commit 6faba39 into streamnative:master Aug 18, 2021
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-many-metadata-caches branch August 18, 2021 14:59
BewareMyPower added a commit that referenced this pull request Aug 19, 2021
### Motivation

When there're a lot of topics, there could be a lot of `MetadataCache` instances in memory.

![image](https://user-images.githubusercontent.com/18204803/129903767-4b2f3961-c0e1-4ad5-88b0-7451ed41393a.png)

This bug was introduced from #488 because the Pulsar side adopted a new class `MetadataCache` as ZK cache.  However, each time `MetadataStore#getMetadataCache` is called, a new `MetadataCache` instance will be created. In KoP, it means that each time a topic lookup is performed, a new `MetadataCache` instance will be created.

### Modifications

Only call `MetadataStore#getMetadataCache` once when KoP starts and reuse the same `MetadataCache` instance for each `KafkaRequestHandler` instance.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants