xref: /f-stack/README.md (revision 9ece0b02)
1[![Build Status](https://travis-ci.org/F-Stack/f-stack.svg?branch=master)](https://travis-ci.org/F-Stack/f-stack)
2
3# F-Stack
4![](F-Stack.png)
5
6## Introduction
7
8With the rapid development of Network Interface Cards the poor performance of data packet processing with the Linux kernel has become the bottleneck in modern network systems. Yet, the increasing demands of the Internet's growth demand a higher performant network processing solution. Kernel bypass has emerged to catch more and more attention. There are various similar technologies such as: DPDK, NETMAP and PF_RING. The main idea of kernel bypass is that Linux is only used to deal with control flow; all data streams are processed in user space. Therefore, kernel bypass can avoid performance bottlenecks caused by kernel packet copying, thread scheduling, system calls, and interrupts. Furthermore, kernel bypass can achieve higher performance with multi-optimizing methods. Within various techniques, DPDK has been widely used because of it's more thorough isolation from kernel scheduling and active community support.
9
10[F-Stack](http://www.f-stack.org/?from=github) is an open source high performant network framework based on DPDK with the following characteristics:
11
121. Ultra high network performance which the network card can achieve under full load: 10 million concurrent connections, 5 million RPS, 1 million CPS.
132. Transplant FreeBSD 11.01 user space stack, which provides a complete stack function, and cut a great amount of irrelevant features. This greatly enhances network performance.
143. Support Nginx, Redis, and other mature applications. Services can easily use F-Stack.
154. Easy to extend with multi-process architecture.
165. Provides micro thread interface. Various applications with stateful applications can easily use F-Stack to get high performance without processing complex asynchronous logic.
176. Provide an Epoll/Kqueue interface that allow many kinds of applications to easily use F-Stack.
18
19## History
20
21To deal with the increasingly severe DDoS attacks the authorized DNS server of Tencent Cloud DNSPod switched from Gigabit Ethernet to 10-Gigabit at the end of 2012. We faced several options: one is to continue to use the original network stack in the Linux kernel, another is to use kernel bypass techniques. After several rounds of investigation; we finally chose to develop our next generation of DNS server based on DPDK. The reason is DPDK provides ultra-high performance and can be seamlessly extended to 40G, or even 100G NIC, in the future.
22
23After several months of development and testing, DKDNS, high-performance DNS server based on DPDK officially released in October 2013. It's capable of achieving up to 11 million QPS with a single 10GE port and 18.2 million QPS with two 10GE ports. And then we developed a user-space TCP/IP stack called F-Stack that can process 0.6 million RPS with a single 10GE port.
24
25With the fast growth of Tencent Cloud, more and more services need higher network access performance. Meanwhile, F-Stack was continuous improving driven by the business growth, and ultimately developed into a general network access framework. But this TCP/IP stack couldn't meet the needs of these services while continue to develop and maintain a complete network stack will cost high, we've tried several plans and finally determined to port FreeBSD(11.0 stable) TCP/IP stack into F-Stack. Thus, we can reduce the cost of maintenance and follow up the improvement from community quickly.Thanks to [libplebnet](https://gitorious.org/freebsd/kmm-sandbox/commit/fa8a11970bc0ed092692736f175925766bebf6af?p=freebsd:kmm-sandbox.git;a=tree;f=lib/libplebnet;h=ae446dba0b4f8593b69b339ea667e12d5b709cfb;hb=refs/heads/work/svn_trunk_libplebnet) and [libuinet](https://github.com/pkelsey/libuinet), this work becomes a lot easier.
26
27With the rapid development of all kinds of application, in order to help different APPs quick and easily use F-Stack, F-Stack has integrated Nginx, Redis and other commonly used APPs, and a micro thread framework, and provides a standard Epoll/Kqueue interface.
28
29Currently, besides authorized DNS server of DNSPod, there are various products in Tencent Cloud has used the F-Stack, such as HttpDNS (D+), COS access module, CDN access module, etc..
30
31## Quick Start
32
33    #clone F-Stack
34    mkdir /data/f-stack
35    git clone https://github.com/F-Stack/f-stack.git /data/f-stack
36
37    cd f-stack
38    # compile DPDK
39    cd dpdk/tools
40    ./dpdk-setup.sh # compile with x86_64-native-linuxapp-gcc
41
42    # Set hugepage
43    # single-node system
44    echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
45
46    # or NUMA
47    echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
48    echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
49
50    # Using Hugepage with the DPDK
51    mkdir /mnt/huge
52    mount -t hugetlbfs nodev /mnt/huge
53
54    # close ASLR; it is necessary in multiple process
55    echo 0 > /proc/sys/kernel/randomize_va_space
56
57    # offload NIC
58    modprobe uio
59    insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
60    insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
61    python dpdk-devbind.py --status
62    ifconfig eth0 down
63    python dpdk-devbind.py --bind=igb_uio eth0 # assuming that use 10GE NIC and eth0
64
65    # On Ubuntu, use gawk instead of the default mawk.
66    #sudo apt-get install gawk  # or execute `sudo update-alternatives --config awk` to choose gawk.
67
68    # Compile F-Stack
69    export FF_PATH=/data/f-stack
70    export FF_DPDK=/data/f-stack/dpdk/x86_64-native-linuxapp-gcc
71    cd ../../lib/
72    make
73
74#### Nginx
75
76    cd app/nginx-1.11.10
77    bash ./configure --prefix=/usr/local/nginx_fstack --with-ff_module
78    make
79    make install
80    cd ../..
81    /usr/local/nginx_fstack/sbin/nginx
82
83for more details, see [nginx guide](https://github.com/F-Stack/f-stack/blob/master/doc/F-Stack_Nginx_APP_Guide.md).
84
85#### Redis
86
87    cd app/redis-3.2.8/
88    make
89    make install
90
91  If KNI is enabled in the configuration file, you should create a virtual NIC after F-Stack started, and set the ipaddr, netmask, mac addr, route table, etc. These addrs must be same with F-Stack.
92
93  If you don't have another management port, you should execute a script like this.
94
95    /usr/local/nginx_fstack/sbin/nginx
96    sleep 10
97    ifconfig veth0 <ipaddr>  netmask <netmask>  broadcast <broadcast> hw ether <mac addr>
98    route add -net 0.0.0.0 gw <gateway> dev veth0
99    # route add -net ...  # other route rules
100
101## Nginx Testing Result
102
103Test environment
104
105    NIC:Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+
106    CPU:Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz(NUMA)
107    Memory:128G
108    OS:CentOS Linux release 7.2 (Final)
109    Kernel:3.10.104-1-tlinux2-0041.tl2
110
111Nginx uses linux kernel's default config, all soft interrupts are working in the first CPU core.
112
113Nginx si means modify the smp_affinity of every IRQ, so that the decision to service an interrupt with a particular CPU is made at the hardware level, with no intervention from the kernel.
114
115Nginx_FStack's 600 cache bytes' body was returned directly in nginx.conf.
116
117All of these test cases use CPUs' physical cores.
118
119
120CPS (Connection:close, Small data packet)  test result
121![](http://i.imgur.com/PvCRmXR.png)
122
123RPS (Connection:Keep-Alive, Small data packet) test data
124![](http://i.imgur.com/CTDPx3a.png)
125
126Bandwidth (Connection:Keep-Alive, 3.7k bytes data packet) test data
127![](http://i.imgur.com/1ZM6yT9.png)
128
129## Licenses
130See [LICENSE](LICENSE)
131
132## Join us
133
134Tencent Cloud F-Stack team developed F-Stack which is a general network framework based on DPDK and provides ultra high network performance. We are here looking for more and more talented people with great passion on technology to join us. You would have the chance to work with brightest minds on this planet and help Tencent cloud and F-stack continuously evolve. Send us your resume or refer your friend to us if you are interested in joining us.
135
136Open Positions: Software engineer(C/C++), Web developer, IOS/Android developer, Product Manager, Operating Manager, etc.
137Contact: Please send your resume to [us](mailto:[email protected])
138