Swap: Difference between revisions

From VoIPmonitor.org
(Restructure: add syntaxhighlight, tables, DISPLAYTITLE, Category, AI Summary, fix typos)
(Improved formatting: added decision flowchart, swappiness values table, fixed syntax highlighting (ini/text vs bash), added sysctl -p command, restored full UUIDs in fstab example)
Line 5: Line 5:


Swap usage leads to performance degradation on VoIPmonitor servers. For realtime packet processing, we highly recommend configuring swap space properly or disabling it entirely.
Swap usage leads to performance degradation on VoIPmonitor servers. For realtime packet processing, we highly recommend configuring swap space properly or disabling it entirely.
<kroki lang="plantuml">
@startuml
skinparam shadowing false
skinparam defaultFontName Arial
skinparam activity {
  BackgroundColor #FFFFFF
  BorderColor #4A90E2
  DiamondBackgroundColor #FFFFFF
  DiamondBorderColor #4A90E2
}
start
:Check current swap usage\n''free -m'';
if (Swap used > 0?) then (yes)
  :Check VoIPmonitor memory settings\n(ringbuffer, max_buffer_mem);
  if (Buffer settings too high?) then (yes)
    :Reduce buffer settings;
  else (no)
    if (Server has enough RAM?) then (yes)
      :Disable swap entirely;
    else (no)
      :Set swappiness = 5;
    endif
  endif
else (no)
  :System is healthy\n(no action needed);
endif
stop
@enduml
</kroki>


=== Understanding Swappiness ===
=== Understanding Swappiness ===
Line 16: Line 47:


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.
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.
{| class="wikitable"
|-
! Swappiness Value !! Behavior
|-
| 0 || Use swap only when RAM is completely exhausted
|-
| 5 || Use swap only when critically low on RAM (recommended)
|-
| 60 || Default - start swapping at 40% free RAM (not recommended)
|-
| 100 || Aggressively use swap (not recommended for VoIPmonitor)
|}


=== Configuring Swappiness ===
=== Configuring Swappiness ===
Line 33: Line 77:
Add the following line to <code>/etc/sysctl.conf</code>:
Add the following line to <code>/etc/sysctl.conf</code>:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="ini">
vm.swappiness=5
vm.swappiness=5
</syntaxhighlight>
</syntaxhighlight>


A value of 0 means use swap only when absolutely no RAM is free.
Then apply without reboot:
 
<syntaxhighlight lang="bash">
sysctl -p
</syntaxhighlight>


=== Clearing Swap ===
=== Clearing Swap ===
Line 56: Line 104:


;Step 2: Comment out swap entries in <code>/etc/fstab</code>:
;Step 2: Comment out swap entries in <code>/etc/fstab</code>:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="text">
proc            /proc          proc    defaults        0      0
proc            /proc          proc    defaults        0      0
UUID=17e56a9a-... /              xfs    relatime        0      1
UUID=17e56a9a-0f42-44ca-90e8-570315708def /              xfs    relatime        0      1


# Swap entries commented out:
# Swap entries commented out:
#UUID=0a403f5e-... none            swap    sw              0      0
#UUID=0a403f5e-0505-4055-a219-70217b6b74d1 none            swap    sw              0      0
#UUID=4cf42564-... none            swap    sw              0      0
#UUID=4cf42564-4339-42ed-b7ec-29644a3085f1 none            swap    sw              0      0
</syntaxhighlight>
</syntaxhighlight>


Line 118: Line 166:
== AI Summary for RAG ==
== 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.
'''Summary:''' Linux swap configuration for VoIPmonitor servers. Covers swappiness tuning (recommended value 5), disabling swap completely, and VoIPmonitor buffer memory settings (ringbuffer, max_buffer_mem) that affect swap usage.


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


'''Key Questions:'''
'''Key Questions:'''

Revision as of 22:53, 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.

Swappiness Value Behavior
0 Use swap only when RAM is completely exhausted
5 Use swap only when critically low on RAM (recommended)
60 Default - start swapping at 40% free RAM (not recommended)
100 Aggressively use swap (not recommended for 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

Then apply without reboot:

sysctl -p

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-0f42-44ca-90e8-570315708def /               xfs     relatime        0       1

# Swap entries commented out:
#UUID=0a403f5e-0505-4055-a219-70217b6b74d1 none            swap    sw              0       0
#UUID=4cf42564-4339-42ed-b7ec-29644a3085f1 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 (recommended value 5), disabling swap completely, and VoIPmonitor buffer memory settings (ringbuffer, max_buffer_mem) that affect swap usage.

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

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?