> For the complete documentation index, see [llms.txt](https://prime-stake-pool.gitbook.io/node-setup-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prime-stake-pool.gitbook.io/node-setup-guide/server-setup-basics/linux-swap-space/kernel-cache-pressure-and-swappiness.md).

# Kernel cache pressure and swappiness

Now that you have swap enabled. Consider adjusting your server’s cache pressure and tendency to swap ([vm.swappiness](https://access.redhat.com/solutions/103833)) by following the guide below.

**vfs\_cache\_pressure** – Controls the kernel’s tendency to reclaim the memory, which is used for caching of directory and inode objects. (default = 100, recommend value 50 to 200)

**swappiness –** This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase aggressiveness; lower values decrease the amount of swap. (default = 60, recommended values between 1 and 60) Remove your swap for 0 value, but usually not recommended in most cases.

To edit, you can add or replace these lines in **/etc/sysctl.conf** file. For example, if you have low memory until you upgrade, you can try something such as:

<figure><img src="/files/OqukutLxUagoBY062eBf" alt=""><figcaption></figcaption></figure>

This will increase the cache pressure, which may seem somewhat counterproductive since caching is good for performance. However, too frequent swapping reduces your server’s overall performance significantly more. So not keeping as much cache in memory will help reduce swap activity. Also, with vm.swappiness set to 10 or as low as 1, it will reduce disk swapping.

On a healthy server with lots of available memory, use the following:

<figure><img src="/files/yCFvn55an8zE3cGlVKr0" alt=""><figcaption></figcaption></figure>

This will decrease the cache pressure. Since caching is good for performance, we want to keep cached data in memory longer. Since the cache will grow larger, we still want to reduce swapping to not cause increased swap I/O.

To check current values using these commands use:

```
sudo cat /proc/sys/vm/swappiness
sudo cat /proc/sys/vm/vfs_cache_pressure
```

To enable these settings temporarily without rebooting, use the following commands:

```
sudo sysctl -w vm.swappiness=10
sudo sysctl -w vm.vfs_cache_pressure=50
```

Swap space will give you some breathing room in cases that would otherwise lead to out-of-memory exceptions.

If you are running into OOM (out of memory) errors, or if you find that your system is unable to use the applications you need, the best solution is to optimize your application configurations or upgrade your server.

> This article has a reference from Hayden James's Linux blog [Why You Should Almost Always Add Swap Space](https://haydenjames.io/linux-performance-almost-always-add-swap-space/).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prime-stake-pool.gitbook.io/node-setup-guide/server-setup-basics/linux-swap-space/kernel-cache-pressure-and-swappiness.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
