From: Aleš Mrázek Date: Thu, 11 Apr 2024 13:54:25 +0000 (+0200) Subject: datamodel: cache: prefetch for expiring record is separated from prediction X-Git-Tag: v6.0.8~25^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70e19915e24aa80c1586c4c7df6380ba8b1b3f1a;p=thirdparty%2Fknot-resolver.git datamodel: cache: prefetch for expiring record is separated from prediction --- diff --git a/doc/user/config-cache-predict.rst b/doc/user/config-cache-predict.rst index f25f95bae..08f168d7e 100644 --- a/doc/user/config-cache-predict.rst +++ b/doc/user/config-cache-predict.rst @@ -2,34 +2,50 @@ .. _config-cache-predict: -Prefetching records -=================== +Prefetching cache records +========================= -Prefetching records helps to keep the cache hot. -It can utilize two independent mechanisms to select the records which should be refreshed: -expiring records and prediction. +Prefetching cache records helps to keep the cache hot. +You can use two independent mechanisms to select the records which should be refreshed. Expiring records ---------------- -This mechanism is always active when the prefetching is enabled and it is not configurable. - Any time the resolver answers with records that are about to expire, they get refreshed. Record is expiring if it has less than 1% TTL (or less than 5s). That improves latency for records which get frequently queried, relatively to their TTL. +.. code-block:: yaml + + cache: + prefetch: + # enabling prefetching of expiring records, 'false' is default + expiring: true + + Prediction ---------- -The resolver can also learn usage patterns and repetitive queries, +The resolver can learn usage patterns and repetitive queries, though this mechanism is a prototype and **not recommended** for use in production or with high traffic. +.. code-block:: yaml + + cache: + prefetch: + # this mode is NOT RECOMMENDED for use in production + prediction: + window: 15m # 15 minutes sampling window + period: 24 # track last 6 hours + + +Window length is in minutes, period is a number of windows that can be kept in memory. +e.g. if a ``window`` is 15 minutes, a ``period`` of "24" means 6 hours (360 minutes, 15*24=360). + For example, if it makes a query every day at 18:00, the resolver expects that it is needed by that time and prefetches it ahead of time. This is helpful to minimize the perceived latency and keeps the cache hot. -You can disable prediction by configuring :option:`period >` to ``0``. - .. tip:: The tracking window and period length determine memory requirements. @@ -38,42 +54,8 @@ You can disable prediction by configuring :option:`period >` to `` Experiment to get the best results. -Configuration -------------- - -.. option:: cache/prediction: true|false| - - :default: false - - .. option:: window: