google-code-export / red5

Automatically exported from code.google.com/p/red5
0 stars 0 forks source link

Ability to use shared NioProcessor for RTMPClient #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We are trying to use Red5 RTMPClient as a load-testing client. Our app provides 
some other services beside video, so we are writing tests in java code and 
these tests generate some http requests and then emulate flash clients which 
publish and subscribe to video streams.

We found red5 client API far more easy to use than flazr's API, but 
unfortunately currently red5 client needs some tuning to give appropriate 
performance. We've managed to apply some workarounds and get nice performance, 
but still it would be great if client have provided this functionality 
out-of-the-box.

So here are some of our optimizations:

1. Extend RTMPClient and override startConnector() method to use shared 
NioProcessor.

2. Set custom IoHandler for shared NioProcessor. IoHandler can be set only once 
and red5 RTMPMinaIoHandlers are bound to single connection. So our custom 
handler contains a Map<IoSession, IoHandler>, upon successfull connection (in 
IoFutureListener) we put IoSession and RTMPMinaIoHandler from RTMPClient into 
this map and all handler methods delegate to IoHandler for IoSession provided 
as argument.

3. Cache video files in memory to avoid file operations. When 500 clients are 
playing a single file in infinite loop performance severly degrades at the 
moment they all end loop iteration and start another one (all clients started 
simultaneously in our case) - seems due to file operations. Even setting large 
buffer (to hold the whole file) and fact that file should already have been 
cached by OS doesn't seem to help. FLVReaders API is designed that it can work 
without files but due to a bug 
(http://code.google.com/p/red5/issues/detail?id=90) this doesn't work now, so 
we construct FLVReader using constructor with IoBuffer argument and then set 
some stub shared FileChannel to prevent NPEs using reflection.

Original issue reported on code.google.com by dmitry.m...@mind.com on 3 Jun 2011 at 7:46

GoogleCodeExporter commented 9 years ago
Could you re-post this as a discussion on the red5 google group?  I would like 
to exchange some ideas with you since we are both working on 
work-arounds/improvements for RTMPCLient - but the issue queue here is not the 
best palce to have an extended discussion.

Original comment by patel...@gmail.com on 17 Jun 2011 at 1:24

GoogleCodeExporter commented 9 years ago

Original comment by mondain on 14 Jul 2011 at 3:50

GoogleCodeExporter commented 9 years ago

Original comment by mondain on 24 Oct 2011 at 4:48

GoogleCodeExporter commented 9 years ago
RTMPClient is written to simulate or be one Flash Player; it is possible to 
create multiple instances of course and if you have code for this we welcome 
your submission for review and addition to the repo / project. I see no 
pressing need to add a MultiClient at this time.

Original comment by mondain on 24 Oct 2012 at 5:56