Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kaigi On Rails

Nate Berkopec
October 21, 2022
1.7k

Kaigi On Rails

Nate Berkopec

October 21, 2022
Tweet

Transcript

  1. @nateberkopec for Kaigi on Rails 2022 JA text on slides

    by @cafedomancer Queues in Rails Apps Sidekiq, Puma, and the GVL Rails ΞϓϦ έʔγϣϯʹ ͓͚ΔΩϡʔ
  2. Hi Nate, Our application is really slow, but our dashboards

    look OK. We don't really understand what's going on. Can you help us? Nate ༷ ͍ͭ΋͓ੈ࿩ʹͳ͓ͬͯΓ·͢ɻ ฐࣾͰӡ༻͍ͯ͠ΔΞϓϦέʔ γϣϯʹύϑΥʔϚϯε্ͷ໰୊ ͕͋Γɺ͓٬༷͔Βෆຬͷ੠͕د ͤΒΕ͍ͯ·͢ɻμογϡϘʔυ ΛݟΔݶΓͰ͸ɺಛʹ໰୊͸ݟ౰ ͨΓ·ͤΜͰͨ͠ɻฐࣾͷํͰ ͸ɺͲͷΑ͏ͳ໰୊͕ى͖͍ͯΔ ͷ͔Λ೺ѲͰ͖͓ͯΓ·ͤΜɻ͓ ๩͍͠ͱ͜ΖେมڪॖͳͷͰ͢
  3. Important Point / ॏཁͳϙΠϯτ Add queue time instrumentation for Sidekiq

    Ωϡʔ࣌ؒͷܭଌπʔϧΛ Sidekiq ʹಋೖ͠Α͏
  4. Predicted Latency = Current rate of job processing x #

    of Jobs in Queue ༧૝͞ΕΔϨΠςϯγʔ = ݱࡏͷδϣϒॲཧ཰ x Ωϡʔͷδϣϒ਺
  5. TODO 1. Arrange queues based on SLAs 2. Create alerts

    based on queue SLAs 1. SLA ʹج͍ͮ ͯΩϡʔΛ 
 ഑ஔ͠Α͏ 2. SLA ʹج͍ͮ ͯΞϥʔτΛ 
 ࡞੒͠Α͏
  6. Web

  7. 4 pods 1 worker 1 pod 4 workers More queue

    time? Ωϡʔ࣌ؒͳ͕௕ ͍ͷ͸ͲΕ͔ʁ
  8. TODO 1. Measure web request queueing 2. Set up autoscaling

    based on this 3. Use at least 4 child processes 1. Web ϦΫΤετ ͷΩϡʔΠϯά Λܭଌ͠Α͏ 2. ্هʹج͍ͮͯ ΦʔτεέʔϦ ϯάΛ 
 ઃఆ͠Α͏ 3. গͳ͘ͱ΋ 4 ͭ ͷϓϩηεΛ 
 ࢖༻͠Α͏
  9. TODO 1. Set thread count to 5 (web) or 10

    (Sidekiq) 2. Monitor service time under load 3. Upgrade to Puma 6 1. εϨου਺Λ 5 (web) ·ͨ͸ 10 (Sidekiq) ʹ 
 ઃఆ͠Α͏ 2. ෛՙ࣌ͷαʔϏε࣌ ؒΛ 
 ϞχλϦϯά͠Α͏ 3. Puma 6 ʹόʔδϣϯ 
 Ξοϓ͠Α͏
  10. TODO 1. Arrange queues based on SLAs 2. Create alerts

    based on queue SLAs 3. Measure web request queueing 4. Set up autoscaling based on this 5. Use at least 4 child processes 6. Set thread count to 5 (web) or 10 (Sidekiq) 7. Monitor service time under load 8. Upgrade to Puma 6 1. SLA ʹج͍ͮͯΩϡʔΛ 
 ഑ஔ͠Α͏ 2. SLA ʹج͍ͮͯΞϥʔτΛ 
 ࡞੒͠Α͏ 3. Web ϦΫΤετͷΩϡʔΠϯ άΛܭଌ͠Α͏ 4. ্هʹج͍ͮͯΦʔτεέʔ ϦϯάΛઃఆ͠Α͏ 5. গͳ͘ͱ΋ 4 ͭͷϓϩηεΛ ࢖༻͠Α͏ 6. εϨου਺Λ 5 (web) ·ͨ͸ 10 (Sidekiq) ʹઃఆ͠Α͏ 7. ෛՙ࣌ͷαʔϏε࣌ؒΛϞχ λϦϯά͠Α͏ 8. Puma 6 ʹόʔδϣϯΞοϓ͠ Α͏
  11. @nateberkopec for Kaigi on Rails 2022 JA text on slides

    by @cafedomancer Queues in Rails Apps Sidekiq, Puma, and the GVL Rails ΞϓϦ έʔγϣϯʹ ͓͚ΔΩϡʔ