# How does Kubernetes use the swap space on the host computer?

**URL:** <https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910>\
**Category:** ScyllaDB\
**Created:** [October 16, 2023, 7:38am UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910 "2023-10-16T07:38:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@vincent](https://forum.scylladb.com/u/vincent)\
**Post date:** [October 16, 2023, 7:38am UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910/1 "2023-10-16T07:38:24Z")

</div>

Hi all! We are now using kubernetes to deploy our ScyllaDB cluster. In this case, can we use the swap space on the host computer?If so, how does Kubernetes use the swap space on the host computer? Thanks!

---

<div class="post-metadata">

**Author:** ![felipemendes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/felipemendes/32/11_2.png) [@felipemendes](https://forum.scylladb.com/u/felipemendes)\
**Post date:** [October 16, 2023, 2:05pm UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910/2 "2023-10-16T14:05:00Z")

</div>

This is more of a Kubernetes question rather than a ScyllaDB one. In the past, there were no kubelet support for swapping, but this has been changing lately with [KEP-2400](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/2400-node-swap/README.md), which is in Beta in 1.28.

In general, for a ScyllaDB deployment you will want to ensure you use `--lock-memory=1` in order to avoid the database process from swapping altogether.

---

<div class="post-metadata">

**Author:** ![vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@vincent](https://forum.scylladb.com/u/vincent)\
**Post date:** [October 20, 2023, 8:55am UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910/3 "2023-10-20T08:55:50Z")

</div>

Thanks a lot! But I’m still confused that is it recommended to use swap space when we are executing bare metal deployment?

---

<div class="post-metadata">

**Author:** ![felipemendes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/felipemendes/32/11_2.png) [@felipemendes](https://forum.scylladb.com/u/felipemendes)\
**Post date:** [October 23, 2023, 2:13pm UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910/4 "2023-10-23T14:13:31Z")

</div>

You’re right. In a bare metal / VM deployment the ScyllaDB process typically runs with the `--lock-memory` option enabled, which causes the process to `mlock()` the memory area. The swap space, therefore, is left to other processes such as JMX, OS, etc.

On K8s you have the flexibility to set the pod memory in your deployment, as well as limit ScyllaDB’s own memory consumption via the `--memory` parameter. Ideally, you will also want to `--lock-memory`, given that it can cause the process to swap once the aforementioned proposal lands in a K8s release.

---

<div class="post-metadata">

**Author:** ![vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@vincent](https://forum.scylladb.com/u/vincent)\
**Post date:** [October 26, 2023, 10:04am UTC](https://forum.scylladb.com/t/how-does-kubernetes-use-the-swap-space-on-the-host-computer/910/5 "2023-10-26T10:04:25Z")

</div>

Thanks a lot for your reply. I think I have a clearer understanding of this issue now.
