Nginx is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It was originally created as a web server for delivering websites and has evolved into a multifaceted solution for proxying content. Today it’s the most widely deployed web server. Eventually, NGINX added RTMP support to address scalability problems with… Continue reading Top 3 Reasons Nginx RTMP Falls Short
Nginx is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It was originally created as a web server for delivering websites and has evolved into a multifaceted solution for proxying content. Today it’s the most widely deployed web server. Eventually, NGINX added RTMP support to address scalability problems with plain RTMP streaming. That provided good performance and stability for live streaming over less scalable solutions like Flash Media Server and Wowza.
RTMP (Real-Time Messaging Protocol) is an application-level protocol owned by Adobe. It was originally designed for delivering on-demand media and live media (i.e live audio, video, and data) over the Internet between a Flash player and RTMP Media Server.
While Nginx and RTMP were reliable in the past, they face three major shortcomings that make them less practical for modern video streaming.
RTMP Does Not Work in the Browser
RTMP does not have HTML5 support which means that it will not run on an internet browser. The Flash player is being phased out as well so that is not a sustainable option. Unsurprisingly, many viewers will use internet browsers to watch video. No browser support means that it is harder for your viewers to watch your stream.
The only way to get RTMP to play in the browser is to stream it over HTTP which will negatively affect performance. So when it comes to RTMP streaming, that leaves you with two bad options: no one watching the stream, or watching a stream with poor quality and performance.
Of course, you can certainly build a native app for playing video through RTMP on iOS and Android. However, this is not a great solution as there are still limitations with the RTMP protocol itself.
TCP Creates High Latency
RTMP is a TCP based protocol. TCP (Transmission Control Protocol) is a transport layer protocol used for sending bits of data—known as packets—over the Internet. It is a connection-oriented protocol with built-in error recovery and retransmission. This means that back-and-forth communication is required to reorder packets and ensure their complete delivery. This constant exchange of messages introduces latency in many networking scenarios.
As we have covered before, latency is a problem for creating effective live streaming applications. Any sort of a delay between when the broadcaster captures the video and the subscriber views that video, creates unnatural gaps that negatively affect communication and the exchange of information.
UDP is a much better protocol for video streaming, and it’s one of the fundamental reasons that WebRTC is a superior protocol over RTMP.
Issues with Firewalls and Encryption
Most RTMP content is sent via the non-standard port 1935 rather than the standard HTTP port 80 making it vulnerable to getting blocked by (corporate) firewalls. This issue can be prevented by streaming in RTMPT (tunneling over HTTP), which comes at a server and client performance cost.
Basically, if you use RTMPT you are pulling the data over HTTP in small chunks. If you are already using this approach, you might as well use HLS which is supported in browsers. We’ve already discussed the many limitations of HLS and other related protocols so we won’t go into that here.
The Solution – WebRTC and Red5 Pro
Red5 Pro’s WebRTC solution solves all these issues. WebRTC enjoys native browser support for plugin-free support of all major browsers. WebRTC uses UDP for faster stream delivery and it uses STUN/TURN for tunneling through firewalls without affecting performance.