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
Clarified section on ResourceVersion and added sections on
avoiding continuously-repeated queries and on the
guidelines still applying when fieldSelectors are used
1. When LIST-ing, the load on etcd and API Server depends primarily on the number of objects that _exist_, not the number that are _returned_. So even if you are using a field selector to filter the list and retrieve only a small number of results, these guidelines still apply. (The only exception is retrieving a single object by `metadata.name`, which is fast.)
73
74
1. If your code needs to hold an up-to-date list of objects in memory,
74
75
avoid repeated LIST calls if possible. Instead consider using the
75
76
`Informer` classes that are provided in most Kubernetes client
76
77
libraries. Informers automatically combine LIST and WATCH functionality
77
78
to efficiently maintain an in-memory collection.
78
-
1. If `Informer`s don't suit your needs, try to use the API Server cache
79
-
when LISTing. To use the cache you must supply a `ResourceVersion`.
80
-
Read the [documentation about ResourceVersions](https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions) carefully to understand how it will affect the
81
-
freshness of the data you receive.
79
+
1. If `Informer`s don't suit your needs, consider whether you really need strong consistency. Do you really need to see the most recent data, up to the _exact moment in time_ when you issued the query? If you don't need that, set `ResourceVersion=0`. This will cause your request to be served from the API Server's cache instead of from etcd. Read the [documentation about ResourceVersions](https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions) carefully to understand how it will affect the freshness of the data you receive.
82
80
1. If you can't use `Informer`s AND you can't use the API Server cache,
83
81
then be sure to [read large lists in chunks](https://kubernetes.io/docs/reference/using-api/api-concepts/#retrieving-large-results-sets-in-chunks).
82
+
1. Additionaly, if you cannot use `Informer`s, you should also consider how _often_ your application LISTs the resources. In particular, after you read the last object in a large list, do not _immediately_ re-query the same list. Wait a while instead. Don't list more often than you need to.
84
83
1. Consider the number of instances of your client application which will be running. For instance,
85
84
there is a big difference between having
86
85
just one controller listing objects, versus having demonsets on every node
0 commit comments