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

Introducing short-lived cache #62

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

asimpleidea
Copy link
Member

TL;DR

Put yourself in the service controller's POV:

  1. You need to register SVC1 on service registry
    • You create its namespace first
    • You register SVC1 on sr and put it on cache
  2. You need to register SVC2
    • HIT: you created the ns 2s ago: get it from cache and save a call to the sr
    • You register SVC2 and put it on cache
  3. You need to update SVC1:
    • HIT: ns is retrieved from cache
    • HIT: SVC1 does exist because it's still on cache
    • HIT: its endpoints are still on cache
    • You update SVC1 on sr (as well as invalidate and recreate cache)
  4. 5+ minutes pass
  5. You need to update SVC1:
    • MISS: Cache has expired so calls to the sr must be performed at each step
    • You update SVC1 on sr and recreate cache

Versioning

No breaking changes, so this belongs to v0.6.x

Description

This PR introduces a 5 minutes, light-weight, in-memory cache that saves some calls to the service registry by caching repetitive tasks. The very nature of the problem is hierarchical and repetitive: at each step, the object's parent's existence must be verified as well as its status, and this action "bubbles up" the deeper we go in the hierarchy -- e.g. if we are updating an endpoint we need to check that the service exists, but before that we need to do the same for the namespace.

Caching should save potentially many calls to the service registry, especially in those cases where a namespace has just been enabled and a lot of services must be registered, e.g. when registering 6 services only 1 call to the sr is needed to check for the namespace existence, making the whole process smoother and faster.

Data on cache is retained for only 5 minutes, after which a MISS occurs.

Rename "enable" to "monitor"

Signed-off-by: Elis Lulja <[email protected]>
This commit passes allowed annotations to the controllers, so they
have that reference instead of getting it from viper.

Signed-off-by: Elis Lulja <[email protected]>
FilterAnnotations is moved from utils package to controllers, because
basically that's the only place where it was actually used.

Signed-off-by: Elis Lulja <[email protected]>
This removes the old gcloud settings and only uses the new one.

Signed-off-by: Elis Lulja <[email protected]>
Signed-off-by: Elis Lulja <[email protected]>
@asimpleidea asimpleidea added the enhancement New feature or request label Sep 27, 2021
@asimpleidea asimpleidea self-assigned this Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant