InfoQ

News

What Is Wrong With Ruby's Net::HTTP?

Posted by Mirko Stocker on Nov 14, 2008 02:00 PM

Community
Ruby
Topics
Performance & Scalability
Tags
HTTP ,
Ruby1.9

"What should be wrong with Ruby's Net:HTTP implementation?", one might ask. Adam Nelson was surprised by what he saw in an application that transfers huge amounts of data. "What actually happens is the CPU redlines, and the data are transferred in 1024 byte chunks.", Adam found out in his first analysis. The actual problem is that "it puts a timeout around every single rbuf_fill call," writes Alex Young, "so by default it has to spawn a new thread for every 1K of data it intends to receive".

A comparison between various implementations of Ruby and different libraries showed that Ruby 1.8.6 uses "twice as much CPU usage as the nearest competitor", that is Ruby 1.8.7, which apparently uses a larger buffer (16K). Interestingly, Ruby 1.9.0 has the lowest CPU usage, with an implementation that uses readpartial, "no timeout for socket reads" and "pre-allocated String buffer for each read". Close behind is RFuzz, a pure Ruby implementation based on the Mongrel core by Zed Shaw.

This issue isn't new, a thread on the ruby-talk mailinglist from 2006 discusses the problem and workarounds that avoid the problem for now.

In addition, this is also a good example how helpful and valuable having open source implementations can be.

No comments

Reply

Educational Content

JRuby: The Pain of Bringing an Off-Platform Dynamic Language to the JVM

Charles Nutter discusses bringing JRuby to the JVM, why Ruby is hard to implement, JIT compilation, precompilation, core Ruby implementation, Java library access, library challenges and future plans.

Performance Anti-Patterns in Database-Driven Applications

Alois Reitbauer specifies several architectural anti-patterns that one should stay away from and which can downgrade an application’s performance.

Making TDD Stick: Problems and Solutions for Adopters

Teams in large organizations still struggle to adopt TDD. In this article Mark Levison shares problems he uncovered when he surveyed teams, and his own strategy to introduce TDD into an organization.

Testing is Overrated

In this talk from RubyFringe, Luke Francl asks: is developer-driven testing really the best way to find software defects? Or is the emphasis on testing and test coverage barking up the wrong tree?

VM Optimizations for Language Designers

John Pampuch discusses the HotSpot compiler, the history of Java performance, HotSpot development philosophies and challenges, optimization, JVM library improvements, and tips for better performance.

Keith Braithwaite, an Agile Skeptic

In this interview, Keith Braithwaite, an Agile developer, consultant and trainer, says that we should show a good deal of skepticism towards today’s Agile practice.

Workflow Orchestration Using Spring AOP and AspectJ

This article demonstrates how to build and orchestrate highly configurable and extensible yet light-weight embedded process flow using AOP techniques with Spring AOP and Aspect J.

Embrace Uncertainty

Jeff Patton explains why one needs to embrace uncertainty in order to succeed with his/her Agile project and how to avoid some of the common mistakes leading to project failure.