Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo -


Published on

A high-performance proxy server is less than a hundred lines of Ruby code and it is an indispensable tool for anyone who knows how to use it. In this session we will first walk through the basics of event-driven architectures and high-performance network programming in Ruby using the EventMachine framework.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Wonderful, wonderful world in the context of building and using Ruby proxy servers for scale, performance and monitoring.
  • Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo -

    1. Ruby Proxies for Scale, Performance and Monitoring Ilya Grigorik CTO / AideRSS Event-Driven Architectures @igrigorik #meshu #eda
    2. The slides… Twitter My blog
    3. <ul><li>Proxy Love </li></ul>
    4. <ul><li>Myth: Slow Frameworks </li></ul>“ Rails, Django, Seaside, Scala…” cant scale.
    5. <ul><li>The Proxy Solution </li></ul>
    6. <ul><li>The “More” Proxy Solution </li></ul>
    7. <ul><li>Transparent, Cut-Through Proxy </li></ul>Transparent
    8. <ul><li>Transparent Proxy = Scalability Power Tool </li></ul>90% use case
    9. Proxies for Monitoring, Performance and Scale welcome to the wonderful world of intercepting, caching, … , proxy servers
    10. Problem: Staging Environment Production Simulated User
    11. “ Representative Load / Staging” Duplication Simulating traffic?
    12. Staging fail. Profile of queries has changed Fail Load on production has changed Fail Parallel environment Fail Slower release cycle Fail
    13. Replay log data, rinse, repeat
    14. <ul><li>Benchmarking Proxy </li></ul><ul><li>flash of the obvious </li></ul>Real (production) traffic Duplex Ruby Proxy, FTW!
    15. Transparent Duplex Proxy, FTW
    16. Same response, different turnaround time Different response body!
    17. <ul><li> </li></ul>Duplex Ruby Proxy, FTW!
    18. <ul><li>EM-Proxy Workflow </li></ul>1. Accept connection - Connect & Forward to Production - Connect & Forward to Staging 2. Stream response to client from Production - Buffer response from Staging 3. Run “Processor / Analyzer” once both return
    19. Ruby EventMachine crash course EM::Connection #receive_data - new data ready for processing #unbind - connection terminated #connection_completed - connected
    20. Duplex incoming data
    21. Forward Production Response Analyze Results
    22. Open connection to application server
    23. Buffer until connected
    24. Pass response to Duplex Notify when done
    25. Analyze Time, Response…
    26. Analyze Time, Response… Response Time
    27. Cute, right? but so what…
    28. %w[ <Transparent> Intercepting Caching … ] solution for every problem
    29. Validating Proxy easy, real-time diagnostics Woops!
    30. Who said you’re not allowed to touch the data? Intercepting Proxy for those hard-to-reach spots
    31. SMTP / Mail: inject SPAM detection De(encrypt): stream data MySQL: inject sharding logic Intercepting Proxy for those hard-to-reach spots
    32. @PostRank: Beanstalkd + Ruby Proxy because RAM is still expensive
    33. <ul><li>Beanstalkd Math </li></ul>~ 93 Bytes of overhead per job ~300 Bytes of data / job x 80,000,000 jobs in memory ~ 30 GB of RAM = 2 X-Large EC2 instances Oi, expensive!
    34. <ul><li>Extending Beanstalkd </li></ul>Observations: 1. Each job is rescheduled several times 2. > 95% are scheduled for > 3 hours into the future 3. Beanstalkd does not have overflow page-to-disk Memory is wasted… We’ll add it ourselves!
    35. @PostRank: “Chronos Scheduler” 1 “Medium” EC2 Instance Intercepting Proxy
    36. Extend the protocol Chronos Scheduler Beanstalkd persistence Process incoming data Buffer “SCHEDULE” requests, otherwise forward
    37. Archive to MySQL Chronos Scheduler Beanstalkd persistence Buffer “SCHEDULE”
    38. @PostRank: “Chronos Scheduler” Extend the protocol ARCHIVE RESERVE, … 10 line patch to client: queue.archive(job)
    39. @PostRank: “Chronos Scheduler” ~79,000,000 jobs, 4GB RAM ARCHIVE RESERVE, … Upcoming jobs: ~ 1M 400% cheaper + extensible! 1 Proxy, 1 Beanstalkd, 1 MySQL = 200 req/s
    40. %w[ Transparent <Intercepting> Auth Cache … ] easy to make & a powerful hammer
    41. Cheers. Questions? The slides… Twitter My blog