Urgent.News

What's breaking now, across thousands of outlets.

Tech

Redis Memory Full and Keys Evicted: A Java Backend Checklist of 4 Spots

Wednesday afternoon, cache hit rate dropped from 98% to 62%, and database QPS quintupled. Ops checked around and said: Redis memory is maxed out, some keys were evicted, it's normal behavior. But the keys that got evicted happened to be login sessions, and users were collectively kicked offline. Memory full means eviction—sounds perfectly reasonable. The problem is which keys get evicted and why…

Redis memory usage reached its maximum capacity, causing key evictions. This resulted in the loss of login sessions, leading to users being logged out. The article provides a checklist of four spots to inspect when encountering this issue.

Firstly, examine the maxmemory policy configuration. Redis employs a maxmemory-policy to determine which keys to evict when memory is full. The allkeys-lru policy, which deletes the least recently accessed keys from all cached data, was likely the default setting. However, this policy indiscriminately removes config data, product caches, rate-limit counters, and other essential keys, causing unexpected issues.

Secondly, consider the eviction policy's scope. The allkeys-* policies evict all cached data, while the volatile-* policies only target keys with expiration times (TTL). Configuring the volatile-* policy ensures that only data with an expiration time is evicted, preserving critical configurations and other data.

Thirdly, monitor the Redis memory statistics to understand the root cause of the issue. Use the redis-cli tool to run the 'info memory' command, which provides details about memory usage, including used_memory, used_memory_rss, and mem_fragmentation_ratio. The evicted_keys metric will show the cumulative count of keys evicted since the process started. Increasing numbers indicate sustained memory pressure, suggesting a deeper problem.

Lastly, delve into the internal workings of Redis memory management. Redis uses a single-threaded command execution model, checking memory usage before executing every command. If memory exceeds the limit, Redis enters an eviction loop, deleting keys until memory falls below the threshold. The eviction process uses a timestamp-based Least Recently Used (LRU) algorithm, sampling a default of 5 keys to determine the least recently accessed ones. However, this sampling method may not accurately reflect the most frequently accessed keys.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Ionicons in Angular: Web Component Fix

Ionicons 4.x provides a web component that you can use to add an icon with <ion-icon name="..."></ion-icon> . Using this web component in an Angular app doesn’t work though, and many developers have…

  • Developers face issues using Ionicons 4.x with web component syntax in Angular.
  • Adding CUSTOMELEMENTSSCHEMA suppresses error but fails to load SVG icons.
  • Installing @ionic/angular module resolves issue by providing access to Ionic components.

How to name your YouTube channel without regretting it in a year

A channel name has to do three jobs at once: say what the channel is about, be easy to remember after hearing it once, and still fit in a year when the content grows.

  • A good YouTube channel name should convey content and allow growth.
  • Avoid overly specific names to prevent limiting future content.
  • Use NamerGuide tool to check domain and social media availability.

Mac Dock & Multiple Monitors

Unfortunately the native Mac OS X dock can’t be used on multiple displays. You can get it setup so that it’s available on both, but what most people are after (myself included) is a seamless dock that…

  • uBar 4 Application replaces native Mac OS dock
  • Configure uBar via Preferences menu with tabs
  • Add applications as Favorites for seamless access

More from Tuesday 3 November →