Streaming Service on Flex and Rails

54
RhemaTech Streaming Service upon Flex and Rails

description

Slides for Streaming Service on Flex and Rails at Ruby Tuesday.

Transcript of Streaming Service on Flex and Rails

Page 1: Streaming Service on Flex and Rails

RhemaTech

Streaming Service upon Flex and Rails

Page 2: Streaming Service on Flex and Rails

RhemaTech

We work in Rhematech Inc.

Page 3: Streaming Service on Flex and Rails

RhemaTech

We provide live Streaming service over Internet on web

Page 4: Streaming Service on Flex and Rails

RhemaTech

100+ concurrent channels

Page 5: Streaming Service on Flex and Rails

RhemaTech

50000+ concurrent audience per channel

Page 6: Streaming Service on Flex and Rails

RhemaTech

Short demo(todo)

Page 7: Streaming Service on Flex and Rails

RhemaTech

System Structure

Page 8: Streaming Service on Flex and Rails

RhemaTech

Event Management

System

Channel Management

System

Media Server

Encoder/Audience UI Flex

Rails

Java/C++

Page 9: Streaming Service on Flex and Rails

RhemaTech

Main Challenges :Cost and Scalability

Page 10: Streaming Service on Flex and Rails

RhemaTech

We choose Flex and Railsbecause of

Page 11: Streaming Service on Flex and Rails

RhemaTech

COST

Page 12: Streaming Service on Flex and Rails

RhemaTech

We were used to be .NET users

Page 13: Streaming Service on Flex and Rails

RhemaTech

We suffered from high development and deployment cost

Page 14: Streaming Service on Flex and Rails

RhemaTech

It fails to respond dynamic requirements

Page 15: Streaming Service on Flex and Rails

RhemaTech

We did take Silverlight into consideration

Page 16: Streaming Service on Flex and Rails

RhemaTech

Not popular enough

Page 17: Streaming Service on Flex and Rails

RhemaTech

Poor designer support

Page 18: Streaming Service on Flex and Rails

RhemaTech

No alternatives for media server

Page 19: Streaming Service on Flex and Rails

RhemaTech

Flex and Rails save us

Page 20: Streaming Service on Flex and Rails

RhemaTech

Serve multimedia on web

Page 21: Streaming Service on Flex and Rails

RhemaTech

Rich user interaction

Page 22: Streaming Service on Flex and Rails

RhemaTech

Run over standard protocols

Page 23: Streaming Service on Flex and Rails

RhemaTech

Low development and deployment cost

Page 24: Streaming Service on Flex and Rails

RhemaTech

Good looking

Page 25: Streaming Service on Flex and Rails

RhemaTech

Service on mobile device(in the future)

Page 26: Streaming Service on Flex and Rails

RhemaTech

Lessons we learned

Page 27: Streaming Service on Flex and Rails

RhemaTech

#1. Be RESTful

Page 28: Streaming Service on Flex and Rails

RhemaTech

Consistent API design

Page 29: Streaming Service on Flex and Rails

RhemaTech

Consistent error handling

Page 30: Streaming Service on Flex and Rails

RhemaTech

Easier to extend and modify

Page 31: Streaming Service on Flex and Rails

RhemaTech

Always return errors in JSON/XML with 200 Ok

Page 32: Streaming Service on Flex and Rails

RhemaTech

flash.net.URLLoader does not handle HTTP error code well

Page 33: Streaming Service on Flex and Rails

RhemaTech

remove protect_from_forgeryfrom environment.rb

Page 34: Streaming Service on Flex and Rails

RhemaTech

#2. Use JSON instead of XML

Page 35: Streaming Service on Flex and Rails

RhemaTech

Less Traffic(quite important for large service)

Page 36: Streaming Service on Flex and Rails

RhemaTech

Easier to parse complex response

Page 37: Streaming Service on Flex and Rails

RhemaTech

Rails JSON Gotcha

Page 38: Streaming Service on Flex and Rails

RhemaTech

Rails does not unescapeunicode while decoding

Page 39: Streaming Service on Flex and Rails

RhemaTech

Fixed in Rails 2.3

Page 40: Streaming Service on Flex and Rails

RhemaTech

#3. Flash uses different session for file uploading on non-IE browsers

Page 41: Streaming Service on Flex and Rails

RhemaTech

Flash uses its http socket for file uploading on non-IE browsers

Page 42: Streaming Service on Flex and Rails

RhemaTech

Work Around -Session Migration

Page 43: Streaming Service on Flex and Rails

RhemaTech

#4. Handle Browser onbeforeunload event.

Page 44: Streaming Service on Flex and Rails

RhemaTech

Flash does not close NetConnection until you close all browser windows!

Page 45: Streaming Service on Flex and Rails

RhemaTech

#5. Create a controller to deliver debug .swf file in development mode.

Page 46: Streaming Service on Flex and Rails

RhemaTech

map.connect '/encoder.swf', :controller => “debug", :action => "encoder"if RAILS_ENV == ‘development'

route.rb

Page 47: Streaming Service on Flex and Rails

RhemaTech

def encodersend_file(path_to_debug_swf, options)

end

debug_controller.rb

Page 48: Streaming Service on Flex and Rails

RhemaTech

Makes debug and trace with rails much easier

Page 49: Streaming Service on Flex and Rails

RhemaTech

#6. Pick right video codec

Page 50: Streaming Service on Flex and Rails

RhemaTech

H263 vs. VP6 vs. H264

Page 51: Streaming Service on Flex and Rails

RhemaTech

H.263Pros: Flash Player build-inCons: Poor quality

Page 52: Streaming Service on Flex and Rails

RhemaTech

VP6Pros: Good video qualityCons: Expensive

Page 53: Streaming Service on Flex and Rails

RhemaTech

H264Pros: Good QualityCons: 2~6s more latency

Page 54: Streaming Service on Flex and Rails

RhemaTech

Questions?