Skip to main content
ML Defender achieves sub-microsecond detection latency and processes 1M+ packets/second with proper tuning. This guide covers component-specific optimizations, benchmark results, and stress testing methodology.

Benchmark Results

All benchmarks from real production testing on Debian Bookworm (6 CPU cores, 8GB RAM).

ML Detector Performance

From Day 52 testing:

Firewall ACL Agent Performance

From Day 52 stress testing (36,000 events): Key Metrics (36K events total):
Discoveries:
  • Crypto pipeline is production-ready (0 errors @ 36K events)
  • IPSet capacity planning is critical (hit 1000 IP limit)
  • System exhibits graceful degradation (no crashes)
  • CPU efficiency excellent (54% max under extreme load)
  • Memory efficient (127MB even with 16K queue)

eBPF Sniffer Performance

Component-Specific Tuning

eBPF Sniffer Tuning

Ring Buffer Size

The eBPF ring buffer must be large enough to avoid packet loss:
Tuning Recommendations: Monitor ring buffer usage:

Batch Processing

Batch size affects throughput and latency tradeoff:
Tuning Guidelines:

Compression

LZ4 compression provides 4.2x ratio with minimal CPU:
Compression Levels:

ML Detector Tuning

Model Thresholds

Adjust detection thresholds to balance false positives vs false negatives:
Threshold Tuning: Calibration Process:
1

Baseline

Run with default thresholds (0.85) for 24 hours
2

Analyze

3

Adjust

  • If too many false positives: Increase threshold
  • If missing threats: Decrease threshold
  • Adjust per-model (DDoS vs Ransomware may need different values)
4

Validate

Test with known attack traffic (MAWI dataset, synthetic)

Batch Size

ML Detector processes packets in batches for efficiency:
Tuning Guidelines:
Larger batches increase throughput but add latency. For real-time blocking, keep batch_timeout_ms < 100.

Model Selection

Enable only models needed for your use case:
Performance Impact:

Firewall ACL Agent Tuning

IPSet Capacity

Critical for production: IPSet has finite capacity.
Capacity Planning: Monitor capacity:
When IPSet is full, new entries fail silently. This is by design (fail-closed). Implement eviction or multi-tier storage (see Roadmap).

Batch Processing

Tuning Guidelines:

Crypto Pipeline

Day 52 testing proved crypto pipeline is production-ready:
Performance Impact:
  • Decryption: 15.2 μs avg
  • Decompression: 11.8 μs avg
  • Total overhead: ~27 μs per message
  • Zero errors @ 36K events
Crypto overhead is negligible. Always keep encryption enabled in production.

CPU and Memory Optimization

CPU Affinity

Pin processes to specific CPU cores:
Benefits:
  • Reduces cache thrashing
  • Improves CPU cache locality
  • Prevents process migration overhead

Memory Limits

Set memory limits to prevent runaway processes:

NUMA Considerations

On NUMA systems, ensure memory locality:

Network Tuning

NIC Settings

Disable Offloading

eBPF/XDP requires raw packets:

Promiscuous Mode

Required for gateway mode:

Ring Buffer Size

Increase NIC ring buffer for high traffic:

eBPF/XDP Mode

XDP provides kernel-bypass for maximum performance:
Performance Comparison:

IP Forwarding and NAT

Optimize for gateway mode:

Stress Test Methodology

8-Hour Stress Test

ML Defender includes a comprehensive stress test:
Test Configuration:
source/stress_test_8h.sh
Test Components:
  1. Traffic Generator (stress_test_traffic.sh): Generates synthetic traffic
  2. Resource Monitor (stress_test_monitor.sh): Tracks CPU, memory, performance
  3. Main Test Loop: Monitors component health, generates report
1

Start test

2

Monitor progress

3

Review report

After test completes, review stress_test_*/REPORT.md:

Progressive Stress Tests

Day 52 methodology (4 progressive tests):
Monitor results:

Synthetic Traffic Generation

For controlled testing:

Performance Monitoring During Tuning

Real-Time Performance

Bottleneck Identification

Memory Leak Detection

Optimization Checklist

  • Ring buffer sized appropriately (check for drops)
  • Batch size tuned for latency vs throughput
  • Compression enabled (LZ4 level 1)
  • NIC offloading disabled (gro, tso, gso)
  • Promiscuous mode enabled
  • CPU affinity set
  • XDP mode appropriate for NIC (DRV recommended)
  • Thresholds calibrated for false positive rate
  • Batch size tuned for traffic rate
  • Unused models disabled
  • CPU affinity set
  • Memory limits configured
  • Crypto pipeline validated (0 errors)
  • IPSet capacity planned for environment
  • Timeout configured for threat duration
  • Batch processing tuned for attack pattern
  • Crypto pipeline enabled
  • CPU affinity set
  • Capacity monitoring enabled
  • Eviction strategy planned (for future)
  • IP forwarding enabled (gateway mode)
  • rp_filter disabled (gateway mode)
  • Conntrack tuned for connection volume
  • NUMA locality configured (if applicable)
  • Resource limits set (systemd)
  • Monitoring in place

Next Steps

Troubleshooting

Diagnose performance issues

Monitoring

Monitor performance metrics

Configuration

Review configuration options

Architecture

Understand data flow