Page Cache Performance and Evictions

Introduction

In the storage lesson, you learned that ideally your graph should fit into the page cache for optimal performance. In this lesson you’ll learn how to monitor the page cache to ensure your graph data is being served from memory rather than disk.

The page cache stores frequently accessed graph data in memory. When your storage size exceeds the available page cache, queries must read from disk, which reduces performance.

Understanding the Page Cache

The page cache stores graph data including nodes, relationships, properties, and indexes in memory.

When a query needs data, Neo4j first checks if it’s in the page cache. Cache hits are fast because the data is already in memory. If the data is not cached in memory, this is referred to as a cache miss. Cache misses result in slower query execution because the data must be read from disk.

Monitoring Page Cache Metrics

The Page Cache and Evictions charts

Aura provides three key page cache metrics split across two charts that work together to indicate performance of the page cache.

Page Cache Chart

The Page Cache metric chart allows you to switch between hit ratio and usage ratio.

The hit ratio is the percentage of times data was found in the page cache versus needing to be read from disk. The expected value is 98-100%. This is your most important page cache metric.

The usage ratio is the percentage of allocated page cache currently in use. When this reaches 100%, the hit ratio may start declining.

Page Cache Evictions

The evictions per minute metric shows how often data in memory is being replaced.

Low eviction rates indicate healthy performance.

High eviction rates indicate the page cache is not large enough to hold all of your data in memory.

A spike in evictions can mean your workload is temporarily exceeding available memory, which may cause performance degradation or query execution errors.

Managing Page Cache Performance

The hit ratio is your primary indicator of page cache health. If the hit ratio falls below 98%, investigate using the usage ratio and evictions metrics.

Check the usage ratio to see how full the page cache is. A usage ratio at or near 100% means the page cache is full and Neo4j is evicting data from memory to make room for new data. As your data grows, the usage ratio will increase until it reaches capacity.

Check the evictions per minute to see how often data is being replaced. High evictions combined with low hit ratio indicate the page cache cannot hold your frequently accessed data.

Write activity can also affect the hit ratio. A high amount of insert or update activity causes the hit ratio to fluctuate as new data loads into the page cache. This is normal during data imports or bulk operations and does not necessarily indicate a scaling issue.

Scaling your instance

If your usage ratio is high but page cache evictions are low, you don’t necessarily need to scale your instance. As data gets replaced, older data that is no longer frequently accessed will be evicted from the page cache.

Temporary spikes in evictions may occur during workload bursts and typically resolve on their own.

However, if page cache evictions remain consistently high, this indicates your instance needs more memory to hold your frequently accessed data.

Scaling your instance

You can scale your instance by clicking the Configure button in the Instance details page and increasing the memory.

Check Your Understanding

Page Cache Hit Ratio

What does the page cache hit ratio measure?

  • ❏ The percentage of queries that complete successfully

  • ❏ The amount of memory allocated to the page cache

  • ✓ The percentage of times data was found in memory versus read from disk

  • ❏ The number of cache evictions per minute

Hint

Think about what happens when Neo4j needs data for a query.

Solution

The percentage of times data was found in memory versus read from disk is correct.

The hit ratio measures how often data is already in the page cache (cache hit) versus needing to be read from disk (cache miss). A high hit ratio means most data is found in memory, which is much faster than disk reads.

Query completion measures success rate, not cache performance. Memory allocation is measured by the usage ratio, not the hit ratio. Cache evictions are a separate metric that tracks how often data is replaced in memory.

Page Cache Metrics Relationship

When the page cache usage ratio reaches 100%, what typically happens to the hit ratio?

  • ❏ It improves because the cache is fully utilized

  • ❏ It stays the same because they are independent metrics

  • ✓ It may start declining as data is constantly evicted and reloaded

  • ❏ It immediately drops to zero

Hint

Consider what happens when the cache is full and new data needs to be loaded.

Solution

It may start declining as data is constantly evicted and reloaded is correct.

When the usage ratio reaches 100%, the entire page cache is full. If queries need data that isn’t cached, Neo4j must evict existing data to make room. This constant cycle of evicting and reloading data causes more cache misses, which lowers the hit ratio.

Improving is incorrect because a full cache leads to more evictions. Staying the same is incorrect because the metrics are related through memory availability. Dropping to zero is incorrect because some data remains cached even during constant eviction cycles.

Summary

In this lesson, you learned how to monitor page cache performance using three key metrics:

  • Hit ratio - The percentage of times data was found in memory versus read from disk (expected value: 98-100%)

  • Usage ratio - The percentage of allocated page cache currently in use

  • Evictions per minute - How often data in memory is being replaced

The hit ratio is your primary indicator of page cache health. If the hit ratio falls below 98%, check the usage ratio and evictions to diagnose the issue. Scale your instance when evictions are high, indicating the page cache cannot hold your frequently accessed data.

In the next lesson, you will learn how to monitor Bolt connections to understand application connectivity patterns.

Chatbot

How can I help you today?