Rage.rb — Khi Ruby Học Cách Không Chờ Đợi

Vấn đề muôn thuở của Rails dưới tải cao Bạn có một Rails API. Mọi thứ chạy tốt ở môi trường dev, production cũng ổn ở lượng traffic vừa phải. Rồi một ngày đẹp trời, traffic tăng đột biến — và bạn b...

By · · 1 min read
Rage.rb — Khi Ruby Học Cách Không Chờ Đợi

Source: DEV Community

Vấn đề muôn thuở của Rails dưới tải cao Bạn có một Rails API. Mọi thứ chạy tốt ở môi trường dev, production cũng ổn ở lượng traffic vừa phải. Rồi một ngày đẹp trời, traffic tăng đột biến — và bạn bắt đầu thấy: Response time leo thang Memory usage phình to Sidekiq queue tắc nghẽn Infra team hỏi "có cần thêm worker không?" Vấn đề không phải ở code logic. Vấn đề nằm sâu hơn — ở cách Rails xử lý concurrency. Rails xử lý concurrency như thế nào? Rails với Puma dùng mô hình multi-threaded. Mỗi HTTP request được xử lý bởi một thread riêng. Request 1 ──→ Thread 1: [connect DB] [======chờ 50ms======] [process] [respond] Request 2 ──→ Thread 2: [connect DB] [======chờ 50ms======] [process] [respond] Request 3 ──→ Thread 3: [connect DB] [======chờ 50ms======] [process] [respond] ... Request N ──→ Thread N: phải chờ thread trống Trong 50ms chờ database, thread đó không làm gì cả — nó block hoàn toàn. Đây gọi là blocking I/O. Giải pháp của Puma: tăng số thread. Nhưng mỗi thread tốn 1–8MB RAM và OS

Related Posts

Similar Topics

#data science (21)#webdev (24)#artificial intelligence (13)#programming (20)#python (20)#pandas (20)#deep learning (9)#architecture (15)#engineering (15)#the library (14)#deep dives (14)#news & insights (14)#go (10)#javascript (11)#data engineering (6)#chrome (11)#concurrency (11)#open source (11)#ai (10)#api (8)

Trending on ShareHub

  1. Understanding Modern JavaScript Frameworks in 2026
    by Alex Chen · Feb 12, 2026 · 0 likes
  2. The System Design Primer
    by Sarah Kim · Feb 12, 2026 · 0 likes
  3. Just shipped my first open-source project!
    by Alex Chen · Feb 12, 2026 · 0 likes
  4. OpenAI Blog
    by Sarah Kim · Feb 12, 2026 · 0 likes
  5. Building Accessible Web Applications: A Practical Guide
    by Alex Chen · Feb 12, 2026 · 0 likes
  6. Rapper Lil Poppa dead at 25, days after releasing new music
    Rapper Lil Poppa dead at 25, days after releasing new music
    by Anonymous User · Feb 19, 2026 · 0 likes
  7. write-for-us
    by Volt Raven · Mar 7, 2026 · 0 likes
  8. Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    by Anonymous User · Feb 12, 2026 · 0 likes
    #coffee gets cold #the #time travel
  9. Best DoorDash Promo Code Reddit Finds for Top Discounts
    Best DoorDash Promo Code Reddit Finds for Top Discounts
    by Anonymous User · Feb 12, 2026 · 0 likes
    #doordash #promo #reddit
  10. Premium SEO Services That Boost Rankings & Revenue | VirtualSEO.Expert
    by Anonymous User · Feb 12, 2026 · 0 likes
  11. NBC under fire for commentary about Team USA women's hockey team
    NBC under fire for commentary about Team USA women's hockey team
    by Anonymous User · Feb 18, 2026 · 0 likes
  12. Where to Watch The Nanny: Streaming and Online Viewing Options
    Where to Watch The Nanny: Streaming and Online Viewing Options
    by Anonymous User · Feb 12, 2026 · 0 likes
    #streaming #the nanny #where
  13. How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    by Anonymous User · Feb 12, 2026 · 0 likes
    #kindle unlimited #subscription #unlimited
  14. Russian skater facing backlash for comment about Amber Glenn
    Russian skater facing backlash for comment about Amber Glenn
    by Anonymous User · Feb 18, 2026 · 0 likes
  15. Google News
    Google News
    by Anonymous User · Feb 18, 2026 · 0 likes

Latest on ShareHub

Browse Topics

#artificial intelligence (31585)#data science (24018)#ai (17349)#generative ai (15034)#crypto (15024)#machine learning (14681)#bitcoin (14280)#featured (13571)#news & insights (13064)#crypto news (11101)

Around the Network