Skip to main content
Version: 4.0 (Archived) 📦

Reuse Port

The performance of SRS2 is improved huge, but is it enough? Absolutely NOT! In SRS3, we provide OriginCluster for multiple origin servers to work together, and go-oryx as a tcp proxy for edge server, and these are not good enough, so we support SO_REUSEPORT feature for multiple processes edge server.

Remark: The SO_REUSEPORT requires Linux Kernel 3.9+, so you should upgrade your kernel for CentOS6, or you could choose Ubuntu20.

First, we start a edge server which listen at 1935:

./objs/srs -c conf/edge.conf

Then, at the same server, start another edge server which also listen at 1935:

./objs/srs -c conf/edge2.conf

Note: They should use different pid file, or it will fail to start the second edge server.

There are two SRS edge servers:

[root@bf2e88b31f9b trunk]# ps aux|grep srs
root       381  0.1  0.0  19888  5752 pts/2    S+   08:03   0:01 ./objs/srs -c conf/edge.conf
root       383  0.0  0.0  19204  5468 pts/1    S+   08:04   0:00 ./objs/srs -c conf/edge2.conf

[root@bf2e88b31f9b trunk]# lsof -p 381
srs     381 root    7u     IPv6  18835      0t0        TCP *:macromedia-fcs (LISTEN)
[root@bf2e88b31f9b trunk]# lsof -p 383
srs     383 root    7u     IPv6  17831      0t0        TCP *:macromedia-fcs (LISTEN)

After that, we start the origin server, from which these edge server to pull streams:

./objs/srs -c conf/origin.conf 

Finally, we could publish to origin/edge, and play stream from each edge server:

    for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \
        -c copy \
        -f flv rtmp://; \
        sleep 1; \

Use VLC to play the RTMP stream: rtmp://