Scaling: Difference between revisions

From VoIPmonitor.org
No edit summary
(Rewrite: konsolidace, zkrácení duplicit, lepší struktura)
 
(64 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Scaling =
{{DISPLAYTITLE:Scaling and Performance Tuning}}
[[Category:Administration]]


VoIPmonitor is able to use all available CPU cores but there are several bottlenecks which you should consider before deploying and configuring VoIPmonitor.  
This guide covers performance tuning for high-traffic VoIPmonitor deployments, addressing the three primary system bottlenecks.


Basically there are three types of bottlenecks - CPU, I/O throughput and MySQL performance. The sniffer is multithreaded application but certain tasks cannot be split to more threads. Main thread is reading packets from kernel - this is the top most consuming thread and it depends on CPU type and kernel version (and number of packets per second). Below 1000 concurrent calls you do not need to be worried about CPU on usual CPU (Xeon, i5). More details about CPU bottleneck see following chapter CPU bound.
== Understanding Performance Bottlenecks ==


I/O bottleneck is most common problem for voipmonitor and it depends if you store to local mysql database along with storing pcap files on the same server and the same storage. Differences between I/O hardware and file system are so significant that there is no general recommendation and the problem can be for 100 concurrent calls. See next chapter I/O throughput.
A VoIPmonitor deployment's capacity is limited by three potential bottlenecks:


<kroki lang="plantuml">
@startuml
skinparam shadowing false
skinparam defaultFontName Arial


== CPU bound ==
title VoIPmonitor Performance Bottlenecks


=== Reading packets ===
rectangle "Network\nInterface" as NIC #E8F4FD
Main thread which reads packets from kernel cannot be split into more threads which limits number of concurrent calls for the whole server. CPU used for this thread is equivalent to running "tcpdump -i ethX -w /dev/null" which you can use as a test if your server is able to handle your traffic. We have tested sniffer on countless type of servers and basically the limit is somewhere around at 800Mbit for usual 1Gbit card on newer Xeon CPU and kernel versions >= 2.6.32. To get higher throughput special drivers or hardware is needed.
rectangle "Packet Capture\n(t0 thread)" as T0 #FFE6E6
rectangle "RTP/SIP\nProcessing" as PROC #E6FFE6
rectangle "PCAP Files\nStorage" as DISK #FFF3E6
database "MySQL/MariaDB" as DB #E6E6FF


On following picture you can see how packets are proccessed from ethernet card to Kernel space to ethernet driver which queues packets to ring buffer. Ring buffer (available since kernel 2.6.32 and libpcap > 1.0) is read by libpcap functions in voipmonitor to its own voipmonitor buffer. Kernel ring buffer is circular buffer directly in kernel which reads packets from ethernet card and overwrites the oldest one if not read in time. Ring buffer can be large at maximum 2GB. If voipmonitor is blocked by CPU or I/O the ring buffer starts filling up to its maximum set size (voipmonitor.conf:ringbuffer=XXX) and in this case dropping packets occurs which is logged into the syslog. VoIPmonitor sniffer reads packets from ring buffer in one main thread and writing packets to voipmonitor buffer with maximum size 4GB (voipmonitor.conf:vmbuffer=XXXX). Which means that maximum buffer size is 6GB RAM which can cover I/O low throughput until all buffers are filled. Thus if you set both buffers to its maximum values and your I/O is not able to handle save all packets to disk (if saving is enabled) you can see dropping packets after 6GB of packets fills buffers. VoIPmonitor buffer is read by another thread to one or more queues which depends on how much number of CPU is available (voipmonitor.conf:rtpthreads=X). Those queues processes RTP packets in parallel. Jitterbuffer simulater uses the most CPU and you can disable all three type of jitterbuffers if your server is not able to handle it all (jitterbuffer_f1, jitterbuffer_f2, jitterbuffer_adapt). If you need to disable one of the jitterbuffer keep jitterbuffer_f2 enabled which is the most usefull.  
NIC -right-> T0 : "1. CPU"
T0 -right-> PROC
PROC -down-> DISK : "2. I/O"
PROC -right-> DB : "3. Database"


[[File:kernelstandarddiagram.png]]
note bottom of T0
  Monitor: t0CPU
  Limit: 1 CPU core
end note


Good tool for measuring CPU is http://htop.sourceforge.net/
note bottom of DISK
  Monitor: iostat
  Solution: SSD, TAR
end note


[[File:ntop.png]]
note bottom of DB
  Monitor: SQLq
  Solution: RAM, tuning
end note
@enduml
</kroki>


==== Software driver alternatives ====
{| class="wikitable"
|-
! Bottleneck !! Description !! Monitor
|-
| '''1. Packet Capture''' || Single CPU core reading packets from NIC || <code>t0CPU</code> in syslog
|-
| '''2. Disk I/O''' || Writing PCAP files to storage || <code>iostat</code>, <code>ioping</code>
|-
| '''3. Database''' || CDR ingestion and GUI queries || <code>SQLq</code> in syslog
|}


'''Capacity:''' A modern server (24-core Xeon, 10Gbit NIC) can handle '''~10,000 concurrent calls''' with full RTP recording, or '''60,000+''' with SIP-only analysis.


If your traffic is to much for your current hardware you can try PF_RING feature.
== Optimizing Packet Capture (CPU & Network) ==


The packet capture thread (t0) runs on a single CPU core. If <code>t0CPU</code> approaches 100%, you've hit the capture limit.


*PF_RING http://www.ntop.org/products/pf_ring/
=== Prerequisites ===
*Direct NIC Access http://www.ntop.org/products/pf_ring/dna/


* '''Linux kernel 3.2+''' with TPACKET_V3 support
* '''Latest VoIPmonitor static binary'''


With a modern kernel and VoIPmonitor build, a standard Intel 10Gbit NIC handles up to 2 Gbit/s VoIP traffic without special drivers.


We tried DNA driver for stock 1Gbit Intel card which reduces 100% CPU load to 20% but we still saw occasional packet loss on the card - although the loss was minimal.
=== NIC Tuning (>500 Mbit/s) ===


==== Hardware NIC cards ====
<syntaxhighlight lang="bash">
# Increase ring buffer (prevents packet loss during CPU spikes)
ethtool -g eth0                  # Check max size
ethtool -G eth0 rx 16384        # Set to max


We have tested 10Gbit cards from Napatech which can handle at least 20000 concurrent calls with 0% CPU for main thread. Those cards are very expensive but the performance is worth it.
# Enable interrupt coalescing (reduces CPU overhead)
ethtool -C eth0 rx-usecs 1022
</syntaxhighlight>


'''Persistent settings''' (Debian/Ubuntu <code>/etc/network/interfaces</code>):
<syntaxhighlight lang="ini">
auto eth0
iface eth0 inet manual
    up ip link set $IFACE up
    up ip link set $IFACE promisc on
    up ethtool -G $IFACE rx 16384
    up ethtool -C $IFACE rx-usecs 1022
</syntaxhighlight>


=== Configuration Optimizations ===


== I/O bottleneck ==
{| class="wikitable"
|-
! Parameter !! Purpose !! Recommendation
|-
| <code>interface_ip_filter</code> || IP-based filtering || More efficient than BPF <code>filter</code>
|-
| <code>pcap_dump_writethreads_max</code> || Compression threads || Set to CPU core count
|-
| <code>jitterbuffer_f1/f2/adapt</code> || Jitter simulation || Disable to save CPU (loses MOS metrics)
|}


For storing up to 100 simultaneous calls you do not need to be worried about I/O performance much. For storing up to 500 calls your disk must have enabled write cache (some raid controllers are not set well for random write scenarios or has write cache disabled at all). For up to 1000 calls you can use ordinary SATA 7.2kRPM disks with NCQ enabled - like Western digital RE4 edition (RE4 is important as it implements good NCQ) and we use it for installations for saving full SIP+RTP up to 1000 simultaneous calls. If you have more than 1000 simultaneous calls you can still use usual SATA disk but using cachedir feature (see below) or you need to look for some hardware raid and test the performance before you buy! Performance of such raids varies a lot and there is no general recommendation or working solutions which we can provide as a reference.  
<syntaxhighlight lang="ini">
# /etc/voipmonitor.conf


SSD disks are not recommended for pcap storing because of its low durability.  
# Efficient IP filtering (replaces BPF filter)
interface_ip_filter = 192.168.0.0/24
interface_ip_filter = 10.0.0.0/8


VoIPmonitor sniffer produces the worst case scenario for spin disks - random write. The situation gets worse in case of ext3/ext4 file systems which uses journal and writes meta data enabled by default thus adding more I/O writes. But ext4 can be tweaked to get maximum performance. We are recommending to use dedicated disk and format it with special ext4 switches which turns off journal and other features which removes some safety in favor of performance. If you cannot use dedicated disk for storing pcap files use dedicated partition formatted with special tweaks (see below).
# Compression scaling
pcap_dump_writethreads = 1
pcap_dump_writethreads_max = 32
pcap_dump_asyncwrite = yes
</syntaxhighlight>


The fastest filesystem for voipmonitor spool directory is EXT4 with turned off journaling and other tweaks. Assuming your partition is /dev/sda2: 
{{Warning|1=Disabling <code>jitterbuffer_*</code> removes MOS/jitter metrics. Only disable if you don't need quality monitoring.}}


mke2fs -t ext4 -O ^has_journal /dev/sda2
=== Kernel-Bypass Solutions ===
tune2fs -O ^has_journal /dev/sda2
tune2fs -o journal_data_writeback /dev/sda2
#add following line to /etc/fstab
/dev/sda2      /var/spool/voipmonitor  ext4    errors=remount-ro,noatime,nodiratime,data=writeback,barrier=0 0 0


In case your disk is still not able to handle traffic you can enable cachedir feature (voipmonitor.conf:cachedir) which stores all files into fast storage which can handle random write - for example RAM disk located at /dev/shm (every linux distribution have enabled this for up to 50% of memory). After the file is closed (call ends) voipmonitor automatically move the file from this storage to spooldir directory which is located on slower storage in guaranteed serial order which eliminates bad random write problem. This also allows to use network shares which is usually too slow to use it for writing directly to it by voipmonitor sniffer.
For extreme loads, bypass the kernel network stack entirely:


== MySQL performance ==
{| class="wikitable"
|-
! Solution !! Type !! CPU Reduction !! Use Case
|-
| '''[[DPDK]]''' || Open-source || ~70% || Multi-gigabit on commodity hardware
|-
| '''PF_RING ZC''' || Commercial || 90% → 20% || High-volume enterprise
|-
| '''[[Napatech|Napatech SmartNICs]]''' || Hardware || <3% at 10Gbit/s || Extreme performance
|}


=== Write performance ===
== Optimizing Disk I/O ==


Write performance depends a lot if a storage is also used for pcap storing (thus sharingn I/O with voipmonitor) and on how mysql handles writes (innodb_flush_log_at_trx_commit parameter - see below). Since sniffer version 6 MySQL tables uses compression which doubles write and read performance almost with no trade cost on CPU.
=== VoIPmonitor Storage Strategy ===


==== innodb_flush_log_at_trx_commit ====
VoIPmonitor groups all calls starting within the same minute into a single compressed <code>.tar</code> archive. This changes thousands of random writes into few sequential writes, reducing IOPS by 10x+.


Default value of 1 will mean each update transaction commit (or each statement outside of transaction) will need to flush log to the disk which is rather expensive, especially if you do not have Battery backed up cache. Many applications are OK with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.
'''Typical capacity:''' 7200 RPM SATA handles ~2,000 concurrent calls with full recording.
If you are importing or altering cdr table it is strongly recommended to set temporarily innodb_flush_log_at_trx_commit = 0 and turn off binlog if you are importing CDR via inserts.  


innodb_flush_log_at_trx_commit = 2
=== Filesystem Tuning (ext4) ===


==== compression ====
<syntaxhighlight lang="bash">
# Format without journal (requires battery-backed RAID)
mke2fs -t ext4 -O ^has_journal /dev/sda2
</syntaxhighlight>


===== MySQL 5.1 =====
<syntaxhighlight lang="ini">
# /etc/fstab
/dev/sda2  /var/spool/voipmonitor  ext4  errors=remount-ro,noatime,data=writeback,barrier=0  0 0
</syntaxhighlight>


set in my.cf in [global] section this value:
{{Warning|1=Disabling journal removes crash protection. Only use with battery-backed RAID controller (BBU).}}


innodb_file_per_table = 1
=== RAID Controller ===


===== MySQL > 5.1 =====
Set cache policy to '''WriteBack''' (not WriteThrough). Requires healthy BBU. Commands vary by vendor (<code>megacli</code>, <code>ssacli</code>, <code>perccli</code>).


MySQL> set global innodb_file_per_table = 1;
== Optimizing Database Performance ==
MySQL> set global innodb_file_format = barracuda;


===== Tune KEY_BLOCK_SIZE =====
=== Memory Configuration ===


If you choose KEY_BLOCK_SIZE=2 instead of 8 the compression will be twice better but with CPU penalty on read. We have tested differences between no compression, 8kb and 2kb block size compression on 700 000 CDR with this result (on single core system – we do not know how it behaves on multi core systems). Testing query is select with group by.
The most critical parameter is <code>innodb_buffer_pool_size</code>.
No compression – 1.6 seconds
8kb -  1.7 seconds
4kb - 8 seconds


=== Read performance ===
{{Warning|1=Setting too high causes OOM killer events, CDR delays, and crashes. See [[Sniffer_troubleshooting#Check_for_OOM_.28Out_of_Memory.29_Issues|OOM Troubleshooting]].}}


Read performance depends how big the database is and how fast disk operates and how much memory is allocated for innodb cache. Since sniffer version 7 all large tables uses partitioning by days which reduces needs to allocate very large cache to get good performance for the GUI. Partitioning works since MySQL 5.1 and is highly recommended. It also allows instantly removes old data by wiping partition instead of DELETE rows which can take hours on very large tables (millions of rows).
'''Buffer Pool Sizing:'''


==== innodb_buffer_pool_size ====
{| class="wikitable"
|-
! Server Type !! Formula !! Example (32GB RAM)
|-
| '''Shared''' (VoIPmonitor + MySQL) || (Total RAM - VoIPmonitor - OS) / 2 || 14GB
|-
| '''Dedicated''' MySQL server || 50-70% of total RAM || 20-22GB
|}


This is very important variable to tune if you’re using Innodb tables. Innodb tables are much more sensitive to buffer size compared to MyISAM. MyISAM may work kind of OK with default key_buffer_size even with large data set but it will crawl with default innodb_buffer_pool_size. Also Innodb buffer pool caches both data and index pages so you do not need to leave space for OS cache so values up to 70-80% of memory often make sense for Innodb only installations.
'''RAM Recommendations:'''


We recommend to set this value to 50% of your available RAM. 2GB at least, 8GB is optimal. All depends how many CDR do you have per day.
{| class="wikitable"
|-
! Deployment Size !! Minimum !! Recommended
|-
| Small (<500 calls) || 8GB || 16GB
|-
| Medium (500-2000) || 16GB || 32GB
|-
| Large (>2000) || 32GB || 64GB+
|}


innodb_buffer_pool_size = 8GB
=== Key MySQL Parameters ===


<syntaxhighlight lang="ini">
# /etc/mysql/my.cnf or mariadb.conf.d/50-server.cnf
[mysqld]
innodb_buffer_pool_size = 14G
innodb_flush_log_at_trx_commit = 2  # Faster, minimal data loss risk
innodb_file_per_table = 1          # Essential for partitioning
innodb_compression_algorithm = lz4  # MariaDB only
</syntaxhighlight>


=== Partitioning ===
=== Slow Query Log ===


Partitioning is enabled by default since version 7. If you want to take benefit of it you need to start with clean database - there is no conversion procedure from old database to partitioned one. Just create new database and start voipmonitor with new database and partitioning will be created. You can turn off partitioning by setting cdr_partition = no in voipmonitor.conf
The slow query log can consume significant memory. Consider disabling on high-traffic systems:
 
<syntaxhighlight lang="ini">
[mysqld]
slow_query_log = 0
# Or increase threshold: long_query_time = 600
</syntaxhighlight>
 
=== Database Partitioning ===
 
VoIPmonitor automatically partitions large tables (like <code>cdr</code>) by day. This is enabled by default and '''highly recommended'''.
 
See [[Data_Cleaning#Database_Cleaning_.28CDR_Retention.29|Database Partitioning]] for details.
 
=== Troubleshooting: Connection Refused ===
 
'''Symptoms:''' GUI crashes, "Connection refused" errors, intermittent issues during peak volumes.
 
'''Cause:''' <code>innodb_buffer_pool_size</code> too low (default 128M is insufficient).
 
'''Solution:''' Increase to 6G+ based on available RAM:
 
<syntaxhighlight lang="ini">
[mysqld]
innodb_buffer_pool_size = 6G
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
systemctl restart mariadb
</syntaxhighlight>
 
== Component Separation (Multi-Host Architecture) ==
 
For deployments exceeding 5,000-10,000 concurrent calls, separate VoIPmonitor components onto dedicated hosts.
 
=== Architecture Overview ===
 
{| class="wikitable"
|-
! Host !! Component !! Primary Resources !! Scaling Strategy
|-
| '''Host 1''' || MySQL Database || RAM, fast SSD || Add RAM, read replicas
|-
| '''Host 2''' || Sensor(s) || CPU (t0 thread), network || DPDK/PF_RING, more sensors
|-
| '''Host 3''' || GUI || CPU, network || Load balancer, caching
|}
 
=== Configuration ===
 
'''MySQL Server:'''
<syntaxhighlight lang="ini">
# /etc/mysql/my.cnf
[mysqld]
bind-address = 0.0.0.0
innodb_buffer_pool_size = 50G  # 50-70% RAM for dedicated server
</syntaxhighlight>
 
<syntaxhighlight lang="sql">
CREATE USER 'voipmonitor'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON voipmonitor.* TO 'voipmonitor'@'%';
</syntaxhighlight>
 
'''Sensor:'''
<syntaxhighlight lang="ini">
# /etc/voipmonitor.conf
id_sensor = 1
mysqlhost = mysql.server.ip
mysqldb = voipmonitor
mysqlusername = voipmonitor
mysqlpassword = strong_password
</syntaxhighlight>
 
'''GUI:''' Configure via Settings > System Configuration > Database, or edit <code>config/system_configuration.php</code>.
 
'''Firewall Rules:'''
{| class="wikitable"
|-
! Source !! Destination !! Port !! Purpose
|-
| Sensor || MySQL || 3306 || CDR writes
|-
| GUI || MySQL || 3306 || Queries
|-
| GUI || Sensor(s) || 5029 || PCAP retrieval
|-
| Users || GUI || 80, 443 || Web access
|}
 
{{Note|1=Component separation can be combined with [[Sniffer_distributed_architecture|Client-Server mode]] for multi-site deployments.}}
 
== Monitoring Performance ==
 
VoIPmonitor logs metrics every 10 seconds:
 
<syntaxhighlight lang="bash">
tail -f /var/log/syslog | grep voipmonitor
</syntaxhighlight>
 
'''Sample output:'''
<syntaxhighlight lang="text">
calls[315][355] PS[C:4 S:29 R:6354] SQLq[0] heap[0|0|0] t0CPU[5.2%] RSS/VSZ[323|752]MB
</syntaxhighlight>
 
{| class="wikitable"
|-
! Metric !! Description !! Warning Sign
|-
| <code>calls[X][Y]</code> || Active / total calls in memory || -
|-
| <code>SQLq[N]</code> || SQL queries queued || Growing = DB bottleneck
|-
| <code>heap[A{{!}}B{{!}}C]</code> || Buffer usage % || A=100% = packet drops
|-
| <code>t0CPU[X%]</code> || Capture thread CPU || >90% = limit reached
|-
| <code>RSS/VSZ[X{{!}}Y]</code> || Memory usage (MB) || RSS growing = leak
|}
 
== See Also ==
 
* [[Sniffer_troubleshooting]] - Troubleshooting including OOM issues
* [[Data_Cleaning]] - Database and spool retention
* [[Sniffer_configuration]] - Complete configuration reference
* [[DPDK]] - DPDK setup guide
* [[Sniffer_distributed_architecture]] - Client-Server mode
 
== AI Summary for RAG ==
 
'''Summary:''' VoIPmonitor scaling guide covering three bottlenecks: (1) Packet Capture - use TPACKET_V3, NIC tuning (ethtool ring buffer/interrupt coalescing), interface_ip_filter instead of BPF, kernel-bypass (DPDK, PF_RING, Napatech); (2) Disk I/O - TAR-based storage, ext4 tuning, RAID WriteBack cache; (3) Database - innodb_buffer_pool_size formula: shared servers = (RAM - VoIPmonitor - OS) / 2, dedicated = 50-70% RAM. Capacity: ~10,000 calls with full RTP, 60,000+ SIP-only. Component separation for >5,000 calls: MySQL/Sensor/GUI on separate hosts. Monitor t0CPU and SQLq in syslog.
 
'''Keywords:''' scaling, performance, bottleneck, t0CPU, SQLq, TPACKET_V3, DPDK, PF_RING, Napatech, ethtool, ring buffer, interrupt coalescing, interface_ip_filter, pcap_dump_writethreads, jitterbuffer, innodb_buffer_pool_size, OOM, database partitioning, component separation, three host architecture, dedicated MySQL, remote database
 
'''Key Questions:'''
* How do I scale VoIPmonitor for thousands of concurrent calls?
* What are the main performance bottlenecks?
* How do I fix high t0CPU usage?
* What is DPDK and when should I use it?
* How do I calculate innodb_buffer_pool_size?
* What causes "MariaDB connection refused" errors?
* How do I deploy MySQL, GUI, and Sensor on separate servers?
* How do I interpret syslog performance metrics?
* How much RAM does VoIPmonitor need?

Latest revision as of 16:50, 8 January 2026


This guide covers performance tuning for high-traffic VoIPmonitor deployments, addressing the three primary system bottlenecks.

Understanding Performance Bottlenecks

A VoIPmonitor deployment's capacity is limited by three potential bottlenecks:

Bottleneck Description Monitor
1. Packet Capture Single CPU core reading packets from NIC t0CPU in syslog
2. Disk I/O Writing PCAP files to storage iostat, ioping
3. Database CDR ingestion and GUI queries SQLq in syslog

Capacity: A modern server (24-core Xeon, 10Gbit NIC) can handle ~10,000 concurrent calls with full RTP recording, or 60,000+ with SIP-only analysis.

Optimizing Packet Capture (CPU & Network)

The packet capture thread (t0) runs on a single CPU core. If t0CPU approaches 100%, you've hit the capture limit.

Prerequisites

  • Linux kernel 3.2+ with TPACKET_V3 support
  • Latest VoIPmonitor static binary

With a modern kernel and VoIPmonitor build, a standard Intel 10Gbit NIC handles up to 2 Gbit/s VoIP traffic without special drivers.

NIC Tuning (>500 Mbit/s)

# Increase ring buffer (prevents packet loss during CPU spikes)
ethtool -g eth0                  # Check max size
ethtool -G eth0 rx 16384         # Set to max

# Enable interrupt coalescing (reduces CPU overhead)
ethtool -C eth0 rx-usecs 1022

Persistent settings (Debian/Ubuntu /etc/network/interfaces):

auto eth0
iface eth0 inet manual
    up ip link set $IFACE up
    up ip link set $IFACE promisc on
    up ethtool -G $IFACE rx 16384
    up ethtool -C $IFACE rx-usecs 1022

Configuration Optimizations

Parameter Purpose Recommendation
interface_ip_filter IP-based filtering More efficient than BPF filter
pcap_dump_writethreads_max Compression threads Set to CPU core count
jitterbuffer_f1/f2/adapt Jitter simulation Disable to save CPU (loses MOS metrics)
# /etc/voipmonitor.conf

# Efficient IP filtering (replaces BPF filter)
interface_ip_filter = 192.168.0.0/24
interface_ip_filter = 10.0.0.0/8

# Compression scaling
pcap_dump_writethreads = 1
pcap_dump_writethreads_max = 32
pcap_dump_asyncwrite = yes

⚠️ Warning: Disabling jitterbuffer_* removes MOS/jitter metrics. Only disable if you don't need quality monitoring.

Kernel-Bypass Solutions

For extreme loads, bypass the kernel network stack entirely:

Solution Type CPU Reduction Use Case
DPDK Open-source ~70% Multi-gigabit on commodity hardware
PF_RING ZC Commercial 90% → 20% High-volume enterprise
Napatech SmartNICs Hardware <3% at 10Gbit/s Extreme performance

Optimizing Disk I/O

VoIPmonitor Storage Strategy

VoIPmonitor groups all calls starting within the same minute into a single compressed .tar archive. This changes thousands of random writes into few sequential writes, reducing IOPS by 10x+.

Typical capacity: 7200 RPM SATA handles ~2,000 concurrent calls with full recording.

Filesystem Tuning (ext4)

# Format without journal (requires battery-backed RAID)
mke2fs -t ext4 -O ^has_journal /dev/sda2
# /etc/fstab
/dev/sda2  /var/spool/voipmonitor  ext4  errors=remount-ro,noatime,data=writeback,barrier=0  0 0

⚠️ Warning: Disabling journal removes crash protection. Only use with battery-backed RAID controller (BBU).

RAID Controller

Set cache policy to WriteBack (not WriteThrough). Requires healthy BBU. Commands vary by vendor (megacli, ssacli, perccli).

Optimizing Database Performance

Memory Configuration

The most critical parameter is innodb_buffer_pool_size.

⚠️ Warning: Setting too high causes OOM killer events, CDR delays, and crashes. See OOM Troubleshooting.

Buffer Pool Sizing:

Server Type Formula Example (32GB RAM)
Shared (VoIPmonitor + MySQL) (Total RAM - VoIPmonitor - OS) / 2 14GB
Dedicated MySQL server 50-70% of total RAM 20-22GB

RAM Recommendations:

Deployment Size Minimum Recommended
Small (<500 calls) 8GB 16GB
Medium (500-2000) 16GB 32GB
Large (>2000) 32GB 64GB+

Key MySQL Parameters

# /etc/mysql/my.cnf or mariadb.conf.d/50-server.cnf
[mysqld]
innodb_buffer_pool_size = 14G
innodb_flush_log_at_trx_commit = 2  # Faster, minimal data loss risk
innodb_file_per_table = 1           # Essential for partitioning
innodb_compression_algorithm = lz4  # MariaDB only

Slow Query Log

The slow query log can consume significant memory. Consider disabling on high-traffic systems:

[mysqld]
slow_query_log = 0
# Or increase threshold: long_query_time = 600

Database Partitioning

VoIPmonitor automatically partitions large tables (like cdr) by day. This is enabled by default and highly recommended.

See Database Partitioning for details.

Troubleshooting: Connection Refused

Symptoms: GUI crashes, "Connection refused" errors, intermittent issues during peak volumes.

Cause: innodb_buffer_pool_size too low (default 128M is insufficient).

Solution: Increase to 6G+ based on available RAM:

[mysqld]
innodb_buffer_pool_size = 6G
systemctl restart mariadb

Component Separation (Multi-Host Architecture)

For deployments exceeding 5,000-10,000 concurrent calls, separate VoIPmonitor components onto dedicated hosts.

Architecture Overview

Host Component Primary Resources Scaling Strategy
Host 1 MySQL Database RAM, fast SSD Add RAM, read replicas
Host 2 Sensor(s) CPU (t0 thread), network DPDK/PF_RING, more sensors
Host 3 GUI CPU, network Load balancer, caching

Configuration

MySQL Server:

# /etc/mysql/my.cnf
[mysqld]
bind-address = 0.0.0.0
innodb_buffer_pool_size = 50G  # 50-70% RAM for dedicated server
CREATE USER 'voipmonitor'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON voipmonitor.* TO 'voipmonitor'@'%';

Sensor:

# /etc/voipmonitor.conf
id_sensor = 1
mysqlhost = mysql.server.ip
mysqldb = voipmonitor
mysqlusername = voipmonitor
mysqlpassword = strong_password

GUI: Configure via Settings > System Configuration > Database, or edit config/system_configuration.php.

Firewall Rules:

Source Destination Port Purpose
Sensor MySQL 3306 CDR writes
GUI MySQL 3306 Queries
GUI Sensor(s) 5029 PCAP retrieval
Users GUI 80, 443 Web access

ℹ️ Note: Component separation can be combined with Client-Server mode for multi-site deployments.

Monitoring Performance

VoIPmonitor logs metrics every 10 seconds:

tail -f /var/log/syslog | grep voipmonitor

Sample output:

calls[315][355] PS[C:4 S:29 R:6354] SQLq[0] heap[0|0|0] t0CPU[5.2%] RSS/VSZ[323|752]MB
Metric Description Warning Sign
calls[X][Y] Active / total calls in memory -
SQLq[N] SQL queries queued Growing = DB bottleneck
B|C] Buffer usage % A=100% = packet drops
t0CPU[X%] Capture thread CPU >90% = limit reached
Y] Memory usage (MB) RSS growing = leak

See Also

AI Summary for RAG

Summary: VoIPmonitor scaling guide covering three bottlenecks: (1) Packet Capture - use TPACKET_V3, NIC tuning (ethtool ring buffer/interrupt coalescing), interface_ip_filter instead of BPF, kernel-bypass (DPDK, PF_RING, Napatech); (2) Disk I/O - TAR-based storage, ext4 tuning, RAID WriteBack cache; (3) Database - innodb_buffer_pool_size formula: shared servers = (RAM - VoIPmonitor - OS) / 2, dedicated = 50-70% RAM. Capacity: ~10,000 calls with full RTP, 60,000+ SIP-only. Component separation for >5,000 calls: MySQL/Sensor/GUI on separate hosts. Monitor t0CPU and SQLq in syslog.

Keywords: scaling, performance, bottleneck, t0CPU, SQLq, TPACKET_V3, DPDK, PF_RING, Napatech, ethtool, ring buffer, interrupt coalescing, interface_ip_filter, pcap_dump_writethreads, jitterbuffer, innodb_buffer_pool_size, OOM, database partitioning, component separation, three host architecture, dedicated MySQL, remote database

Key Questions:

  • How do I scale VoIPmonitor for thousands of concurrent calls?
  • What are the main performance bottlenecks?
  • How do I fix high t0CPU usage?
  • What is DPDK and when should I use it?
  • How do I calculate innodb_buffer_pool_size?
  • What causes "MariaDB connection refused" errors?
  • How do I deploy MySQL, GUI, and Sensor on separate servers?
  • How do I interpret syslog performance metrics?
  • How much RAM does VoIPmonitor need?