System configuration

System Configuration

Enhancing Memgraph's performance can sometimes involve optimizing operating system-level configurations. These adjustments primarily pertain to the settings governing resource allocation and process management.

Adjusting fs.file-max

The fs.file-max parameter in Linux sets the maximum number of file handles that the Linux kernel will allocate. Adjusting this is crucial when the system needs to handle numerous open files simultaneously. To adjust this parameter do the following:

Open `/etc/sysctl.conf` in a text editor

You need root privileges to edit this file, which is used for configuring kernel parameters at runtime.

Set the file handle limit

Add the line fs.file-max=100000 to sysctl.conf.

Apply the changes

Save your changes and exit the text editor. Run sudo sysctl -p to immediately apply the changes without rebooting.

Verify the changes

Run sysctl fs.file-max to check that the new value has been applied. It should return 100000.

Increasing memory map areas

The vm.max_map_count parameter determines the maximum number of memory map areas a process can have. Run sudo sysctl -w vm.max_map_count=262144 to immediately increase the memory map area limit to 262,144. This change takes effect right away but lasts only until the next reboot.

If you want a change that persists across system reboots, follow these steps:

Edit `/etc/sysctl.conf`

Add vm.max_map_count=262144 to /etc/sysctl.conf. Root privileges are required for editing.

Apply the changes

Save your changes and run sudo sysctl -p to apply them right away.

Verify the changes

Run sysctl vm.max_map_count to ensure the new value is in effect. It should return 262144.

Setting the process stack size

For systems running resource-intensive applications, it might be necessary to increase the stack size for a process. By default, the Linux stack size is set to 8MB. Increasing this limit can help in managing larger transactions and workloads.

Steps to set the process stack size:

If you are using Docker you can set the process stack size when you run the Docker container. Just add --ulimit stack=8277716992:8277716992 to your Docker run command, e.g. docker run --rm -it --name memgraph --ulimit stack=8277716992:8277716992 -p 7687:7687 -p 7444:7444 memgraph/memgraph

Open `/etc/security/limits.conf` in a text editor

You need root privileges to edit this file. This file is used to set user or group-specific soft and hard limits for various system resources.

Set the stack size limit

Add the following lines to set both the soft and hard stack size limits for the user:

memgraph soft stack 8087482
memgraph hard stack 8087482

The values 8087482 represent the stack size in kilobytes, equivalent to 8GB.

Apply the changes

Save your changes and exit the text editor. For the changes to take effect, the user may need to log out and then log back in.

Verify the changes

To check the new stack size limits, switch to the user account and run:

ulimit -s

This command should return 8087482, confirming that the new stack size limits have been applied.