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.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alonsoir/test-zeromq-c-/llms.txt
Use this file to discover all available pages before exploring further.
Benchmark Results
All benchmarks from real production testing on Debian Bookworm (6 CPU cores, 8GB RAM).
ML Detector Performance
From Day 52 testing:| Metric | Value | Notes |
|---|---|---|
| Detection Latency | <1 μs | Sub-microsecond per packet |
| Throughput | 1M+ pkt/s | Tested with synthetic traffic |
| Features Extracted | 83 per flow | Flow-based aggregation |
| Models | 4 concurrent | DDoS, Ransomware, Traffic, Anomaly |
| Memory | 256 MB RSS | Stable over 8-hour test |
| CPU | 8.5% avg | Single core |
Firewall ACL Agent Performance
From Day 52 stress testing (36,000 events):| Test | Events | Rate | CPU | Memory | Result |
|---|---|---|---|---|---|
| Test 1 | 1,000 | 42.6/sec | N/A | N/A | ✅ PASS |
| Test 2 | 5,000 | 94.9/sec | N/A | N/A | ✅ PASS |
| Test 3 | 10,000 | 176.1/sec | 41-45% | N/A | ✅ PASS |
| Test 4 | 20,000 | 364.9/sec | 49-54% | 127 MB | ✅ PASS |
- 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
| Metric | Value | Notes |
|---|---|---|
| Capture Rate | 1,528 pkt/s | Real network traffic |
| eBPF Drops | 0 | Zero packet loss |
| Ring Buffer Full | 0 | Proper sizing |
| Batch Size | 10 packets | Configurable |
| Compression Ratio | 4.2x | LZ4 |
| CPU | 12.1% | Single core |
| Memory | 189 MB RSS | Including ring buffer |
Component-Specific Tuning
eBPF Sniffer Tuning
Ring Buffer Size
The eBPF ring buffer must be large enough to avoid packet loss:| Traffic Rate | Ring Buffer Size | Notes |
|---|---|---|
| <100 pkt/s | 64 KB | Low traffic |
| 100-1000 pkt/s | 256 KB | Default |
| 1K-10K pkt/s | 1 MB | High traffic |
| >10K pkt/s | 4 MB | Very high traffic |
Batch Processing
Batch size affects throughput and latency tradeoff:| Use Case | Batch Size | Timeout | Rationale |
|---|---|---|---|
| Low Latency | 5 | 50 ms | Minimize wait time |
| Balanced | 10 | 100 ms | Default (recommended) |
| High Throughput | 50 | 500 ms | Maximize efficiency |
| Extreme Load | 100 | 1000 ms | Reduce ZMQ overhead |
Compression
LZ4 compression provides 4.2x ratio with minimal CPU:| Level | Speed | Ratio | CPU | Use Case |
|---|---|---|---|---|
| 1 | Fastest | 4.0x | Low | Default (recommended) |
| 3 | Fast | 4.5x | Medium | Better compression |
| 9 | Slow | 5.2x | High | Bandwidth-constrained |
ML Detector Tuning
Model Thresholds
Adjust detection thresholds to balance false positives vs false negatives:| Threshold | False Positives | False Negatives | Use Case |
|---|---|---|---|
| 0.70 | High | Low | Aggressive blocking |
| 0.85 | Medium | Medium | Balanced (default) |
| 0.95 | Low | High | Conservative |
Adjust
- If too many false positives: Increase threshold
- If missing threats: Decrease threshold
- Adjust per-model (DDoS vs Ransomware may need different values)
Batch Size
ML Detector processes packets in batches for efficiency:| Traffic Rate | Batch Size | Timeout | Latency Impact |
|---|---|---|---|
| <100 pkt/s | 10 | 20 ms | +20 ms |
| 100-1K pkt/s | 100 | 50 ms | +50 ms |
| >1K pkt/s | 1000 | 100 ms | +100 ms |
Model Selection
Enable only models needed for your use case:| Models Enabled | CPU Usage | Memory | Latency |
|---|---|---|---|
| 1 model | 2-3% | 128 MB | <0.5 μs |
| 2 models | 4-6% | 192 MB | <0.8 μs |
| 4 models (all) | 8-10% | 256 MB | <1.0 μs |
Firewall ACL Agent Tuning
IPSet Capacity
Critical for production: IPSet has finite capacity.| Environment | Max Elements | Hash Size | Timeout | Notes |
|---|---|---|---|---|
| Testing | 1,000 | 1024 | 3600s (1h) | Default |
| Small Network | 10,000 | 4096 | 7200s (2h) | < 1000 users |
| Medium Network | 50,000 | 16384 | 14400s (4h) | 1K-10K users |
| Large Network | 500,000 | 65536 | 86400s (24h) | 10K+ users |
Batch Processing
| Attack Pattern | Batch Size | Timeout | Rationale |
|---|---|---|---|
| Slow Scan | 1 | 100 ms | Immediate blocking |
| DDoS Burst | 50 | 1000 ms | Reduce IPSet calls |
| Steady State | 10 | 1000 ms | Balanced (default) |
Crypto Pipeline
Day 52 testing proved crypto pipeline is production-ready:- 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:- 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:| Mode | Throughput | Latency | Compatibility |
|---|---|---|---|
| NATIVE | 10M+ pps | <1 μs | Limited |
| DRV | 5M+ pps | <2 μs | Most drivers |
| SKB | 1M+ pps | <10 μs | All NICs |
IP Forwarding and NAT
Optimize for gateway mode:Stress Test Methodology
8-Hour Stress Test
ML Defender includes a comprehensive stress test:source/stress_test_8h.sh
- Traffic Generator (
stress_test_traffic.sh): Generates synthetic traffic - Resource Monitor (
stress_test_monitor.sh): Tracks CPU, memory, performance - Main Test Loop: Monitors component health, generates report
Progressive Stress Tests
Day 52 methodology (4 progressive tests):Synthetic Traffic Generation
For controlled testing:Performance Monitoring During Tuning
Real-Time Performance
Bottleneck Identification
Memory Leak Detection
Optimization Checklist
Sniffer Optimization Checklist
Sniffer 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)
Detector Optimization Checklist
Detector Optimization Checklist
- 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)
Firewall Optimization Checklist
Firewall Optimization Checklist
- 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)
System Optimization Checklist
System Optimization Checklist
- 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