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
When you do a cache warmup, people often use a single TTL for a lot of keys. When the keys are related, this can cause the callback to be stampeded with requests. The solution is to make those TTLs have a slight variation. Usually that is done with a percentage of the original TTL.
I propose adding a method which will add jitter to the TTL. Something like
/**
* @param int $ttl
* @param float $jitter
* @return int
*/
function jitter($ttl, $jitter)
{
if ($jitter >= 1 || $jitter =< 0)
{
throw new Exception('$jitter must be between 1 and 0');
}
$variation = $ttl * $jitter;
$min = ceil($ttl - $variation);
$max = ceil($ttl + $variation);
return rand($min, $max);
}
The text was updated successfully, but these errors were encountered:
We currently subtract a random amount of time from the TTL, capped at 15%. This is a little different than your method, because our method does not allow the TTL to be extended past it's original time time, it only allows the ttl to be lowered.
When you do a cache warmup, people often use a single TTL for a lot of keys. When the keys are related, this can cause the callback to be stampeded with requests. The solution is to make those TTLs have a slight variation. Usually that is done with a percentage of the original TTL.
I propose adding a method which will add jitter to the TTL. Something like
The text was updated successfully, but these errors were encountered: