Rails   B2B                             @freewheel.tv   @freewheel.tv                                                  201...
!  FreeWheel! !  Rails FreeWheel!  Rails! 
FreeWheel   !
What does FreeWheel do?• • •            30%     •      •    comScore
What is MRM/RPM?         •  Monetization Rights Management®           •          •  Revenue & Payments Management®        ...
!
FreeWheel MRM  Ad#Tag#/#Request              Ad#Manager                    Video#Metadata MRM        Ad#Server            ...
Technology StacksIntegration             Flash&(AS2/AS3)&          iPhone/iPad&(ObjAC)&               HTML5&/&JavaScript& ...
Open Source Building Blocks                              11
•      • •             Uptime: 99.99%     •      •      • •      •      •    Insight•      •    +•      •                 ...
•  Since 2010•   •  S.W.A.T team  •  Top Guns/Code Monkeys•                    !•  DevOps:                             13
UI •  RPM+MRM UI •       •  Ruby on Rails + Sinatra      •       JS/CSS •       •       •       •       •       •  … •    ...
Rails   FreeWheel   !
Rails !  2007 7   Rails 1.2.3 !  MRM UI                           Rails       
   
                                   

!    17
Quick-and-Dirty !                Business Driven   !    !  B2B !  Release   !        5~6           Release   !          Po...
Rails         “       ” !  Rails                        !      !                              !      !  “   ” workaround !...
UI   !         20
Rails
!  Rails1.2 (March, 2007) => Rails3.0 (April, 2011)  !  Bundle Scopes I18N Rack-based Middleware…  !  MRM RPM             ...
Rails3.0 !  3 Release 12 !  LoC in Branch      # Commits          LoC         LoC(Exclude Vendor)           344      +6932...
!                   SSO                                               API                       …!  Module              Mi...
!    mount                   Module                                !                    Gem          Module   !       Asse...
Business Model!                                       Let Model be DAO !  ActiveRecord Model                   Business Lo...
— Model   !                           Validation                       !              1.              Validation          ...
— Business Model   !                            Business Model                                  Validation                ...
Widgets !                  MVC  !                            jQuery jQuery UI  !  JSON + Restful  !       !       !  Grid,...
Widgets           !    Widgets              AdProduct               ContentTargeting            Schedule               Bud...
Widget   -   !                 31
Widget—       !                  FormWidget                               Field          !                                ...
Widget—   !                       !              Widget                       33
Widgets   !              34
Unicorn + !               Lighttpd + FastCGI !  Unicorn      –  An HTTP server with 2k+ lines of pure ruby code      –  Be...
!  DCI Data, context and interaction                           !! !            !  !              !  !  CSS           !!  F...
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
02s0102基于rails的大型b2 b系统架构优化   于冰赵晓锋
Upcoming SlideShare
Loading in …5
×

02s0102基于rails的大型b2 b系统架构优化 于冰赵晓锋

1,461 views

Published on

rails 性能优化

Published in: Design, Technology, Education
  • Be the first to comment

02s0102基于rails的大型b2 b系统架构优化 于冰赵晓锋

  1. 1. Rails B2B @freewheel.tv @freewheel.tv 2012.04© FreeWheel 2011
  2. 2. !  FreeWheel! !  Rails FreeWheel!  Rails! 
  3. 3. FreeWheel !
  4. 4. What does FreeWheel do?• • •  30% •  •  comScore
  5. 5. What is MRM/RPM? •  Monetization Rights Management® •  •  Revenue & Payments Management® •  6
  6. 6. !
  7. 7. FreeWheel MRM Ad#Tag#/#Request Ad#Manager Video#Metadata MRM Ad#Server Ad#Server Ad#Server Ad#Server DB:#OLTP/OLAP UI/API:#Adver-sing/Inventory Log#Files ETL#Repor-ng Inventory#Forecast 9
  8. 8. Technology StacksIntegration Flash&(AS2/AS3)& iPhone/iPad&(ObjAC)& HTML5&/&JavaScript& Android&(Java)& Silverlight&(C#)&Service Quality BUSINESS&INTELLIGENCE& MRM/RPM:&UI/API # Cucumber & (RoR,#jQuery,#Java) Analy-cs## Ad&Server& ETL&ReporQng& (MicroStrategy) (C++) Selenium Forecast& (Map#Reduce#like,#C++,#Python) Log&Replay # Management&&&Monitor&Portal& BVI/BII/Data& Search## (Python,#jQuery,#SQLite) Manager (Lucene#/#Solr) (Ruby,#etc.) REGRESSION & MRM/RPM&UI & VI& Message#Queue(ZMQ) Cache#/#Fast#Storage#(Memcached/ # Ad&Server & LevelDB/MongoDB) OLAP#(Infobright) ETL&ReporQng Forecast& Task#Scheduler#(crontab,#etc) OLTP#(MySQL) Rules&Engine &Infrastructure SYSTEM& STORAGE& NETWORKING& Mostly#Linux#(RHEL#5) SAN#+#NAS LB#/#Akamai 10
  9. 9. Open Source Building Blocks 11
  10. 10. •  • •  Uptime: 99.99% •  •  • •  •  •  Insight•  •  +•  •  12
  11. 11. •  Since 2010•  •  S.W.A.T team •  Top Guns/Code Monkeys•  !•  DevOps: 13
  12. 12. UI •  RPM+MRM UI •  •  Ruby on Rails + Sinatra •  JS/CSS •  •  •  •  •  •  … •  14
  13. 13. Rails FreeWheel !
  14. 14. Rails !  2007 7 Rails 1.2.3 !  MRM UI Rails 
 
 

  15. 15. ! 17
  16. 16. Quick-and-Dirty !  Business Driven !  !  B2B !  Release !  5~6 Release !  Point Release Bugfix ! “ ” !  Rails !  Best Practice
  17. 17. Rails “ ” !  Rails ! !  ! !  “ ” workaround !  Fat Model !  ! !  ! !  Validations Callbacks ! !  View !  Partial !  RHTML/HAML/ERB JavaScript
  18. 18. UI ! 20
  19. 19. Rails
  20. 20. !  Rails1.2 (March, 2007) => Rails3.0 (April, 2011) !  Bundle Scopes I18N Rack-based Middleware… !  MRM RPM !!  Rails3.1 Asset Pipeline!  JavaScript !  jQuery 1.2 => jQuery 1.4.4 !  jQuery-UI Widgets
  21. 21. Rails3.0 !  3 Release 12 !  LoC in Branch # Commits LoC LoC(Exclude Vendor) 344 +69322, -62147 +41559, 43750 !  LoC in Trunk # Commits LoC 592 +13137, -11324
  22. 22. !  SSO API …!  Module Mini Rails!  Application Module Bundled APP Module Module Module Resources Resources Resources C Biz Logic C Biz Logic C Biz Logic A A A O O O N View/Helper P N View/Helper P N View/Helper P I I I F Controller F Controller F Controller Model Model Model SSO User Permission System API (Search, i18n, …) Tasks Shared Model Controller/Dispatcher View/Helper BizLogic Shared 3rd Plugins Components Shared Resources
  23. 23. ! mount Module ! Gem Module ! Asset Pipeline Modul e ! 25
  24. 24. Business Model!  Let Model be DAO !  ActiveRecord Model Business Logic !  Active Record Callbacks Validations Rails MVC with Business Model AcQon&View Widgets& AcQon&Controller Business&Model& Business&Scenario& AcQveRecord AcQveRecord
  25. 25. — Model ! Validation ! 1. Validation 2. validation if/else ! 3. Model LoC>2k)! 27
  26. 26. — Business Model ! Business Model Validation 1. “ ” 2. Business Model 3. Business Model Business Model 28
  27. 27. Widgets !  MVC !  jQuery jQuery UI !  JSON + Restful !  !  !  Grid, Tab, Calendar, Layout, Accordion, Wizard, Dropdown… !  !  !  ! 
  28. 28. Widgets ! Widgets AdProduct ContentTargeting Schedule Budget GeoTargeting ... ... Components AdvancedS Base Grid Toolbar Form earch Lang jQuery I18n FW Core 30
  29. 29. Widget - ! 31
  30. 30. Widget— ! FormWidget Field ! 32
  31. 31. Widget— ! ! Widget 33
  32. 32. Widgets ! 34
  33. 33. Unicorn + !  Lighttpd + FastCGI !  Unicorn –  An HTTP server with 2k+ lines of pure ruby code –  Better memory control by shared memory, forking –  Copy-on-write with REE 1.8.7 –  (Twitter, Github…)
  34. 34. !  DCI Data, context and interaction !! !  ! !  ! !  CSS !!  FreeWheel UI ! !  ! !  ! Multitenant Architecture Easy Customization Better Access

×