Software defined networks (SDN) introduce centralized controllers to
drastically increase network programmability. The simplicity of a logical
centralized controller, however, can come at the cost of controller programming
complexity and scalability. In this paper, we present McNettle, an extensible
SDN controller system whose control event processing throughput scales with the
number of system CPU cores and which supports control algorithms requiring
globally visible state changes occurring at flow arrival rates. Programmers
extend McNettle by writing event handlers and background programs in a
high-level functional programming language extended with shared state and
memory transactions. We implement our framework in Haskell and leverage the
multicore facilities of the Glasgow Haskell Compiler (GHC) and runtime system.
Our implementation schedules event handlers, allocates memory, optimizes
message parsing and serialization, and buffers system calls in order to
optimize cache usage, OS processing, and runtime system overhead. We identify
and fix bottlenecks in the GHC runtime system and IO manager. Our experiments
show that McNettle can serve up to 5000 switches using a single controller with
46 cores, achieving throughput of over 14 million flows per second, near-linear
scaling up to 46 cores, and latency under 10 ms with loads consisting of up to
1500 switches.