appform-io / ranger

Service Discovery for Java
Apache License 2.0
7 stars 12 forks source link

Adding a cache to the serviceFinder #19

Open koushikr opened 1 year ago

koushikr commented 1 year ago

Should we add a caching layer to the serviceFinder, where we apply the criteria? If there were thousands of nodes and a criteria has to run every time, the expense is unnecessary till the time the criteria changes or the registry nodeList changes. We could cache till the next reload of changes on the said criteria application if the criteria doesn't change.

For that though we may have to introduce an abstract RangerPredicate implementing Predicate with abstractPredicate having a name attribute, which we could use as a cacheKey. May help not to apply the same criteria multiple times on the same nodeList.

santanusinha commented 1 year ago

The refresh is every second or very few seconds .. the cache will get threashed like crazy leading to a whole bunch of garbage creation without any real need. The criteria hit should be scoped at service scope so should not have any impact as such.

On Thu, Mar 9, 2023 at 11:18 AM Koushik Ramachandra < @.***> wrote:

Should we add a caching layer to the serviceFinder, where we apply the criteria? If there were thousands of nodes and a criteria has to run every time, the expense is unnecessary till the time the criteria changes or the registry nodeList changes. We could cache till the next reload of changes on the said criteria application if the criteria doesn't change.

For that though we may have to introduce an abstract RangerPredicate implementing Predicate with abstractPredicate having a name attribute, which we could use as a cacheKey. May help not to apply the same criteria multiple times on the same nodeList.

— Reply to this email directly, view it on GitHub https://github.com/appform-io/ranger/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAME5Z3JE7KSQVPMCJDIYATW3FVLZANCNFSM6AAAAAAVUUN2WQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>