Skip to content

Instantly share code, notes, and snippets.

@tuan3w
Last active February 13, 2019 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tuan3w/3230988b23f13cd30ce59f7a91321c44 to your computer and use it in GitHub Desktop.
Save tuan3w/3230988b23f13cd30ce59f7a91321c44 to your computer and use it in GitHub Desktop.
Experiment with nginx-http-flv-module
worker_processes auto; #should be 1 for Windows, for it doesn't support Unix domain socket
worker_rlimit_nofile 100000;
error_log logs/error.log error;
#if the module is compiled as a dynamic module and features relevant
#to RTMP are needed, the command below MUST be specified and MUST be
#located before events directive, otherwise the module won't be loaded
#or will be loaded unsuccessfully when NGINX is started
#load_module modules/ngx_rtmp_module.so;
events {
worker_connections 10240;
accept_mutex off;
use epoll;
}
#thread_pool default threads=6 max_queue=65536;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
sendfile_max_chunk 512k;
#aio threads=default;
#aio threads=default;
#tcp_nopush on;
# don't buffer data sent, good for small data bursts in real time
#tcp_nodelay on;
keepalive_timeout 65;
server {
listen 8080 reuseport;
location / {
root /var/www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /live {
flv_live on; #open flv live streaming (subscribe)
#aio on;
chunked_transfer_encoding on; #open 'Transfer-Encoding: chunked' response
add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header
add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header
}
location /stat {
#configuration of push & pull status
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /var/www/rtmp; #specify in where stat.xsl located
}
location /hls {
# Serve HLS fragments
# Disable cache
#add_header Cache-Control no-cache;
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /var/www;
add_header Cache-Control no-cache;
}
}
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /var/www/sockets;
rtmp {
out_queue 4096;
out_cork 8;
max_streams 64;
server {
listen 1935;
application myapp {
live on;
gop_cache on; #open GOP cache for low latency
}
}
}
version: "3"
services:
benchmark:
image: williamyeh/wrk
command: "-d 5m -t10 -c500 \"http://SERVER_ADDR:8080/live?app=myapp&stream=test\""
deploy:
mode: global
@tuan3w
Copy link
Author

tuan3w commented May 4, 2018

Build and install

# ./configure  --add-module=../nginx-http-flv-module --with-http_ssl_module
# make -j 4 
# make install
# cp nginx.conf /usr/local/nginx/conf

stress server

# export HOST=
# docker run --rm williamyeh/wrk -d 5m -t10 -c1000 "http://$HOST:8080/live?app=myapp&stream=test" > /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment