Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

WCS Google Cloud Platform instances support TCP Network load balancer.

WebSocket connections will be distributed between active load balancer instances. In case a scaling policy is executed (when the policy target – e.g., CPU load on instance - is reached) and new instances are launched, they will be added to the load balancer.

The following components would be required

  • Disk image to use in instance template
  • Instance template to create new server instances while autoscaling
  • Autoscale instance group
  • Load balancer
  • Server health checks

Let's try to deploy CDN for WebRTC streams including one Origin server and a group of Edge servers (from 1 to 3 instances) with CPU load autoscaling.

Prepare server instances

1. Create one Origin and one Edge server as described here. Reserve a static internal IP address to Origin server.

2. Configure CDN on Origin server side

cdn_enabled                             = true
cdn_ip                                  = <origin_internal_ip>
cdn_role                                = origin
cdn_nodes_resolve_ip                    = false

3. Configure CDN on Edge server side

cdn_enabled                             = true
cdn_ip                                  = <edge_internal_ip>
cdn_point_of_entry                      = <origin_internal_ip>
cdn_role                                = edge
cdn_nodes_resolve_ip                    = false

4. Add the following parameter to Edge server settings

http_enable_root_redirect=false

Create Edge disk image

1. Stop Edge server instance

2. In Google Cloud console, go to "Compute Engine - Images" section and click "Create image". Choose Edge instance disk as disk image source and click "Create"

Create Edge instance template

1. Go to "Compute Engine - Instance templates" section and click "Create instance template". Choose instance VM configuration

2. In "Boot disk" section click "Change"

On "Custom images" tab choose Edge disk image

3. On "Security" tab add the public SSH key if you do not have project SSH keys and click "Create"

Create autoscaling group

1. Go to "Compute Engine - Instance groups" section and click "Create instance group". Choose instance group region and zone, select Edge instance template

2. Choose "Autoscale" mode by "CPU utilization" metric, set metric target value to 80% and set maximum number of instances to 3

3. Enable "Auto healing" and create a health check. Set TCP protocol, port 8081 and request /health-check

Configure health criteria and click "Create" to return to group setup

4. Expand "Advanced creation options" and enable "Do not retry machine creation", then click "Create"

Autoscaling instance gruop will be created, and one instance will be launched

Create load balancer

1. Go to "Network – Load balancers" section and click "Create load balancer". Choose "TCP Load Balancing"

2. Choose external load balancer "From internet to my VMs" and its region

3. In "Backend configuration" section, on "Select existing instance groups" tab select Edge instance group and set session affinity to client IP and protocol

4. Choose "Create health check". Create server health check, set port 8081 and request /

5. In "Frontend configuration" section create TCP port configurations for ports 8081, 8080, 8443, 8444 for HTTP(S) and WS(S). Reserve external static IP address to load balancer

You can add anothe port configurations (1935 for RTMP subscribers, 8082, 8445 for HLS etc depending on Edge use case)

6. Click "Create". Load balancer will start

Load balancer testing

1. Go to Origin web interface and publish test stream in Two Way Streaming example

2. Go to Edge web interface using load balancer IP address. Play test stream in Player example

  • No labels