Multiple Edge servers behind AWS LB not communicating

Hi,

I am following CDN pattern https://docs.flashphoner.com/display/WCS52EN/CDN+2.0 where I have set of Origin servers behind a AWS LB and another set of edge servers behing another LB.

Instances with WCS is added to load balancer using Autoscaling. When more than one edge server is added to a load balancer, I can't able to play HLS stream using the edge endpoint. But if there is only one Instance in Edge endpoint, sream is playing.

Why the edge servers are not getting communicated within each other?
Is there any configuration to be done where CDN edge servers to communicate?
 

Max

Administrator
Staff member
Hello

HLS http port is 8082
HLS https port is 8445


So if you setup load balancing for HLS, your load balancer should serve requests like

and so on

If user sends HTTP request https://mylb:8445/stream/stream.m3u8 and this request is forwarded to edge1, then subsequent request from this user must be forwarded to edge1 too. If subsequent request was forwarded to edge2, it won't work.

Working scheme

User1 https://mylb.com:8445/stream/stream.m3u8 >> edge1
User1 https://mylb.com:8445/stream/stream1.ts >> edge1

User2 https://mylb.com:8445/stream/stream.m3u8 >> edge2
User2 https://mylb.com:8445/stream/stream1.ts >> edge2

Wrong scheme (User2 will not be served)

User1 https://mylb.com:8445/stream/stream.m3u8 >> edge1
User1 https://mylb.com:8445/stream/stream1.ts >> edge1
User2 https://mylb.com:8445/stream/stream.m3u8 >> edge2
User2 https://mylb.com:8445/stream/stream2.ts >> edge1

So if you setup load balancing, the loadbalancer must stick users to CDN edges. If first request was placed to Edge1, subsequent requests from this User must be placed to Edge1 too.
 
Thank you Max. Let me check.

Also, is there any calculated metrices (stream publish count) available based on server capacity? I mean stream publishing count based on server capacity.
For ex, if I have a server with 2vCPU and 2 GB RAM, how many streams can be published in that server?

I tested with load tool https://docs.flashphoner.com/display/WCS52EN/Load+testing and around 100 stream publish, it supported.
But I want to know it will always be 100 or CPU utilization will increase based on any other circumstances (like encoding, large time stream etc)?
 
Thanks Max.
Final Question: How does the billing is calculated?
On checking with this link https://docs.flashphoner.com/display/WCS52EN/Billing, even if the server runs for 10 minutes will that also included as a full monthly billing.
Since I am using Autoscaling, new instance will get launched and get terminated in 10 - 15m based on the load. So for those 10m, will the billing calculated as whole month billing or it is hour based?
 
Last edited:

Max

Administrator
Staff member
Final Question: How does the billing is calculated?
Now, AWS instances are billed by Amazon AWS Marketplace on hourly basis. There is a special license shipped with AMI, which even does not need to be activated.
So you don't have to pay for full month if server is online just 15 minutes.

AWS Marketplace Images
 
Last edited:
Great. FYI, that link goes to 404.
If I use custom AMI with WCS server, does this same billing apply for the instances or it applies only if we use AWS marketplace special AMI.
 
Hello

HLS http port is 8082
HLS https port is 8445


So if you setup load balancing for HLS, your load balancer should serve requests like

and so on

If user sends HTTP request https://mylb:8445/stream/stream.m3u8 and this request is forwarded to edge1, then subsequent request from this user must be forwarded to edge1 too. If subsequent request was forwarded to edge2, it won't work.

Working scheme

User1 https://mylb.com:8445/stream/stream.m3u8 >> edge1
User1 https://mylb.com:8445/stream/stream1.ts >> edge1

User2 https://mylb.com:8445/stream/stream.m3u8 >> edge2
User2 https://mylb.com:8445/stream/stream1.ts >> edge2

Wrong scheme (User2 will not be served)

User1 https://mylb.com:8445/stream/stream.m3u8 >> edge1
User1 https://mylb.com:8445/stream/stream1.ts >> edge1
User2 https://mylb.com:8445/stream/stream.m3u8 >> edge2
User2 https://mylb.com:8445/stream/stream2.ts >> edge1

So if you setup load balancing, the loadbalancer must stick users to CDN edges. If first request was placed to Edge1, subsequent requests from this User must be placed to Edge1 too.
@Max this issue is happening again. After enabling stickiness in load balancer, it worked for few weeks. But all of a sudden now, it is not working.
Is there any configuration change happened?
 
Thank you. I have already added what you said but still CORS issue happens where there are mutiple edge servers behind load balancer.
 

Max

Administrator
Staff member
You should add ACAO header including port to which request is coming:
Code:
hls_access_control_headers=Access-Control-Allow-Origin: http://localhost:8081;Access-Control-Allow-Methods: GET, HEAD;Access-Control-Max-Age: 3000;Access-Control-Expose-Headers: Accept-Ranges, Content-Range, Content-Encoding, Content-Length;Access-Control-Allow-Credentials: true
Also, you should add withCredentials: true parameter to HLS player initialization code
Code:
function initPage() {
...
player.src({
    src: src,
    type: "application/vnd.apple.mpegurl",
    withCredentials: true
});
player.play();
};
...
}
This allows player to send cookie received from load balancer
 
Top