Lecture 2 - Developing Virtual Network Functions
Lecture 2 - Developing Virtual Network Functions
If match
found Send packet
to backend
instance
…
Pre-allocated buffers
Each ring slot points for holding incoming
to a preallocated packets
buffer
…
Pre-allocated buffers for storing packets
● Incoming packet is DMA’d into the buffer along with adding new
packet descriptor to ring buffer
● DPDK uses hugepages to maintain large pools of memory
○ Each page is 2 MB in size (compared to traditional 4KB pages)
○ Fewer pages ⇒ Fewer TLB misses ⇒ improved performance
…
Pre-allocated buffers
for holding incoming
packets
…
Advance the ring
write pointer DMA packet data
No overhead of copying packet data
● NIC DMA transfers packets directly to userspace buffers
● Protocol processing (TCP/IP) is done using those buffered packets in
place
○ …if needed by the network function [Note: not all NFs require TCP/IP processing
Upshot of NF using DPDK and Intelligent NICs
● All the kernel overheads in packet processing (alluded to earlier)
mitigated/eliminated
● Results in performance-conscious implementation of the VNF
● Developer of NF can concentrate on just the functionality of the NF
○ DPDK alleviates all the packet processing overheads for any NF
Outline
● Virtual network functions (VNF): revisiting “load balancer” as a
concrete example
● Performance issues in implementing virtual network functions
● Performance-conscious implementation of virtual network functions
● Data Plane Development Kit (DPDK) - an exemplar for user-space
packet processing
● Implementation of VNF on commodity hardware using DPDK
● Putting it together: load balancer example using DPDK
DPDK optimizations
Various optimization opportunities are available in DPDK to improve
packet processing
How to ensure that the cores processing packets are on same NUMA
socket as the NIC?
Receive side scaling: Useful hardware
technology
●Enabler of multi-core processing
● Use hashing to distribute incoming
packets to individual cores
○ Hash function takes 5-tuple of packet as
input Hash
○ src_ip, dst_ip, src_port, dst_port, proto Functio
n
● Each core is assigned a unique ring
buffer to poll
○ No contention among threads
● Different connection ⇒ Different
Ring CPU
queue (ring) ⇒ Different core buffers cores
○ Per-connection state is accessed only by a
single core, so state management is easy
Multi-core support in DPDK
Allows admin to specify the following (hardware/software partnership):
● Allows mapping of specific RX queue to specific CPU core
○ Port 0 - Rx queue 1 → CPU core 6
○ CPU core 6 → Port 1 - Tx queue 2
○ Flexible to create as many queues as admin wants
● Each thread is pinned to a specific core
○ To avoid contention
● Each thread/core runs the same code
NUMA awareness in DPDK
● DPDK creates memory pools for inter-core communication on the
same NUMA socket as the cores involved
● Ring buffers are allocated on the same socket as the NIC and cores
selected for processing
● Remote memory access is minimized
Outline
● Virtual network functions (VNF): revisiting “load balancer” as a
concrete example
● Performance issues in implementing virtual network functions
● Performance-conscious implementation of virtual network functions
● Data Plane Development Kit (DPDK) - an exemplar for user-space
packet processing
● Implementation of VNF on commodity hardware using DPDK
● Putting it together: load balancer example using DPDK
Putting it all together: Load balancer
application
● Multi-threaded load balancer
○ Run-to-completion model
○ Each thread performing identical processing
● Dedicated Rx and Tx queues for each core
Scalable implementation of Load Balancer on
Multi-core CPU using DPDK
Load
Balance
r
Load
Balance
r
RSS Load
Balance
r
Load
Balance
r
If match
Polling for new packet found Send packet
descriptors
to backend
instance
Write output
Advance write
packet
pointer
Kernel space
Closing headshot
In this lecture we saw how to build performance-conscious virtual network
functions. The state-of-the-art is to implement network functions on top of Linux
Kernel. We identified the source of performance bottleneck with this approach for
network function implementation. We discussed the general trend towards
accelerating packet processing via mechanisms to bypass the kernel. We used
Intel’s DPDK as an exemplar to understand how the kernel overhead could be
mitigated. Further, we also saw the optimization opportunities offered by DPDK
for exploiting the inherent multi-core capabilities of modern processors. Due to the
hardware/software partnership offered by technologies such as VT-d and DPDK, it
is now possible to have very performance-conscious user-space implementation
of virtual network functions.
Resources
1. Comparison of Frameworks for High-Performance Packet IO
https://www.net.in.tum.de/publications/papers/gallenmueller_ancs2015.pdf
2. mTCP: A Highly Scalable User-level TCP Stack for Multicore Systems
https://www.usenix.org/node/179774
3. On Kernel-Bypass Networking and Programmable Packet Processing
https://medium.com/@penberg/on-kernel-bypass-networking-and-programmable-packet-processing-799609b06898
4. Introduction to DPDK: Architecture and Principles
https://blog.selectel.com/introduction-dpdk-architecture-principles/
5. DPDK architecture
https://doc.dpdk.org/guides/prog_guide/overview.html
6. A Look at Intel’s Dataplane Development Kit
https://www.net.in.tum.de/fileadmin/TUM/NET/NET-2014-08-1/NET-2014-08-1_15.pdf
7. Linux drivers
https://doc.dpdk.org/guides/linux_gsg/linux_drivers.html
Credits for figures used in this presentation
1. mTCP: A Highly Scalable User-level TCP Stack for Multicore Systems
https://www.usenix.org/node/179774
2. Introduction to DPDK and exploration of acceleration techniques
https://www.slideshare.net/LiorBetzalel/introduction-to-dpdk-and-exploration-of-acceleration-techniques
3. On Kernel-Bypass Networking and Programmable Packet Processing
https://medium.com/@penberg/on-kernel-bypass-networking-and-programmable-packet-processing-799609b06898
4. Dynamic Tracing with DTrace & SystemTap : Network stack
https://myaut.github.io/dtrace-stap-book/kernel/net.html
5. Introduction to DPDK: Architecture and Principles
https://blog.selectel.com/introduction-dpdk-architecture-principles/