Multi-worker live streaming in master

A few days ago I have merged auto-push branch in master. Several people reported it’s pretty stable. Now it’s possible to do multi-worker live streaming with nginx-rtmp. That can make you achieve really huge traffic. The tests show 2-2.5 Gbps per core. With 16-core CPU it can be as much as 32-35 Gbps.

Auto-push module uses unix domain sockets to pass streams to all workers from the one which has accepted the connection. Every worker has its own unix socket to listen.

The directives to control this feature:

  • rtmp_auto_push on|off – toggle auto-push mode, off by default
  • rtmp_auto_push_reconnect timeout – reconnect timeout after worker got killed, default is 100ms
  • rtmp_socket_dir dir – directory where worker unix domain sockets will be created, default it /tmp. Permissions to create files at that location are needed obviously

All the directives should be placed at the root (top) scope (not rtmp{} or whatever).

Example:

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /var/sock;

rtmp {
    server {
        listen 1935;
        application myapp {
            live on;
        }
    }
}

Statistics url does not return overall statistics for all workers but for a single random worker (which accepted the request). That’s a task for future.

Advertisements
  1. #1 by Mike on October 11, 2012 - 1:41 pm

    Hey rarut.
    Thanks a lot for extremly useful module!!!

    I was trying to minimize the delay (despite bandwitch/cpu usage, that’s not a problem for now) but I couldn’t go lower than 4-5 seconds.

    I and the server have fast connection so it’s transfter speed which limits me(buffer is 0.0s).

    I’m not using ffmpeg on server side, my rtmp settings are default (besides allow/deny).
    For publishing I’m using FMLE with H.264(level 3.1, keyframe freq. 1), framerate 15, dimensions 768*576, bitrate 2K (max)
    For playing i’m using rtmpdump + VLC.

    any tips? 🙂
    Thanks!

    • #2 by rarut on October 11, 2012 - 2:16 pm

      What kind of delay do you mean? Connection delay before actual video appears? If so then it can be about video keyframe interval. Players usually wait until first keyframe comes in before starting playing video.

      • #3 by Mike on October 11, 2012 - 2:18 pm

        Hi! No, actually I ment `how long does it take for viewer to see my broadcast`. I ran VLC to view my stream from the server and counted seconds after some action.

      • #4 by rarut on October 11, 2012 - 2:37 pm

        Player usually buffers data. Yo can set buffer time in player settings.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: