Courseiva
Monitor and optimize database performancehardMultiple ChoiceObjective-mapped

How to Fix Latency Spikes from Evicted Keys in Memorystore for Redis

You are managing a Memorystore for Redis cluster with standard tier (persistence disabled). The application experiences occasional latency spikes while performing SET operations. You observe that the 'evicted_keys' metric spikes during the spikes. What is the most effective solution?

Quick Answer

The answer is to increase the maximum memory size of the instance. When the evicted_keys metric spikes during SET operations, it signals that the Redis instance has hit its maxmemory limit and is aggressively evicting keys to free space for new writes, which directly causes the observed latency spikes. This scenario tests your understanding of Memorystore for Redis memory management under the Google Professional Cloud Database Engineer exam, where a common trap is to mistakenly tune the eviction policy instead of addressing the capacity shortage—changing the policy only shifts which keys are removed, not the underlying eviction overhead. A key memory tip is to remember that eviction itself is the latency culprit, not the policy; always scale memory first when evictions coincide with write spikes.

⚠ Common exam trap

Google Cloud often tests the misconception that changing the eviction policy (Option B) solves memory pressure, when in fact the policy only controls which keys are evicted, not whether eviction occurs at all.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Increase the maximum memory size of the instance

The evicted_keys metric spikes during SET operations indicate that the Redis instance has reached its maxmemory limit and is evicting keys to accommodate new writes. Increasing the maximum memory size directly addresses the root cause by providing more headroom for data, reducing the need for eviction and the associated latency spikes.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Enable AOF persistence with fsync every second

    Why it's wrong here

    Persistence increases write latency and doesn't prevent eviction.

  • Change the maxmemory-policy to 'volatile-lru'

    Why it's wrong here

    Changing eviction policy doesn't solve insufficient memory.

  • Increase the maximum memory size of the instance

    Why this is correct

    More memory reduces evictions, stabilizing write latency.

  • Configure a read replica to offload read traffic

    Why it's wrong here

    Read replicas don't help with SET operations.

About these practice questions

Courseiva writes every PCDE question from scratch — 1,446 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on PCDE

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A Cloud Memorystore for Redis instance used as a session store has a high eviction rate. Which configuration change can reduce evictions while maintaining performance?

medium
  • A.Enable persistence (RDB)
  • B.Increase number of replicas
  • C.Decrease timeout
  • D.Set maxmemory-policy to allkeys-lru

Why D: Setting `maxmemory-policy` to `allkeys-lru` allows Redis to evict the least recently used keys across all keys when memory is full, which directly reduces eviction rates by ensuring that only the least active session data is removed. This maintains performance by keeping frequently accessed session keys in memory, which is critical for a session store where active sessions are repeatedly read and written.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDE exam.