You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: caffeine-bounded-cache-support/src/main/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedCache.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@
3
3
importcom.github.benmanes.caffeine.cache.Cache;
4
4
5
5
/**
6
-
* Caffein cache wrapper to be used in a {@link BoundedItemStore}
6
+
* Caffeine cache wrapper to be used in a {@link BoundedItemStore}
Copy file name to clipboardExpand all lines: caffeine-bounded-cache-support/src/main/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedItemStores.java
Copy file name to clipboardExpand all lines: docs/documentation/features.md
+26-20Lines changed: 26 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -722,9 +722,9 @@ to add the following dependencies to your project:
722
722
```xml
723
723
724
724
<dependency>
725
-
<groupId>io.fabric8</groupId>
726
-
<artifactId>crd-generator-apt</artifactId>
727
-
<scope>provided</scope>
725
+
<groupId>io.fabric8</groupId>
726
+
<artifactId>crd-generator-apt</artifactId>
727
+
<scope>provided</scope>
728
728
</dependency>
729
729
```
730
730
@@ -742,26 +742,32 @@ with a `mycrs` plural form will result in 2 files:
742
742
743
743
## OptimizingCaches
744
744
745
-
One of the ideas around operator pattern, is that all the relevant resources are cached, thus reconciliation is usually
746
-
very fast (especially ifit does not need to update resources) since it's mostly working with in memory state.
747
-
However or large clusters, caching huge amount of primary and secondary resources might consume lots of memory.
748
-
There are some semi-experimental (experimental in terms that it works, but we need feedback from real production usage)
749
-
features to optimize memory usage of controllers.
745
+
One of the ideas around the operator pattern is that all the relevant resources are cached, thus reconciliation is
746
+
usually very fast (especially ifno resources are updated in the process) since the operator is then mostly working with
747
+
in-memory state. Howeverfor large clusters, caching huge amount of primary and secondary resources might consume lots
748
+
of memory. JOSDK provides ways to mitigate this issue and optimize the memory usage of controllers. While these features
749
+
are working and tested, we need feedback from real production usage.
750
750
751
-
### Bounded Caches for Informers
751
+
### BoundedCachesforInformers
752
752
753
-
Limiting caches for informers - thus for Kubernetes resources, both controllers primary resource - is supported for now.
754
-
The idea with the implementation that is provided, is that resources are in the cache for a limited time.
755
-
So for use cases, when a resource is only frequently reconciled when it is created, and later no or
756
-
occasionally reconciled, will be evicted from the cache, since the resources are not accessed.
757
-
If a resource accessed in the future but not in the cache, the bounded cache implementation will fetch it from
758
-
the service if needed.
759
-
Note that on start of a controller all the resources are reconciled, for this reason explicitly setting a maximal
760
-
size of a cache might not be ideal. In other words it is desired to have all the resources in the cache at startup,
761
-
but not later if not accessed.
753
+
Limiting caches for informers - thus forKubernetes resources - is supported by ensuring that resources are in the cache
754
+
for a limited time, via a cache eviction of least recently used resources. This means that when resources are created
755
+
and frequently reconciled, they stay "hot" in the cache. However, if, over time, a given resource "cools" down, i.e. it
756
+
becomes less and less used to the point that it might not be reconciled anymore, it will eventually get evicted from the
757
+
cache to free up memory. If such an evicted resource were to become reconciled again, the bounded cache implementation
758
+
would then fetch it from the API server and the "hot/cold" cycle would start anew.
762
759
763
-
See usage of the related implementation using Caffein cache in integration tests for [primary resource](https://github.com/java-operator-sdk/java-operator-sdk/blob/10e11e587447667ef0da1ddb29e0ba15fcd24ada/caffein-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeinBoundedCacheNamespacedIT.java#L19-L19) and for an [informer](https://github.com/java-operator-sdk/java-operator-sdk/blob/10e11e587447667ef0da1ddb29e0ba15fcd24ada/caffein-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/sample/AbstractTestReconciler.java#L84-L93).
760
+
Since all resources need to be reconciled when a controller start, it is not practical to set a maximal cache size as
761
+
it's desirable that all resources be cached as soon as possible to make the initial reconciliation process on start as
762
+
fast and efficient as possible, avoiding undue load on the API server. It's therefore more interesting to gradually
763
+
evict cold resources than try to limit cache sizes.
764
764
765
-
See also [CaffeinBoundedItemStores](https://github.com/java-operator-sdk/java-operator-sdk/blob/10e11e587447667ef0da1ddb29e0ba15fcd24ada/caffein-bounded-cache-support/src/main/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeinBoundedItemStores.java#L22-L22)
765
+
See usage of the related implementation using [Caffeine](https://github.com/ben-manes/caffeine) cache in integration
766
+
tests
767
+
for [primary resources](https://github.com/java-operator-sdk/java-operator-sdk/blob/902c8a562dfd7f8993a52e03473a7ad4b00f378b/caffeine-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/sample/AbstractTestReconciler.java#L29-L29).
768
+
769
+
See
770
+
also [CaffeineBoundedItemStores](https://github.com/java-operator-sdk/java-operator-sdk/blob/902c8a562dfd7f8993a52e03473a7ad4b00f378b/caffeine-bounded-cache-support/src/main/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedItemStores.java)
0 commit comments