HTTP Redirector
HTTP Redirector is a service responsible for uniform and flexible load balancing between multiple streaming servers or their groups. It’s functionality includes the following:
- Defining server groups and load balancing rules within the group and between groups, depending on the location of the client and the requested content.
- Redirecting subscriber requests to working servers if one or more source servers fail
- Monitoring the servers’ performance
- Checking the content availability
Command Line Arguments
–help, -h
Print the help to the console and exit.
–version, -v
Print the version to the console and exit.
–config, -c
Default value: smrdr.json
The path to the configuration file.
–log-config, -l
Default value: smrdr.log.json
The path to the logging configuration file.
–log-file
The logger output file. This option works when no logger configuration is specified.
This option is ignored if –log-config is specified.
Configuration File
The default location of the configuration file is /opt/smartlabs/smartmedia/redirector/config/config.json.
Basic Parameters
core, {object}
A section with the basic settings.
http_threads, integer
Default value: 5
The number of threads to process outgoing HTTP requests when polling servers.
port, integer
Default value: 9000
The port for incoming FastCGI connections.
interface, string
Default value: 0.0.0.0
The interface to listen on for incoming FastCGI connections.
user, string
The name of the user whose rights the httpRedirector process will have. If no parameter value is specified (an empty string), the process is delegated the rights of the user who started it.
group, string
The name of the group whose rights the httpRedirector process will have. If no parameter value is specified (an empty string), the process is delegated the rights of the user group that started it.
redirection, {object}
A section with the traffic redirection settings.
uri_path, string
Default value: /hls
The base URI path to process requests for content transfer over the HLS or DASH protocol.
request_timeout_sec, integer
Default value: 5
The time to wait for the upstream HTTP server response, in seconds.
server_status_cache_time_sec, integer
Default value: 5
The time to cache the availability state of the server (in seconds).
farms, [array{object}]
The list of farms.
name, string
The farm name.
balance_policy, string
Default value: policy_strict_weight
A method of balancing requests between servers within a farm.
For any balancing method, the servers with the requested content are first selected from the farm, and one server is selected among those servers according to the balancing method. The possible parameters are:
- policy_strict_weight (or: sw, bp_sw, strict_weight) — the server with the most weight in the farm is selected;
- policy_flexible_weight (or: fw, bp_fw, flexible_weight) — the server is selected based on its weight: the redirect probability to the farm server with a higher weight is higher, the dependence is linear. For example, a server with a weight of 1 will be redirected to 2 times fewer requests than a server with a weight of 2;
- policy_no_weight (or: nw, bp_nw, no_weight) — the server is selected without taking into account its weight (the probability of a redirect to any server of the farm is the same);
- policy_first_succeed (or: fs, bp_fs, first, first_succeed) — the first responding server in the farm is selected.
request_timeout_sec, integer
The farm-specific request timeout, overrides the base parameter request_timeout_sec.
no_query, boolean
Default value: false
servers, [array{object}]
The list of servers of this farm.
url, string
The base URL for content request.
weight, integer
Default value: 0
The weight of the server within this farm.
no_query, boolean
Default value: false
If set to true, the verify request to the server will not be sent — the server and the content on it are considered always available.
channels, {array of strings}
The list of channel names statically linked to this server.
channels_assignment, boolean
Default value: false
Indicates whether to link channels to servers by name.
channels_assignment_group_size, integer
Default value: 1
Size N of the server group to which the channel is to be assigned by name. Used only if the flag channels_assignment is set. N consecutive servers of a farm are selected as a group. For example, if the start index “2” was calculated by channel name, and N=3, the channel is assigned to servers with indexes 2, 3, 4.
duplicate_without_assignment, boolean
Default value: false
If channels_assignment=true (see above) and duplicate_without_assignment=true, if the content is not found on the linked server, the search will be performed again on all farm servers.
restrict_by_cost, boolean
Default value: false
Indicates that only servers with a minimum delivery cost should be considered for balancing. Does not work for the policy_first_succeed balancing rule.
locations, [array{object}]
The list of possible redirect options.
uri_regex, string
The regular expression to match the requested URI.
request_scheme_regex, string
The regular expression to match the schema of the requested URL.
ip_mask, {array of strings}
Default value: empty array
The list of values “client application IP address/mask”. If the value is “*”, any IP address is accepted.
farms, {array of strings}
The list of farms.
live_cache_time_sec, integer
Default value: 5
Time to cache live requests, in seconds.
clear_cache_interval_sec, integer
Default value: 60
The purge interval for stale cache entries.
channel_regex, string
The regular expression to find the channel name by URI.
channel_regex_index, string
Default value: 0
The number of the regular expression substring that is the channel name.
default_server_cost, integer
Default value: 0
The virtual “cost” of getting content from the server by default. It’s used if the farm has the restrict_by_cost option enabled and the farm server has not returned its delivery cost when the havecontent request has been made.
max_http_request_redirects, integer
Default value: 0
The maximum number of HTTP request redirects. If the value is 0, the number of redirects is not limited.
vod_regex, string
The regular expression used to determine whether the content belongs to VOD.
params_blacklist, array of strings
Default value: [“csi”]
The HTTP GET parameters to be ignored when caching content.
unsupported_servers, array of strings
Default value: []
List of regular expressions. If, when requesting a playlist from a server with the `havecontent` parameter, the request URL matches one of these, Redirector assumes that this server cannot return a percentage of content availability and processes only the HTTP response code.
Server Selection Algorithm for Request Redirection
- Alternately checked all redirection.locations to match uri_regex to the target URI and ip_mask to the client application IP address.
- When a match between uri_regex and ip_mask is found, all farms are polled for content availability (unless otherwise specified in the no_query parameter for the farm/server):
- If servers with the required content are found in the farm, one server is selected based on the balancing rule (the farm parameter balance_policy, and the request is redirected to this server.
- If no servers with the required content are found in the farm, the next farm is polled.
- If the server with the required content is not found in any of the farms, a 404 error is returned.
- If no match is found, a 404 error is returned.