How to load balance RTSP protocol based services

How to load balance RTSP protocol based services

What is RTSP protocol? #

RTSP, or the Real-Time Streaming Protocol, is a network communication protocol primarily designed for controlling and delivering streaming media, such as audio and video content, over the internet. It functions as a framework for client-server communication, enabling clients to request and control the real-time transmission of media data from servers. RTSP is often used in conjunction with other streaming protocols, like RTP (Real-Time Transport Protocol), to deliver multimedia content efficiently.

To use RTSP, a client initiates a session by sending requests to a media server. These requests can include actions like play, pause, stop, and record, allowing users to interact with the streaming media. RTSP provides a flexible means of accessing and controlling multimedia content, making it a vital component of applications like video conferencing, IP surveillance systems, and online streaming services. It’s important to note that while RTSP manages the control aspect of streaming, the actual data transmission may be handled by a separate protocol like RTP, which works in tandem with RTSP to ensure seamless media delivery.

Which industries use RTSP? #

RTSP (Real-Time Streaming Protocol) is used in various industries and applications that involve real-time media streaming and control. Some of the industries and sectors that commonly use RTSP include:

Entertainment and Media: Online streaming services, video-on-demand platforms, and live broadcasting use RTSP to deliver audio and video content to users.

Video Conferencing and Telecommunications: Many video conferencing systems and telecommunication applications utilize RTSP to enable real-time video and audio communication between participants.

Security and Surveillance: IP-based security cameras and surveillance systems often employ RTSP to transmit live video feeds, enabling remote monitoring and control.

Gaming: Online gaming platforms may use RTSP for streaming in-game content, such as live gameplay or interactive experiences.

Education: E-learning platforms and virtual classrooms use RTSP to deliver live or pre-recorded educational content, facilitating remote learning.

Healthcare: Telemedicine and remote healthcare applications can use RTSP for real-time video consultations and medical imaging sharing.

Industrial and Manufacturing: Remote monitoring and control of industrial processes may utilize RTSP for video feeds and data sharing to enhance operational efficiency.

Aerospace and Defense: RTSP can be employed in defense applications for real-time video feeds from unmanned aerial vehicles (UAVs) and surveillance systems.

Retail and Marketing: Some retail businesses use RTSP for live product demonstrations, video advertising, and interactive customer engagement.

Transportation: Public transportation systems, such as subway stations and airports, may use RTSP for live video feeds for security and passenger information.

RTSP Protocol internals #

Let’s analyze the internals of RTSP protocol while used behind a load balancer.

1. The client initiates a TCP-based RTSP connection to the VIP on inbound the load balancer side, usually served in the port 554.

2. The client and backend exchange OPTIONS, SETUP, and DESCRIBE header messages to agree on the RTP and RTCP delivery mechanisms among other parameters.

3. The client send a PLAY packet to command the virtual service to commence the delivery of the UDP-based RTP and RTCP frames containing the data and control, respectively.

4. Then, the backend initiates the UDP (or TCP) based RTP delivery, the load balancer could have understanding of such traffic (if dNAT is being used) or not (if DSR is used).

How to load balance RTSP? #

Load balancing RTSP (Real-Time Streaming Protocol) can be challenging due to the stateful nature of RTSP connections. RTSP connections often consist of multiple interleaved streams and maintain session state, making it necessary to use specialized load balancing techniques. Usually, once the RTSP session is established, the server negotiates four dynamic UDP ports with the client (two for audio and other two for video).

Here are steps you can follow to load balance RTSP effectively:

Protocol awareness load balancing #

Deploy a Load Balancer, such as RELIANOID, which is aware of protocol-based communications. In the case of RELIANOID, it is capable to understand and manage TCP, UDP or both at the same time over the same virtual service.

Low-latency load balancing methods #

Layer 4 load balancing with transparent and low-latency load balancing methods like Direct Server Return (DSR) or DNAT / stateless DNAT are the most suitable for RTSP load balancing.

Session persistence #

As RTSP is a stateful protocol, it is required to maintain session persistence between clients and backends. Persistence by source IP it would be required to be configured in the L4 virtual service.

Health Checks #

Preloaded health check check_real is able to perform dummy RTSP connections to the backends to know its availability.

root@nois-ee-01:~# /usr/local/relianoid/app/libexec/check_real --help
[...]

This plugin tests the REAL service on the specified host.


Usage:
check_real -H host [-e expect] [-p port] [-w warn] [-c crit] [-t timeout] [-v]

Options:
 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 --extra-opts=[section][@file]
    Read options from an ini file. See
    https://www.monitoring-plugins.org/doc/extra-opts.html
    for usage and examples.
 -H, --hostname=ADDRESS
    Host name, IP Address, or unix socket (must be an absolute path)
 -p, --port=INTEGER
    Port number (default: 554)
 -u, --url=STRING
    Connect to this url
 -e, --expect=STRING
String to expect in first line of server response (default: RTSP/1.)
 -w, --warning=DOUBLE
    Response time to result in warning status (seconds)
 -c, --critical=DOUBLE
    Response time to result in critical status (seconds)
 -t, --timeout=INTEGER
    Seconds before connection times out (default: 10)
 -v, --verbose
    Show details for command-line debugging (output may be truncated by
    the monitoring system)

This plugin will attempt to open an RTSP connection with the host.
Successul connects return STATE_OK, refusals and timeouts return
STATE_CRITICAL, other errors return STATE_UNKNOWN.  Successful connects,
but incorrect response messages from the host result in STATE_WARNING return
values.

[...]

RTSP virtual service high availability #

With a stateful cluster, like it is included in RELIANOID Load Balancer, the RTSP virtual service would be protected against a single point of failure as this allows to setup two different nodes that interoperates between them to provide a full reliable RTSP service.

RTSP virtual service Security #

Load Balancers, like RELIANOID, usually are able to apply some security rules to the virtual services. In regards to RELIANOID, the IPDS module allows to include DoS protections, real-time blacklists (RBL) and preloaded and customized blacklists for RTSP load balancing services.

SHARE ON: #

Powered by BetterDocs