xref: /f-stack/doc/F-Stack_Nginx_APP_Guide.md (revision 68458806)
1a9643ea8Slogwang# F-Stack Nginx APP Guide
2a9643ea8Slogwang
3a9643ea8SlogwangF-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.
4a9643ea8Slogwang
5a9643ea8Slogwang## How does Nginx use F-Stack?
6a9643ea8Slogwang
7a9643ea8Slogwang  Nginx APP is in `app/nginx-1.11.10` directory.
8a9643ea8Slogwang
940600211Slogwang```
10a9643ea8Slogwang
1140600211Slogwang                                                        +--------+
1263fb3d1fSlogwang                         +------------------------+     |
1363fb3d1fSlogwang                            channel: socketpair         |
1463fb3d1fSlogwang                         +------------------------+     |  signal(reload, quit..)
1540600211Slogwang                                                        |
1640600211Slogwang                                                        |
1740600211Slogwang                                              +---------v--------+
1840600211Slogwang                                              |                  |
1940600211Slogwang                             +----------------+  master process  +---------------+
2040600211Slogwang                             |                |                  |               |
2140600211Slogwang                             |  channel       +----------+-------+               |
2240600211Slogwang                             |                           |              channel  |
2340600211Slogwang                             |                  channel  |                       |
2440600211Slogwang                             |                           |                       |
2540600211Slogwang                   +---------+----------+     +----------+--------+    +---------+--------+
2663fb3d1fSlogwangfirst one to start |                    |     |                   |    |                  |
2763fb3d1fSlogwang last one to exit<-+   primary worker   |     |  secondary worker |    | secondary worker |
2840600211Slogwang                   |                    |     |                   |    |                  |
2940600211Slogwang                   +--------------------+     +-------------------+    +------------------+
30*68458806S陈威                   +--------------------+     +-------------------+
31*68458806S陈威                   |                    |     |                   |
32*68458806S陈威                   |   fstack,kernel    |     |   fstack,kernel   |
33*68458806S陈威                   |     and channel    |     |     and channel   |
34*68458806S陈威                   |     loop thread    |     |     loop thread   |
35*68458806S陈威                   |                    |     |			  |
36*68458806S陈威                   +--------------------+     +-------------------+
37*68458806S陈威                    woker process cycle        woker process cycle
38a9643ea8Slogwang
3940600211Slogwang```
40a9643ea8Slogwang
4163fb3d1fSlogwang- spawn primary worker firstly, and then wait for primary startup, continue to spawn secondary workers.
42b14f72a4Slogwang
43*68458806S陈威- 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).
44a9643ea8Slogwang
4540600211SlogwangNote that:
466d206da2Slogwang
4763fb3d1fSlogwang- the `reload` is not graceful, service will still be unavailable during the process of reloading.
48a9643ea8Slogwang
4940600211Slogwang- necessary modifies in nginx.conf:
50a9643ea8Slogwang
5140600211Slogwang```
5240600211Slogwang    user  root; # root account is necessary.
5340600211Slogwang    fstack_conf f-stack.conf;  # path of f-stack configuration file, default: $NGX_PREFIX/conf/f-stack.conf.
5440600211Slogwang    worker_processes  1; # should be equal to the lcore count of `dpdk.lcore_mask` in f-stack.conf.
55a9643ea8Slogwang
56a9643ea8Slogwang    events {
5740600211Slogwang        worker_connections  102400; # increase
58a9643ea8Slogwang        use kqueue; # use kqueue
59a9643ea8Slogwang    }
60a9643ea8Slogwang
61a9643ea8Slogwang    sendfile off; # sendfile off
6240600211Slogwang```
63a9643ea8Slogwang
6440600211Slogwang## Nginx compiling
6540600211Slogwang	./configure --prefix=/usr/local/nginx_fstack --with-ff_module
6640600211Slogwang	make
6740600211Slogwang	make install
68a9643ea8Slogwang
69