Swap: Difference between revisions

From VoIPmonitor.org
(Add section on checking VoIPmonitor memory configuration (max_buffer_mem, ringbuffer, packetbuffer) when troubleshooting swap issues)
(Restructure: add syntaxhighlight, tables, DISPLAYTITLE, Category, AI Summary, fix typos)
Line 1: Line 1:
== Swap ==
{{DISPLAYTITLE:Swap Configuration}}
Category:Installation


Swap usage leads to performance degradation of your server. So we highly recommend to configure swap space properly or disable it entirely
== Swap Configuration ==


===How to configure===
Swap usage leads to performance degradation on VoIPmonitor servers. For realtime packet processing, we highly recommend configuring swap space properly or disabling it entirely.
Most of distribution's default settings for swap is to use the swap when Ram usage exceeds 40%
check your swappiness value with
cat /proc/sys/vm/swappiness
(the value 60 here means to start to use the swap when there is less then 60% of free RAM - this not makes sense for realtime services)


You can change it in a run-time,effect is instant after disable/enable the swap(but not persists restart of a server)
=== Understanding Swappiness ===
echo '5' > /proc/sys/vm/swappiness


Most Linux distributions default to using swap when RAM usage exceeds 40%. The <code>swappiness</code> value controls this behavior:


You can set the value permanent by adding the line at end of /etc/sysctl.conf
<syntaxhighlight lang="bash">
vm.swappiness=5
# Check current swappiness value
cat /proc/sys/vm/swappiness
</syntaxhighlight>


(0 value means to use swap only when there is no Ram free)
A value of 60 means the system starts using swap when less than 60% of RAM is free. This is not optimal for realtime services like VoIPmonitor.


===Make swap empty===
=== Configuring Swappiness ===
swapoff -a
swapon -a


===How to disable===
==== Temporary Change (Until Reboot) ====


root@vmsniff:~# swapoff -a
<syntaxhighlight lang="bash">
# Set swappiness to 5 (use swap only when critically low on RAM)
echo '5' > /proc/sys/vm/swappiness


Then edit the /etc/fstab file and comment out the swap lines. E.g.
# Apply immediately by clearing swap
swapoff -a && swapon -a
</syntaxhighlight>


proc            /proc          proc    defaults        0      0
==== Permanent Change ====
# / was on /dev/md0 during installation
UUID=17e56a9a-0f42-44ca-90e8-570315708def /              xfs    relatime        0      1
# swap was on /dev/sda2 during installation
#UUID=0a403f5e-0505-4055-a219-70217b6b74d1 none            swap    sw              0      0
# swap was on /dev/sdb2 during installation
#UUID=4cf42564-4339-42ed-b7ec-29644a3085f1 none            swap    sw              0      0


Note: use dmesg (or dmeg -T) command to ensure there is no service crashing because of no ram free.
Add the following line to <code>/etc/sysctl.conf</code>:
 
<syntaxhighlight lang="bash">
vm.swappiness=5
</syntaxhighlight>
 
A value of 0 means use swap only when absolutely no RAM is free.
 
=== Clearing Swap ===
 
To move all data from swap back to RAM:
 
<syntaxhighlight lang="bash">
swapoff -a
swapon -a
</syntaxhighlight>
 
=== Disabling Swap Completely ===
 
;Step 1: Disable swap immediately:
<syntaxhighlight lang="bash">
swapoff -a
</syntaxhighlight>
 
;Step 2: Comment out swap entries in <code>/etc/fstab</code>:
<syntaxhighlight lang="bash">
proc            /proc          proc    defaults        0      0
UUID=17e56a9a-... /              xfs    relatime        0      1
 
# Swap entries commented out:
#UUID=0a403f5e-... none            swap    sw              0      0
#UUID=4cf42564-... none            swap    sw              0      0
</syntaxhighlight>
 
;Step 3: Monitor for OOM issues:
<syntaxhighlight lang="bash">
# Check for out-of-memory events
dmesg -T | grep -i "out of memory\|killed process"
</syntaxhighlight>


=== Checking VoIPmonitor Memory Configuration ===
=== Checking VoIPmonitor Memory Configuration ===


Before tuning system-level swap settings, you should also review VoIPmonitor's internal memory configuration parameters. Excessive buffer settings can cause memory pressure and trigger swap usage.
Before tuning system-level swap settings, review VoIPmonitor's internal memory configuration. Excessive buffer settings can cause memory pressure and trigger swap usage.


Check the current memory-related settings:
<syntaxhighlight lang="bash">
# Check current memory-related settings
grep -E '^(max_buffer_mem|ringbuffer|packetbuffer)' /etc/voipmonitor.conf
</syntaxhighlight>


cat /etc/voipmonitor.conf | grep '^max_buffer_mem\|^ringbuffer\|^packetbuffer'
{| class="wikitable"
|-
! Parameter !! Default !! Description
|-
| <code>ringbuffer</code> || 50 MB || Ringbuffer size per interface. Recommended >= 500 for >100 Mbit traffic. Max 2000.
|-
| <code>max_buffer_mem</code> || 2000 MB || Maximum buffer memory for packet buffers.
|-
| <code>packetbuffer_enable</code> || yes || Enable packet buffer cache.
|-
| <code>packetbuffer_compress</code> || no || Compress packet buffer (saves RAM, uses CPU).
|}


