Skip to content

Load Testing Flash Media Server

by Jason on July 7th, 2008

Often times when speaking with clients they will complain that “something” is wrong with their FMS server(s), but rarely do they know what. And you can’t blame them, a large FMS deployment could consist of dozens of servers and server clusters pumping out and sucking in all kinds of different streams, the notion of a staging environment is not common in this senario simply because it seems impossible to test modifications using real-world test data.

What is often missing is a means simulate a real-world video load. A good way to start testing your streaming servers is to create a simple application in Flash or Flex that creates N NetConnection’s and N NetStream’s and have each ns/ns pair connect and pull a video from your FMS system. To do this, you’ll need to rely on array’s.

The idea is that you are going to loop over all the connections you want to make (careful, too many and you can grind your CPU on your test client machine to a halt) and initialize the nc objects:

var nsArr:Array = new Array();
var ncArr:Array = new Array();

for ( var i = 0, i < 500; i++ ) {
  ncArr[i] = new NetConnection();
  ncArr[i].connect( server );
  ncArr[i].addEventListener( NetStatusEvent.NET_STATUS, onNetStatus );
}

While this is happening, your NetConnections are going to start calling onNetStatus(). In the onNetStatus() function you are going to want to create a NetStream for each NetConnection and have that newly minted NetStream start pulling down a stream:

function onNetStatus( evt ) {
  var cnt = nsArr.length
  nsArr[cnt] = new NetStream( evt.target );
  nsArr[cnt].client = this;
  nsArr[cnt].play( stream );
}

Of course, the above is to give you a head start only. There is a lot of additional things you can add. Note that the Flash runtime isn’t the most efficient software on the planet and it will consume massive amounts of system resources, so be careful!

If you wanted to load test a server that served text and misc data rather than video or audio, then the above code will need to be modified, but the principle is the same, if you want to test for 100 clients, you will need 100 NetConnection object’s initialized, with each one carrying their own data stream, be it audio, video or text.

From → Actionscript

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS