Anúncio

Scaling Rails apps - Valentin Mihov

it-tour
22 de Jul de 2013
Anúncio

Scaling Rails apps - Valentin Mihov

  1. Скалиране на Rails Приложения Валентин Михов 2013
  2. За мен ● 5 години опит със Ruby on Rails ● скалиране до милиони заявки на ден ● big data processing
  3. Може ли Rails да скалира?
  4. Как работи Ruby on Rails? Browser WEBrick Makes request Rails App Parses the request Writes response Sends response
  5. Избор на правилен app server
  6. One machine concurrent setup Browser App Server Makes request Rails App Parses the request Writes response Sends response App Server App Server App Server App Server Pool of workers
  7. Many machines concurrent setup Browser Makes request Sends response App Server App Server App Server App Server App Server Load Balancer App Server App Server App Server App Server App Server App Server App Server App Server App Server App Server Balances between machines Instance/VM/Box Instance/VM/Box Instance/VM/Box
  8. Slow clients Връзката е бавна тъй като канала е Internet Може да има network latency Browser App Server App Server App Server App Server App Server Load Balancer App Server App Server App Server App Server App Server App Server App Server App Server App Server App Server
  9. Използвайте "буфери" за трафика Browser App Server App Server App Server App Server App Server ELB/haproxy/nginx App Server App Server App Server App Server App Server App Server App Server App Server App Server App Server nginxnginx nginx
  10. Изберете внимателно Ruby VM ● GC може да заема *МНОГО* време ● green threads vs true concurrency vs GIL ● много зависи от приложението ● ruby 1.8 не се поддържа официално ● GC tweaks ○ RUBY_GC_MALLOC_LIMIT ○ RUBY_HEAP_SLOTS_INCREMENT ○ RUBY_HEAP_MIN_SLOTS
  11. Ruby Enterprise Edition ● Може бе най-добрата 1.8 имплементация ● Tweakable GC params ● copy-on-write friendly GC ● Използва TCMalloc - по-бърз malloc
  12. JRuby ● Изграден върху JVM ● Използва JVM GC - много бърз ● Не поддържа native extensions ● Unicorn не се поддържа ● Трябва да се ползва TomCat, JBoss, GlassFish, etc. ● Няма GIL + използва native threads
  13. ● GC-то може да се тунингова ● Не всички gem-ове се поддържат ● Странна поддръжка на unicode ● Може би най-добрия избор за нов проект MRI 2.0
  14. Unicorn::OobGC Time Request 1 Request 2 Request 3 GC GC Time Request 1 Request 2 Request 3 GC GC
  15. Monitoring NewRelic - БЕЗЦЕННО!
  16. Полезни проекти/услуги ● Unicorn - app server ● nginx - web server ● haproxy - load balancer ● AWS - real-time scaling infrastructure ● NewRelic - kick ass monitoring ● REE - optimized ruby VM ● memcached - сесии, кеширане
  17. ● Първо измервайте, после оптимизирайте ● Работещ продукт - най-важната оптимизация ● В повечето случай bottleneck-а е data IO ● Rails скалира не по-лошо от всеки един друг framework ● Всичко e computer science И не забравяйте!
  18. Въпроси?
Anúncio