* '''ringbuffer = 50''' (default) - Ringbuffer size in MB. Recommended >= 500 for >100 Mbit traffic. Max 2000.
If your sensor is swapping, reduce <code>ringbuffer</code> and <code>max_buffer_mem</code> unless capturing at very high traffic rates.
* '''max_buffer_mem = 2000''' (default) - Maximum buffer memory in MB for packet buffers.
* '''packetbuffer_enable = yes''' (default) - Enable packet buffer cache.


Reduce these values if your sensor is swapping:
See [[Sniffer_configuration|Sniffer Configuration]] for complete memory and buffer documentation.
* Lower '''ringbuffer''' and '''max_buffer_mem''' if not capturing at very high traffic rates
* Consider '''packetbuffer_compress = yes''' to reduce memory usage at the cost of CPU
* See [[Sniffer_configuration]] for complete memory and buffer configuration documentation


=== Checking Current Memory and Swap Usage ===
=== Checking Current Memory and Swap Usage ===


To verify the current memory and swap status:
<syntaxhighlight lang="bash">
free -m
# Check memory and swap status
free -m
 
# Monitor memory usage over time
watch -n 1 free -m
 
# Check which processes use most memory
ps aux --sort=-%mem | head -10
</syntaxhighlight>
 
=== See Also ===
 
* [[Scaling|Scaling and Performance Tuning]]
* [[Sniffer_troubleshooting#Check_for_OOM|OOM Troubleshooting]]
* [[Sniffer_configuration|Sniffer Configuration]]
 
== AI Summary for RAG ==
 
'''Summary:''' Linux swap configuration for VoIPmonitor servers. Covers swappiness tuning, disabling swap, and VoIPmonitor buffer memory settings that affect swap usage.
 
'''Keywords:''' swap, swappiness, memory, RAM, performance, ringbuffer, max_buffer_mem, OOM, out of memory
 
'''Key Questions:'''
* How to configure swap for VoIPmonitor?
* How to disable swap on Linux?
* What is swappiness and how to configure it?
* How to reduce VoIPmonitor memory usage?
* What are ringbuffer and max_buffer_mem settings?

Revision as of 18:08, 4 January 2026

Category:Installation

Swap Configuration

Swap usage leads to performance degradation on VoIPmonitor servers. For realtime packet processing, we highly recommend configuring swap space properly or disabling it entirely.

Understanding Swappiness

Most Linux distributions default to using swap when RAM usage exceeds 40%. The swappiness value controls this behavior:

# Check current swappiness value
cat /proc/sys/vm/swappiness

A value of 60 means the system starts using swap when less than 60% of RAM is free. This is not optimal for realtime services like VoIPmonitor.

Configuring Swappiness

Temporary Change (Until Reboot)

# Set swappiness to 5 (use swap only when critically low on RAM)
echo '5' > /proc/sys/vm/swappiness

# Apply immediately by clearing swap
swapoff -a && swapon -a

Permanent Change

Add the following line to /etc/sysctl.conf:

vm.swappiness=5

A value of 0 means use swap only when absolutely no RAM is free.

Clearing Swap

To move all data from swap back to RAM:

swapoff -a
swapon -a

Disabling Swap Completely

Step 1
Disable swap immediately:
swapoff -a
Step 2
Comment out swap entries in /etc/fstab:
proc            /proc           proc    defaults        0       0
UUID=17e56a9a-... /               xfs     relatime        0       1

# Swap entries commented out:
#UUID=0a403f5e-... none            swap    sw              0       0
#UUID=4cf42564-... none            swap    sw              0       0
Step 3
Monitor for OOM issues:
# Check for out-of-memory events
dmesg -T | grep -i "out of memory\|killed process"

Checking VoIPmonitor Memory Configuration

Before tuning system-level swap settings, review VoIPmonitor's internal memory configuration. Excessive buffer settings can cause memory pressure and trigger swap usage.

# Check current memory-related settings
grep -E '^(max_buffer_mem|ringbuffer|packetbuffer)' /etc/voipmonitor.conf
Parameter Default Description
ringbuffer 50 MB Ringbuffer size per interface. Recommended >= 500 for >100 Mbit traffic. Max 2000.
max_buffer_mem 2000 MB Maximum buffer memory for packet buffers.
packetbuffer_enable yes Enable packet buffer cache.
packetbuffer_compress no Compress packet buffer (saves RAM, uses CPU).

If your sensor is swapping, reduce ringbuffer and max_buffer_mem unless capturing at very high traffic rates.

See Sniffer Configuration for complete memory and buffer documentation.

Checking Current Memory and Swap Usage

# Check memory and swap status
free -m

# Monitor memory usage over time
watch -n 1 free -m

# Check which processes use most memory
ps aux --sort=-%mem | head -10

See Also

AI Summary for RAG

Summary: Linux swap configuration for VoIPmonitor servers. Covers swappiness tuning, disabling swap, and VoIPmonitor buffer memory settings that affect swap usage.

Keywords: swap, swappiness, memory, RAM, performance, ringbuffer, max_buffer_mem, OOM, out of memory

Key Questions:

  • How to configure swap for VoIPmonitor?
  • How to disable swap on Linux?
  • What is swappiness and how to configure it?
  • How to reduce VoIPmonitor memory usage?
  • What are ringbuffer and max_buffer_mem settings?