Repository navigation
Performance and Scale Tuning
Home · Configuration Guide · Troubleshooting & Recovery
- CSF performance issues usually come from one of three places: rule volume, log/detection churn, or connection-tracking pressure.
- The biggest wins are usually:
LF_IPSET, sane deny limits, targeted detectors, and measured scan intervals. - Tune one subsystem at a time and validate after each change.
Related guides:
If you need fast, safe improvements without deep tuning yet:
- Baseline current behavior (
time csf -ra, rule/list size, recentlfd.log). - Enable and validate IPSET support (
csftest.pl, thenLF_IPSET=1if supported). - Keep deny limits bounded (
DENY_IP_LIMIT,DENY_TEMP_IP_LIMIT). - Leave
CT_LIMIT=0unless you have a clear abuse pattern and scoped plan. - Reload and compare baseline vs after-state.
Slows down when:
-
csf.deny/ temp deny lists grow large - large CC / blocklist feeds are loaded as classic iptables rules
- frequent restarts/reloads happen under heavy change
Primary controls:
LF_IPSETLF_IPSET_HASHSIZELF_IPSET_MAXELEMDENY_IP_LIMITDENY_TEMP_IP_LIMITFASTSTARTCC_DROP_CIDR
Slows down when:
- too many noisy detectors are enabled simultaneously
-
LF_PARSEis very aggressive - log scanner scope is broad (many files/globs)
Primary controls:
LF_PARSELF_INTERVAL-
LF_TRIGGER/ application triggers -
LOGSCANNER,LOGSCANNER_LINES, log-file scope
Slows down when:
-
CT_LIMIT/tracking is enabled with broad states/ports on busy protocols - large numbers of TIME_WAIT states are counted
Primary controls:
CT_LIMITCT_PORTSCT_STATESCT_SKIP_TIME_WAITCT_SUBNET_LIMIT
Capture current state first:
# Rule/list size indicators
wc -l /etc/csf/csf.deny /etc/csf/csf.allow /etc/csf/csf.ignore 2>/dev/null
csf -t | wc -l
# Reload timing (run a few times and compare)
time csf -ra
# Rule footprint snapshots
iptables -S | wc -l
ip6tables -S | wc -l
# lfd signal quality
tail -n 200 /var/log/lfd.logIf using IPSET:
ipset list -tFirst validate platform/module support:
perl /etc/csf/csftest.plThen configure:
LF_IPSET = "1"
LF_IPSET_HASHSIZE = "1024"
LF_IPSET_MAXELEM = "65536"Then scale hash/maxelem gradually based on set fullness and memory.
DENY_IP_LIMIT = "200"
DENY_TEMP_IP_LIMIT = "100"Increase only with clear need and capacity headroom.
FASTSTART = "1"This improves restart/reload behavior by using save/restore paths.
CC_DROP_CIDR = "16"Use only when you intentionally accept coarser CC granularity for throughput gain.
LF_PARSE = "5"- Lower values react faster but increase parser churn.
- Raise carefully if CPU pressure is sustained and response latency tolerance allows.
-
LF_TRIGGER = "0"→ app-specific thresholds are used directly. -
LF_TRIGGER > "0"→ cumulative threshold model (app toggles become on/off).
Choose the model that fits your noise profile and keeps false-positive pressure manageable.
Particularly on busy shared environments, be conservative with:
LF_APACHE_404LF_APACHE_403LF_APACHE_401- aggressive script/queue checks without baseline
If enabling CT_LIMIT, avoid all-ports/all-states as first move.
CT_LIMIT = "300"
CT_INTERVAL = "30"
CT_PORTS = "80,443"
CT_SKIP_TIME_WAIT = "1"
CT_STATES = "SYN_RECV,ESTABLISHED"Then tune from observed false positives.
LOGSCANNER can become expensive with broad file globs.
LOGSCANNER = "0" # or keep narrow scope
LOGSCANNER_LINES = "5000"If enabled, restrict monitored files and ignore noisy patterns aggressively.
- v1 HTTPS messenger can be memory-heavy on large cert/domain inventories.
- Prefer
MESSENGERV3where supported.
Reference: Messenger Service
-
List/rule volume first (
LF_IPSET, deny limits, CC scope) -
Detection noise second (
LF_PARSE, trigger model, noisy detectors) -
Connection tracking third (
CT_*narrowly scoped) -
Scanner/report extras last (
LOGSCANNER, optional alerts)
After each step:
csf -ra
tail -n 100 /var/log/lfd.logOnly change one major subsystem per maintenance window. This keeps root-cause analysis simple if behavior regresses.
FASTSTART = "1"
LF_IPSET = "1"
DENY_IP_LIMIT = "200"
DENY_TEMP_IP_LIMIT = "100"
CT_LIMIT = "0"
LOGSCANNER = "0"Notes:
- enable
LF_IPSETonly ifcsftest.plconfirms support on your platform/container - avoid broad CC deny sets unless absolutely required
- keep detector set minimal and deliberate
LF_IPSET = "1"
CT_LIMIT = "0" # start disabled, enable only with scoped ports if needed
PORTFLOOD = "443;tcp;40;5"
LF_PARSE = "5"Notes:
- validate real client IP restoration before aggressive auth/trigger automation
- avoid
CT_SUBNET_LIMITfor proxied ports unless architecture explicitly supports it
LF_IPSET = "1"
DENY_IP_LIMIT = "500"
DENY_TEMP_IP_LIMIT = "300"
LF_TRIGGER = "0" # keep app-specific thresholds explicit initially
PT_INTERVAL = "60"
PT_USERKILL = "0"Notes:
- prioritize false-positive control and operational predictability
- tune login/script thresholds with real traffic history
| Symptom | Fast triage action |
|---|---|
csf -ra takes too long |
check rule/list size, enable/tune IPSET, bound deny limits |
| repeated lock contention/hung iptables ops | evaluate WAITLOCK strategy and competing firewall tooling |
| high lfd CPU with noisy logs | raise LF_PARSE modestly, disable/tune noisy detectors, narrow log scanner scope |
| many false CT blocks | set CT_LIMIT=0 temporarily, then re-enable with scoped CT_PORTS/states |
| rule churn during DDoS-like events | cap deny lists, avoid over-broad auto-blocking features, keep rollback path ready |
- trusted admin access still works (IPv4 + IPv6 if enabled)
- reload time improved or at least not regressed
- no spike in false-positive block events
-
lfd.logshows stable behavior (no repeating parser/errors) - temporary/permanent block lifecycle still matches policy intent
Last reviewed: 2026-02-25
- Security Features Guide
- Cloud & Container Hardening
- Automation & IaC
- IPv6 Deployment & Hardening
- IP Block Lists
- Reference Map
- Introduction
- csf Principles
- lfd Principles
- csf CLI Options
- lfd CLI Options
- Login Tracking
- Regex Custom Cookbook
- Script Email Alerts
- Process Tracking
- Directory Watching
- Advanced Filters
- Multiple Ethernet
- Generic Linux
- FTP Issues
- Messenger Service
- Block Reporting
- Port Flood
- Pre/Post Scripts
- Port Knocking
- Connection Limit
- Port/IP Redirect
- Integrated UI
- RESTRICT_SYSLOG
- Exim SMTP AUTH
- UI Skinning
- InterWorx
- CentOS Web Panel