Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache subscriber to decrease query count #6822

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

lastpeony
Copy link
Contributor

@lastpeony lastpeony commented Nov 22, 2024

#6783

Subscriber cache implemented using Caffeine to decrease mongodb load on subscriber read.

Subscriber read is called many times on SubscriberBlockFilter.java for subscriber.isBlocked(), checkIsTimedBasedSubscriber() and for webrtc play/publish isSubscriberBlocked() of WebSocketEnterpriseHandler.java

I used Caffeine because it has useful optimization features such as expireAfterWrite

testing confirms that it works well.
SUBSCRIBER_CACHE_EXPIRE_SECONDS set to 30, it can be lowered for possible syncronization issues.

executed-query-count rest api end point added for integration testing.

Cluster integration test:
https://gitlab.com/Ant-Media/testcluster/-/merge_requests/102

@lastpeony
Copy link
Contributor Author

lastpeony commented Nov 25, 2024

We had a discussion with @mekya, we will count mongodb calls and use it in cluster integration test to verify cache approach reduces mongodb load.

Regarding to design, cache approach is approved and we will proceed with it.

@lastpeony
Copy link
Contributor Author

Cluster integration test added:
https://gitlab.com/Ant-Media/testcluster/-/merge_requests/102

@mekya mekya changed the title Subscriber cache Cache subscriber to decrease query count Nov 30, 2024
Copy link

sonarcloud bot commented Nov 30, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants