Chris Pollett > Students >


    [Project Blog]

    [CS 297 Proposal]

    [Adobe Flash Media Server - PPT]

    [Flex and ActionScript - PPT]

    [Del 1-Streams recorded mp3 file]

    [Del 2-Streams output of webcam]

    [Del 3-Bandwidth experiments]

    [Del 4-Load Balancing Server]

    [CS 297 Report - PDF]

    [CS 298 Proposal - PDF]

    [CS 298 Report- PDF]

    [CS 298 Presentation- PPT]

    [Installation guide]


Load Balancing Flash Media Server


Balancing the load among multiple servers is a very important aspect of online video chatting tool. Deliverable 4 focuses on balancing the load among multiple Flash Media Servers.

Load balancing can be achieved through different ways. A typical method is implemented using a caching server which sits between the clients and the servers. All the clients connect to caching servers and caching server will forward the request to the application servers. When the caching server services the request, it will make a copy of the data and store it locally. Next time when the client connects to the caching server, the caching server can provide the data without requesting the application servers.There can be multiple application servers behind the load balancer and load balancer can send the request to the application server in a round robin fashion. There is lots of load balancing software available in the market. One example of load balancing software is squid.

But there is a potential problem with load balancing soft wares. Those are best fit for stateless application services. A typical web server is a stateless application service. Each request to the web server is independent and does not matter which machine services its request each time. So load balancing is very easily achieved through round robin and all the details of the multiple servers servicing the requests can be masked from the client.

Flash Media Server can intelligently direct traffic to a multiple server cluster using server-side scripting. This option is used for multi-way communication applications that require connections to be routed to a specific server. In the video chat application of the Flash Media Player there is one publisher and several subscribers. Publisher publishes the live web cam data to Flash Media Server which then streams the web cam data to connected subscribers. Both the publisher and the subscriber need to connect to the same Adobe Flash Media Server instance.


There will be a master Flash Media Server. Master server stores the details of all the other servers. Publisher client first connect to master server. In the server-side code it first accepts the client connection. It then checks whether the server capacity is exceeded. For example the Flash Media Development Server free edition supports only 10 simultaneous connections at a time. So if the total number of clients in the application exceeds 10, server then creates a new NetConnection object and then connects to the next server. Then the stream name is attached to a NetStream object and published live. This way Flash Media Server balances the load among multiple servers.

//server-side code of master server
var nc;
var ns;
application.onConnect = function(client)
application.acceptConnection(client) ;
application.onPublish = function(client,livestream)
if (application.clients.length>10)
trace("current server fully loaded");
nc = new NetConnection();
nc.connect( "rtmp://" ); //connect to next server
nc.onStatus=function (info){
if (info.code=="NetConnection.Connect.Success") //connection succeeded
ns = new NetStream(nc);
trace( " is up.");
ns.publish(, "live" ); //master publishes the stream to next server
else //master server capacity is not exceeded, so it plays the stream
application.myStream = Stream.get(livestream);
if (application.myStream){, -1);

Master server maintains a list of all Flash Media Servers. Master Server uses NetConnection object to connect to other server. All other servers first check whether their load is full. If their capacity is exceeded, they reject connection from master server. Otherwise they play the stream that is send from master server to the connected clients. If the NetConnection fails, the master server picks next server in the list and try to connect the next server and the so on. If capacity of master server is not exceeded, it plays the stream to the connected client.