xref: /f-stack/doc/F-Stack_Nginx_APP_Guide.md (revision a1d3d0a7)
1# F-Stack Nginx APP Guide
2
3F-Stack is an open source network framework based on DPDK. F-Stack supports standard Nginx as HTTP framework which means all web application based on HTTP can easily use F-Stack.
4
5## How does Nginx use F-Stack?
6
7  Nginx APP is in `app/nginx-1.16.1` directory.
8
9```
10
11                                                        +--------+
12                         +------------------------+     |
13                            channel: socketpair         |
14                         +------------------------+     |  signal(reload, quit..)
15                                                        |
16                                                        |
17                                              +---------v--------+
18                                              |                  |
19                             +----------------+  master process  +---------------+
20                             |                |                  |               |
21                             |  channel       +----------+-------+               |
22                             |                           |              channel  |
23                             |                  channel  |                       |
24                             |                           |                       |
25                   +---------+----------+     +----------+--------+    +---------+--------+
26first one to start |                    |     |                   |    |                  |
27 last one to exit<-+   primary worker   |     |  secondary worker |    | secondary worker |
28                   |                    |     |                   |    |                  |
29                   +--------------------+     +-------------------+    +------------------+
30                   +--------------------+     +-------------------+
31                   |                    |     |                   |
32                   |   fstack,kernel    |     |   fstack,kernel   |
33                   |     and channel    |     |     and channel   |
34                   |     loop thread    |     |     loop thread   |
35                   |                    |     |			  |
36                   +--------------------+     +-------------------+
37                    woker process cycle        woker process cycle
38
39```
40
41- spawn primary worker firstly, and then wait for primary startup, continue to spawn secondary workers.
42
43- a major addition to the worker process is fstack-handling:ff_init();ff_run(worker_process_cycle); worker_process_cycle(handle channel/host/fstack event).
44
45## What's Different?
46### New directives:
47All the directives below are available only when ```NGX_HAVE_FSTACK``` is defined.
48```
49    Syntax: kernel_network_stack on | off;
50    Default: kernel_network_stack off;
51    Context: http, server
52
53    Determines whether server should run on kernel network stack or fstack.
54```
55
56```
57    Syntax: proxy_kernel_network_stack on | off;
58    Default: kernel_network_stack off;
59    Context: http, stream, mail, server
60
61    Determines whether proxy should go through kernel network stack or fstack.
62```
63
64```
65    Syntax: schedule_timeout time;
66    Default: schedule_timeout 30ms;
67    Context: main
68
69    Sets a time interval for polling kernel_network_stack. The default value is 30 msec.
70```
71
72### Command-line `reload`
73the `reload` is not graceful, service will still be unavailable during the process of reloading.
74
75### Necessary modifies in nginx.conf:
76```
77    user  root; # root account is necessary.
78    fstack_conf f-stack.conf;  # path of f-stack configuration file, default: $NGX_PREFIX/conf/f-stack.conf.
79    worker_processes  1; # should be equal to the lcore count of `dpdk.lcore_mask` in f-stack.conf.
80
81    events {
82        worker_connections  102400; # increase
83        use kqueue; # use kqueue
84    }
85
86    sendfile off; # sendfile off
87```
88
89## Nginx compiling
90	./configure --prefix=/usr/local/nginx_fstack --with-ff_module
91	make
92	make install
93
94