Streaming Service on Flex and Rails
description
Transcript of Streaming Service on Flex and Rails
RhemaTech
Streaming Service upon Flex and Rails
RhemaTech
We work in Rhematech Inc.
RhemaTech
We provide live Streaming service over Internet on web
RhemaTech
100+ concurrent channels
RhemaTech
50000+ concurrent audience per channel
RhemaTech
Short demo(todo)
RhemaTech
System Structure
RhemaTech
Event Management
System
Channel Management
System
Media Server
Encoder/Audience UI Flex
Rails
Java/C++
RhemaTech
Main Challenges :Cost and Scalability
RhemaTech
We choose Flex and Railsbecause of
RhemaTech
COST
RhemaTech
We were used to be .NET users
RhemaTech
We suffered from high development and deployment cost
RhemaTech
It fails to respond dynamic requirements
RhemaTech
We did take Silverlight into consideration
RhemaTech
Not popular enough
RhemaTech
Poor designer support
RhemaTech
No alternatives for media server
RhemaTech
Flex and Rails save us
RhemaTech
Serve multimedia on web
RhemaTech
Rich user interaction
RhemaTech
Run over standard protocols
RhemaTech
Low development and deployment cost
RhemaTech
Good looking
RhemaTech
Service on mobile device(in the future)
RhemaTech
Lessons we learned
RhemaTech
#1. Be RESTful
RhemaTech
Consistent API design
RhemaTech
Consistent error handling
RhemaTech
Easier to extend and modify
RhemaTech
Always return errors in JSON/XML with 200 Ok
RhemaTech
flash.net.URLLoader does not handle HTTP error code well
RhemaTech
remove protect_from_forgeryfrom environment.rb
RhemaTech
#2. Use JSON instead of XML
RhemaTech
Less Traffic(quite important for large service)
RhemaTech
Easier to parse complex response
RhemaTech
Rails JSON Gotcha
RhemaTech
Rails does not unescapeunicode while decoding
RhemaTech
Fixed in Rails 2.3
RhemaTech
#3. Flash uses different session for file uploading on non-IE browsers
RhemaTech
Flash uses its http socket for file uploading on non-IE browsers
RhemaTech
Work Around -Session Migration
RhemaTech
#4. Handle Browser onbeforeunload event.
RhemaTech
Flash does not close NetConnection until you close all browser windows!
RhemaTech
#5. Create a controller to deliver debug .swf file in development mode.
RhemaTech
map.connect '/encoder.swf', :controller => “debug", :action => "encoder"if RAILS_ENV == ‘development'
route.rb
RhemaTech
def encodersend_file(path_to_debug_swf, options)
end
debug_controller.rb
RhemaTech
Makes debug and trace with rails much easier
RhemaTech
#6. Pick right video codec
RhemaTech
H263 vs. VP6 vs. H264
RhemaTech
H.263Pros: Flash Player build-inCons: Poor quality
RhemaTech
VP6Pros: Good video qualityCons: Expensive
RhemaTech
H264Pros: Good QualityCons: 2~6s more latency
RhemaTech
Questions?