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-2
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-20
Original file line number
Diff line number
Diff line change
@@ -739,9 +739,9 @@ to add the following dependencies to your project:
739
739
```xml
740
740
741
741
<dependency>
742
-
<groupId>io.fabric8</groupId>
743
-
<artifactId>crd-generator-apt</artifactId>
744
-
<scope>provided</scope>
742
+
<groupId>io.fabric8</groupId>
743
+
<artifactId>crd-generator-apt</artifactId>
744
+
<scope>provided</scope>
745
745
</dependency>
746
746
```
747
747
@@ -759,26 +759,32 @@ with a `mycrs` plural form will result in 2 files:
759
759
760
760
## OptimizingCaches
761
761
762
-
One of the ideas around operator pattern, is that all the relevant resources are cached, thus reconciliation is usually
763
-
very fast (especially ifit does not need to update resources) since it's mostly working with in memory state.
764
-
However or large clusters, caching huge amount of primary and secondary resources might consume lots of memory.
765
-
There are some semi-experimental (experimental in terms that it works, but we need feedback from real production usage)
766
-
features to optimize memory usage of controllers.
762
+
One of the ideas around the operator pattern is that all the relevant resources are cached, thus reconciliation is
763
+
usually very fast (especially ifno resources are updated in the process) since the operator is then mostly working with
764
+
in-memory state. Howeverfor large clusters, caching huge amount of primary and secondary resources might consume lots
765
+
of memory. JOSDK provides ways to mitigate this issue and optimize the memory usage of controllers. While these features
766
+
are working and tested, we need feedback from real production usage.
767
767
768
-
### Bounded Caches for Informers
768
+
### BoundedCachesforInformers
769
769
770
-
Limiting caches for informers - thus for Kubernetes resources, both controllers primary resource - is supported for now.
771
-
The idea with the implementation that is provided, is that resources are in the cache for a limited time.
772
-
So for use cases, when a resource is only frequently reconciled when it is created, and later no or
773
-
occasionally reconciled, will be evicted from the cache, since the resources are not accessed.
774
-
If a resource accessed in the future but not in the cache, the bounded cache implementation will fetch it from
775
-
the service if needed.
776
-
Note that on start of a controller all the resources are reconciled, for this reason explicitly setting a maximal
777
-
size of a cache might not be ideal. In other words it is desired to have all the resources in the cache at startup,
778
-
but not later if not accessed.
770
+
Limiting caches for informers - thus forKubernetes resources - is supported by ensuring that resources are in the cache
771
+
for a limited time, via a cache eviction of least recently used resources. This means that when resources are created
772
+
and frequently reconciled, they stay "hot" in the cache. However, if, over time, a given resource "cools" down, i.e. it
773
+
becomes less and less used to the point that it might not be reconciled anymore, it will eventually get evicted from the
774
+
cache to free up memory. If such an evicted resource were to become reconciled again, the bounded cache implementation
775
+
would then fetch it from the API server and the "hot/cold" cycle would start anew.
779
776
780
-
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).
777
+
Since all resources need to be reconciled when a controller start, it is not practical to set a maximal cache size as
778
+
it's desirable that all resources be cached as soon as possible to make the initial reconciliation process on start as
779
+
fast and efficient as possible, avoiding undue load on the API server. It's therefore more interesting to gradually
780
+
evict cold resources than try to limit cache sizes.
781
781
782
-
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)
782
+
See usage of the related implementation using [Caffeine](https://github.com/ben-manes/caffeine) cache in integration
783
+
tests
784
+
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).
785
+
786
+
See
787
+
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