Limit Window Subsystem Linux v2 (WSL2) Resources to Speed Up Kubernetes

Window Subsystem Linux v2 (WSL2) is an iteration of the VM created by Microsoft, from Hyper-V to WSL and this the second generation of WSL. If it’s your first time accessing WSL2, it automatically provides you with the default setup which doesn’t provide any limits accessing your full workstation resources (CPU, RAM and other HDD). It means that if you have 8 cores CPU and 16Gb memory, it will use all that up. The problem with it is sometimes it affects your host computer, and it gets slow. So, to solve that problem we try to limit the resource consumption of WSL2.

Photo by Sadik Brika on Unsplash

Limit WSL Resource Consumption

On your profile directory %USERPROFILE% create a new file named .wslconfig. Set its content to the following:

[wsl2]
memory=8GB
processors=8

Change the settings based on your workstation capability, and this is what works for me.

Next, open up a powershell terminal in administrator mode and restart the LxssManager as this manages WSL2.

Get-Service LxssManager | Restart-Service

You could also use the wsl --shutdown method to restart WSL. Check if the vmmem process still consumes beyond its limit.

Troubleshoot

If the changes are still not reflecting, try to restart your machine and also restart Docker Desktop.


Posted

in

by

  • Let’s Explore!

    It’s 04:03am Tuesday, and I’m starting this blog. There are a lot of things currently bothering my mind, and sometimes I’m thinking of what the future will look like. Waiting till 10:00 to get onto my work and start doing some stuff. Let’s find some beautiful place and get lost. – Me I’ve been a… Read More

  • Installing MySQL2 Ruby Gem in macOS Mojave

    Installing MySQL2 gem became a common problem for people who uses macOS to develop Ruby1 based apps that utilized MySQL2 data store. I’ve personally encountered this problem myself back in the days and still encountering this on brand new setup macOS workstation. In this article, we will go through the steps I did to resolved… Read More

  • Changing Xserver Default Applications Using XDG Tools

    XDG (freedesktop.org) which stands for X Desktop Group is a group which develop the X11 and xdg utilities which currently runs as barebones of linux desktop. So how do we change the defaults when opening a file on XServer? Be free, and live life fully. — Caroline Shaw. So how do we configure XDG? Tools… Read More