Conference(Room API) function as ASG

sangsoo

Member
Hello.
I want to configure Conference(Room API) in amazon ASG environment.

Test order.
1. Configure ASG with a.b.com (CNAME).
2. Run 5 WCS servers (EC2 Instance) on a.b.com (CNAME).
3. "Bill" joins a.b.com. An Invite link containing a.b.com will be created (*)
4. "'Steve" joins the Invite link. Two cases occur here.
=> Success, when "Steve" connects to the EC2 instance connected by "Bill"
=> Failure, when "Steve" connects to the other 4 EC2 instances that "Bill" has not connected

How can "Steve" get the WCS server address of the Ec2 Instance joined by "Bill" first?

Thank you.
 

Max

Administrator
Staff member
Good day.
Unfortunately, there's no perfect way to bypass load balancer or autoscaling group entry point. We cannot predict what server will be chosen when connecting to the enry point by CNAME.
You can get WCS IP address where room is created, by /connect REST hook handling, but:
1. To handle REST hooks using RoomApi, you should proxy all the requests and all the responses to the standard RoomApp backend application, or RoomApi will not work:
PHP:
$body = file_get_contents('php://input');
$incoming_data = json_decode($body, true);

switch($api_method) {
    case"connect":
        // Save sessionId
        saveSessionId($incoming_data['sessionId']);
        // POST /connect query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
    default:
        // POST any query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
}
header('HTTP/1.1 200 OK', true, 200);
header('Content-Type: application/json');
echo json_encode($response_data);

// Passing query to WCS default RoomApp
function postToRoomApp($method, $data_string) {
    // Here should be your WSC RoomApp address
    $wcs_url="http://wcs:8081/apps/RoomApp/" . $method;

    $response="";
    if( $curl = curl_init() ) {
        curl_setopt($curl, CURLOPT_URL, $wcs_url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json',                                                                           
                               'Content-Length: ' . strlen($data_string)));  
        $response = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if($http_code != 200) {
            ubnormalResponse($http_code);
        }
        error_log($response);
        curl_close($curl);
    }
    return($response);
}

function ubnormalResponse($code) {
    if ($code == 403) {
    header('HTTP/1.1 403 Forbidden', true, $code);
    } else {
    header(':', true, $code);
    }
    die();
}
You should get WCS IP to pass request from sessionId in this case, too:
Code:
///             client IP and port  WCS IP and port
"sessionId" : "/192.168.1.83:61936/192.168.1.39:8443-7a076e23-186e-4069-ac29-b6b379fe8d8d",
2. WCS IP in sessionId is private IP, so you need to know its external IP, and the server must be available from outside directly for client to connect.
3. You should pass WCS external IP from backend to client by some way, to correct invitation link.
So we do not recommend to use RoomApi in ASG environment.
 

sangsoo

Member
Thank you for your reply.
As you said, using the Conference-Room API in an Amazon ASG environment seems inappropriate.

I want to fix it before it slows down the server or causes errors.
So I'm still looking for a way to scale WCS automatically or with minimal work when usage increases.

Now is,
1. Set up each public domain in every WCS,
- https://docs.flashphoner.com/display/WCS52EN/Server+domain+name+support+as+external+address
2. Monitor "Stats of WCS" to determine (distribute) the server to use,
- https://docs.flashphoner.com/displa...tistics+and+CDN+events+collection+to+MySQL+DB
3. If necessary, it seems possible to manage the server list by manually adding or removing WCS.

Is there a better way?
What server configuration can you suggest?
Please comment.
 

Max

Administrator
Staff member
2. Monitor "Stats of WCS" to determine (distribute) the server to use,
- https://docs.flashphoner.com/displa...tistics+and+CDN+events+collection+to+MySQL+DB
This statistics is not enough. It allows to collect stream publishing/playback and CDN state events only. The server load statistics is avalable only at this page.
You can also collect server statistics using Prometheus. Please read this article about server resources monitoring with Prometheus and Grafana, and this article about network load monitoring (and some useful files at the end)
If your goal is to scale RoomApi conference, you should control server CPU load, memory and network load. If there are some rooms on the server, and some of those metrics crosses high watermark, other new conference rooms should be redirected to another WCS instance.
So to set up a public server domain name for each WCS, to maintain a server list and to collect load data to Prometheus and control thresholds seems like suitable solution in this case.
 

sangsoo

Member
Thank you for your reply.
I will study the linked blog article content.
A detailed explanation is always very helpful to me.

Thank you.
 
Top