xref: /f-stack/doc/F-Stack_Nginx_APP_Guide.md (revision b14f72a4)
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.11.10` directory.
8
9```
10
11                                                    +--------+
12                                                    |
13+------------------------+                          |
14   channel: socketpair                              |  signal(reload, quit..)
15+------------------------+                          |
16                                                    |
17                                          +---------v--------+
18                                          |                  |
19                         +----------------+  master process  +---------------+
20                         |                |                  |               |
21                         |  channel       +----------+-------+               |
22                         |                           |              channel  |
23                         |                  channel  |                       |
24                         |                           |                       |
25               +---------+----------+     +----------+--------+    +---------+--------+
26               |                    |     |                   |    |                  |
27               | ff primary process |     |  worker process   |    |  worker process  |
28               |                    |     |                   |    |                  |
29               +--------------------+     +-------------------+    +------------------+
30                ff_init(primary)          +--------+  +-------+
31                loop:                     |        |  |       |
32                 handle channel event     | fstack |  |channel|
33                                          |  main  |  | event |
34                                          |  loop  |  |thread |
35                                          | thread |  |       |
36                                          |        |  |       |
37                                          +--------+  +-------+
38                                           woker       loop:
39                                          process      handle
40                                           cycle      channel
41                                                       event
42
43```
44
45- spawn an extra process ff primary: ff_init(primary);loop(handle channel event).This process doesn't handle SIGQUIT.
46
47- worker process has 2 threads. main thread: ff_init(secondary);ff_run(worker_process_cycle), channel thread: loop(handle channel event).
48
49Note that:
50- supported nginx signals: reload(HUP)/reopen(USR1)/stop(TERM).
51
52- unsupported nginx signals: NGX_CHANGEBIN_SIGNAL(USR2).
53
54- when use `nginx -s reload`, you should make sure that `woker_processes` in nginx.conf and f-stack.conf haven't be modified.
55
56- necessary modifies in nginx.conf:
57
58```
59    user  root; # root account is necessary.
60    fstack_conf f-stack.conf;  # path of f-stack configuration file, default: $NGX_PREFIX/conf/f-stack.conf.
61	worker_processes  1; # should be equal to the lcore count of `dpdk.lcore_mask` in f-stack.conf.
62
63	events {
64		worker_connections  102400; # increase
65		use kqueue; # use kqueue
66	}
67
68	sendfile off; # sendfile off
69```
70
71## Nginx compiling
72	./configure --prefix=/usr/local/nginx_fstack --with-ff_module
73	make
74	make install
75
76