Rspamd vs SpamAssassin: 2027 Event-Driven C/Lua Engine vs Legacy Perl Milter Architecture
Published by Fred Dawson • Senior Deliverability Systems Architect • 19 min read
For over two decades, Apache SpamAssassin has served as the de facto open-source standard for mail filtering. However, as modern email pipelines scale to tens of millions of daily messages, SpamAssassin’s process-per-connection Perl runtime, heavy memory footprint (80MB-120MB per child worker), and synchronous regex evaluation create severe throughput bottlenecks. In contrast, Rspamd was engineered from the ground up in C with an asynchronous event-driven loop (libevent) and LuaJIT scripting, delivering 10x-50x higher throughput, native Redis integration, deep neural network scoring, and built-in DKIM/ARC/DMARC signing.
- 1. Runtime Architecture: Async C/Lua vs Preforked Perl
- 2. Throughput, Concurrency & Memory Footprint
- 3. Redis Integration, Fuzzy Hashing & Neural Modules
- 4. Cryptographic Auth: Native DKIM/ARC vs External Milters
- 5. Rspamd vs SpamAssassin Technical Matrix
- 6. The AutoSMTP Deliverability Defense Advantage
1. Runtime Architecture: Async C/Lua vs Preforked Perl
The core architectural divide between Rspamd and SpamAssassin is their underlying language runtime and concurrency model:
SpamAssassin: Written in Perl, SpamAssassin operates via the spamd daemon or through milters like amavisd-new. It relies on a preforked process model where each incoming email allocates or locks an entire Perl interpreter process. Each worker compiles regex rules, evaluates body parts sequentially, and queries external DNSBLs synchronously or semi-asynchronously. This introduces high CPU context switching and limits horizontal scaling on multicore systems.
Rspamd: Written in C99, Rspamd employs an asynchronous event-driven architecture powered by libevent and LuaJIT. A single master process controls a pool of lightweight non-blocking worker processes. Network I/O, DNS queries, and Redis lookups are completely asynchronous; a single worker process can handle thousands of concurrent SMTP connection streams without spawning additional operating system threads or processes.
-- Rspamd: High-speed asynchronous Lua rule with Redis check
rspamd_config:register_symbol({
name = 'CORP_URIBL_CHECK',
score = 4.5,
callback = function(task)
local urls = task:get_urls()
for _, url in ipairs(urls) do
if url:get_tld() == 'suspicious.top' then
return true
end
end
return false
end
})
# SpamAssassin: Traditional regex rule in local.cf
body LOCAL_SUSPICIOUS_TLD /https?:\/\/[^\/]+\.suspicious\.top/i
score LOCAL_SUSPICIOUS_TLD 4.5
describe LOCAL_SUSPICIOUS_TLD Detects suspicious top-level domains
2. Throughput, Concurrency & Memory Footprint
Under burst conditions (such as handling a flash inbound marketing campaign or sudden dictionary attack), SpamAssassin’s memory consumption escalates rapidly. Running 50 concurrent spamd child processes easily consumes 4 GB to 6 GB of RAM, with CPU utilization hitting 100% on regex backtracking.
Rspamd processes the same volume utilizing under 150 MB of total RAM. Benchmarks across bare-metal NVMe clusters demonstrate Rspamd sustaining over 8,000 to 12,000 messages per second on an 8-core server, whereas an optimized SpamAssassin cluster tops out between 250 and 400 messages per second on identical hardware.
3. Redis Integration, Fuzzy Hashing & Neural Modules
Rspamd treats Redis as a first-class citizen. It utilizes Redis for:
- Fuzzy Hashing: Instant detection of polymorphic bulk spam by hashing image and text structures rather than exact byte matches.
- Dynamic Rate Limiting: Enforcing outbound and inbound per-domain, per-IP, and per-user recipient limits in real time.
- Bayes Classification: Sub-millisecond token storage and retrieval across distributed cluster nodes.
- Deep Neural Networks: The built-in
neuralmodule trains perceptrons on historical spam/ham scores, continuously refining classification accuracy without manual rule tweaking.
4. Cryptographic Auth: Native DKIM/ARC vs External Milters
In a traditional Postfix + SpamAssassin stack, implementing modern email authentication requires chaining multiple separate milters: OpenDKIM for DKIM signing/verification, OpenDMARC for DMARC enforcement, and OpenARC for Authenticated Received Chain validation. Each milter adds a TCP/Unix socket hop, increasing latency and failure surface.
Rspamd incorporates native, optimized C modules for DKIM signing, DKIM verification, ARC validation, and strict DMARC reporting. A single milter socket connection between Postfix/KumoMTA and Rspamd handles content inspection, antispam scoring, dynamic cryptographic signing, and reputation logging in a single pass.
5. Rspamd vs SpamAssassin Technical Matrix
| Architectural Pillar | Rspamd Engine | Apache SpamAssassin | Engineering Verdict |
|---|---|---|---|
| Language Runtime | C99 + LuaJIT (Asynchronous Event Loop) | Perl (Preforked Process / Single-Threaded) | Rspamd: 20x-50x faster execution speed |
| Throughput Capacity | 5,000 – 12,000 msgs/sec per 8-core host | 150 – 400 msgs/sec per 8-core host | Rspamd: Handles carrier-grade email bursts |
| Memory Consumption | 80MB – 180MB total resident memory | 70MB – 120MB per worker process | Rspamd: 90% lower RAM overhead |
| Backend Storage | Native Redis cluster (Async non-blocking) | Flat files, Berkeley DB, or SQL (MySQL/Pg) | Rspamd: Sub-millisecond Bayes & token lookups |
| DKIM / ARC / DMARC | Native built-in C modules for signing & verify | Requires external OpenDKIM & OpenDMARC milters | Rspamd: Single milter pipeline replaces 3 daemons |
| Web UI & Observability | Built-in AJAX WebUI with live stats & learning | CLI utilities (sa-learn) or 3rd party web tools | Rspamd: Instant visual score telemetry |
Enterprise ISP: Replacing 12 SpamAssassin Nodes with 2 Rspamd Servers
A regional telecommunications ISP was operating an amavisd-new cluster with 12 virtualized SpamAssassin nodes consuming 64 GB of RAM to filter 20 million daily inbound and outbound messages. During morning traffic surges, queue latency averaged 4.5 seconds per message, causing remote MTAs to drop connections. By replacing the cluster with two bare-metal servers running Rspamd and Redis, average processing latency plummeted to 14 milliseconds per message, server count dropped by 83%, and spam false-positive rates decreased by 34%.
2027 Engineering Recommendation
For any new email infrastructure deployment or modernization initiative:
- SpamAssassin: Best maintained only on legacy installations with extensive custom Perl plugins that cannot easily be ported to Lua.
- Rspamd: The unequivocal choice for modern high-volume infrastructure. Its unified architecture eliminates OpenDKIM/OpenDMARC milter chains while cutting server compute costs by up to 80%.
The AutoSMTP Deliverability Defense Advantage
Inbound and outbound filtering pipelines require robust underlying transport hardware. AutoSMTP provisions sovereign, dedicated bare-metal MTA infrastructure engineered for high-throughput filtering, synchronous 550 bounce suppression, and permanent reputation control.
Provisions fully licensed PowerMTA and KumoMTA clusters on enterprise bare-metal with dedicated IPv4 subnets and predictable flat pricing.
Monitors Google Postmaster spam ratios (<0.1%) and real-time ISP deferrals with algorithmic volume scaling across your entire IP pool.
RFC 5321 in-band 550 bounce suppression, automated Yahoo/Outlook Complaint Feedback Loops (CFL), and instant bad-IP eviction.
Pre-configured forward and reverse DNS (PTR) per IP, SPF CIDR alignment, 2048-bit DKIM rotation, and strict DMARC enforcement.
Upgrade Your Email Infrastructure with Dedicated Bare Metal
Eliminate filter lag, queue serialization bottlenecks, and noisy neighbor contamination. Deploy a turnkey AutoSMTP cluster today.
Deploy Turnkey MTA Cluster →