The SMS Gateway Problem
In 2009, SMS was still king. No WhatsApp, no push notifications, no RCS. If you needed to reach someone reliably on a mobile phone, you sent an SMS. And if you needed to reach millions of people — political campaigns, banks, service alerts — you needed a gateway that could handle the throughput.
At Airhub, we chose Kannel. Here's why that was the right choice, and what I learned maintaining it at scale.
What Kannel Is
Kannel is an open source WAP gateway and SMS gateway written in C. It was developed by the Kannel Project and remains one of the most capable SMS gateways for high-throughput applications. The C implementation means it's memory-efficient and fast — able to handle enormous message volumes on hardware that would make modern cloud engineers wince.
Kannel connects to mobile networks via SMPP (Short Message Peer-to-Peer) — the industry protocol for SMS exchange between systems. You connect to an operator's SMSC (Short Message Service Centre) via SMPP, and Kannel handles the protocol details, message queuing, and throughput management.
Tuning for High Throughput
Our target was ~200K TPS (transactions per second) across multiple operator connections. Getting there required careful tuning:
SMPP connection management: Each operator connection has a maximum throughput limit. We maintained multiple simultaneous SMPP connections per operator and load-balanced across them. Kannel's bearerbox component manages these connections and the message routing logic.
Database performance: Kannel can log messages to a database. At 200K TPS, naive database writes become the bottleneck immediately. We implemented asynchronous write buffering — messages were logged to memory first, then flushed to MySQL in batches.
OS-level tuning: File descriptor limits, TCP buffer sizes, and network interrupt handling all needed adjustment for this scale. The default Linux kernel settings were nowhere near adequate.
Hardware: We ran on modest hardware by today's standards — but with direct hardware allocation, not virtualisation. Predictable latency matters for SMPP connections.
The Lessons
Kannel taught me two things I've never forgotten. First: open source software can be genuinely world-class. The Kannel codebase is well-architected, the documentation is thorough, and the community knows the domain deeply. Don't dismiss open source for critical infrastructure.
Second: throughput and latency are different problems. High throughput needs queuing, batching, and parallelism. Low latency needs the opposite — short queues, immediate processing. Understanding which you're optimising for is essential before you start tuning.