In one of my previous post, I discussed about the load balancing of stream data using Terracotta. There are many red5 users who do not want this solution because this soulution is too advance for them. They dont have such a huge load on their server that they need this soultion.
For those who just want to keep distributing the incoming requests to any of the available server they have, Lets call it static load balancing, because we know to which server we have to map the request.
We will not use any kind of load balancer like Pound or something else.
Below is simple way to acheive the load balancing of Red5 without using any load balancer.
Round-Robin:-
Suppose we have 4 Red5 servers and we want to distribute the incoming client request to one of these server in Round-robin fashion. So the possible table could be like below-
Request Red5-1 Red5-2 Red5-3 Red5-4
1 Yes No No No
2 No Yes No No
3 No No Yes No
4 No No No Yes
------------------------------------
5 Yes No No No
-----------------------------------
As you can see the fifth request will again map to first red5 server and so on.
This was the simplest solution to distribute the load on Red5 server but it has some limitations.
This approach does not know which server is loaded much or exhausted. it simply passes the incoming request to any of the server based on round-robin.
The other efficient way to load balance red5 could be-
1. Add in your application a function that returns the amount of
rooms/instances/scopes and connected users.
2a. Develop a (php-)script that calls that function on your red5 server(s)
using AMFPHP via cron(job) once every xx minutes.
2b. Calculate the result (e.g. server A has 70 users and server B has 120
users) and store it in a small status-file (or db).
3a. Have your flash-client-application call the (php-)script
3b The script reads the status-file or db.
3c The script returns 'go connect to server A.
4 The flash client connects to server A , thus offloading server B.
The second solution is taken from the discussion in Red5 forum over load balancer.
See Also:-
Red5 clustering of stream data with Terracotta
MRTMP- Red5 load balancing


0 comments:
Post a Comment