Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Odyssey to async ruby

142 views

Published on

Keynote on RubyConf. China 2017

  • Be the first to comment

Odyssey to async ruby

  1. 1. Odyssey to Async Ruby Delton Ding GitHub: @dsh0416
  2. 2. Odyssey to Async Ruby Delton Ding GitHub: @dsh0416
  3. 3. 大概是这样的, 写了某个框架, 成为Github星星大户, 然后一股莫名的优越感涌上心头, 开始觉得别人都是垃圾。
  4. 4. 大概是这样的, 写了某个框架, 成为 GitHub 星星大户, 然后一股莫名的优越感涌上心头, 开始觉得别人都是垃圾。
  5. 5. Odyssey to Async Ruby
  6. 6. 「大多数项目都活不到遇到性能问题的那一天」
  7. 7. Wat?
  8. 8. Is Ruby Slow?
  9. 9. Is Ruby Slow? Yes, it is.
  10. 10. H E A P S O RT ( 1 0 ^ 7 E L E M E N T S ) C++ (clang-800) Go 1.7.4 Swift 3.0.1 Rust 1.13 Java 8 Crystal Node 7.2.1 Pypy3 5.5.0 LuaJIT 2.0.4 Elixir 1.4.0 JRuby (Graal) JRuby 9.1.6.0 PHP 7.0 Ruby 2.4.0 PHP 5.6 Lua 5.2.4 Python 3.6.0 Perl 5.18.2 100 1000 10000 100000 1000000 172,625 140,208 90,171 84,900 47,290 41,404 32,272 7,574 4,075 2,822 2,182 2,052 1,669 1,373 1,156 1,085 817 759 Running Time (ms)
  11. 11. My name is L**k. Stop calling me Z**da. 提 供
  12. 12. Concurrency What’s the problem?
  13. 13. Web Server Basic Views (Slim) Views + DB (Sequel) WEBrick 273 req/s 116 req/s 111 req/s Thin 1597 req/s 174 req/s 139 req/s Unicorn 605 req/s 121 req/s 121 req/s
  14. 14. Client Client Application Request Application Response API
  15. 15. Client Client Forked App Request Forked App Response API
  16. 16. Software Dev Is it an one-man orchestra?
  17. 17. –Yukihiro Matsumoto “Ruby is designed to make programmers happy.”
  18. 18. EM.run do http = EM HttpRequest.new(‘https://www.google.com/').get http.callback do
 puts result
 EM.stop
 end
 puts 'Requesting...'
 end
  19. 19. An Attempt
  20. 20. API call Database I/O Call Callback Call
  21. 21. Fiber API call Database I/O Yield Resume
  22. 22. I/O Pool By nio4r Fiber Pool By Fiber Resume Yield New
  23. 23. midori github.com/heckpsi-lab/em-midori
  24. 24. Goals • No I/O Blocking • Lightweight Stack Design • Engineering Capability
  25. 25. Demo
  26. 26. Benchmark
  27. 27. Web Server Basic DB (Sequel) Sinatra (Thin) 1597 req/s 111 req/s Midori 3937 req/s 1726 req/s Express.js (Node) 4944 req/s 2151 req/s
  28. 28. Middleware
  29. 29. Middleware Middleware Middleware Middleware Request Response API
  30. 30. Middleware Middleware Middleware Middleware Request API
  31. 31. Next Steps
  32. 32. Next Steps • Website/Tutorial • API Stable • I/O Improvement • Clusters • Scaffold
  33. 33. Thanks Delton Ding GitHub: @dsh0416

×