TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Golang 10x faster than Ruby for web APIs

65 点作者 mattetti将近 12 年前

21 条评论

Freaky将近 12 年前
A slow dynamic bytecode-interpreted globally VM-locked language running a massive completely-overkill framework is only 10x slower than a statically compiled natively concurrent language running a tiny microframework? I'd say that's a massive positive for Ruby and Rails to be honest.
评论 #5881819 未加载
评论 #5881449 未加载
评论 #5881551 未加载
评论 #5883285 未加载
评论 #5881708 未加载
评论 #5881737 未加载
gtaylor将近 12 年前
Compiled, concurrency&#x2F;parallelism-focused language is more performant than a dynamically typed, interpreted language in a micro benchmark. News at 11.<p>While it&#x27;d be great to get to the point where you <i>need</i> to worry a lot about performance, the reality is that most projects won&#x27;t ever get there. Some of us will fail quite a few times before getting to the point of having to worry about Ruby-specific performance issues.<p>Don&#x27;t get me wrong, I have really enjoyed playing with Go. I just think we have a tendency to geek out about &quot;performance&quot;, when it&#x27;s not nearly as important as productivity&#x2F;maintainability for most of us.<p>Apologies for the rant, but these benchmarks are just short of useless, and I wish we would spend more time &quot;benchmarking&quot; ease of development, maintainability, and talent availability.
评论 #5881513 未加载
relix将近 12 年前
Another day, another &quot;proof&quot; that Ruby is slower than X, which surprises exactly no one.<p>The interesting thing here though is that considering the trivial amount of work to be done, Ruby shouldn&#x27;t be that slow. I&#x27;d like to see the source code of the Ruby project to see if some simple improvements could have been made that aren&#x27;t too invasive.<p>The spike in latency at around 15,000 requests could be explained by the garbage collector, which normally is put out-of-band. This makes me believe that he used a single-threaded, single-worker approach for Ruby. I don&#x27;t know about the Go framework he used, but maybe it was multi-threaded (and not green-threads).
评论 #5881516 未加载
评论 #5881682 未加载
评论 #5881379 未加载
评论 #5881847 未加载
mtkd将近 12 年前
Using Go is a constant temptation and for small APIs it&#x27;s probably a good choice.<p>Ruby (esp. Rails), for me, is worth the performance trade-off - even though that stings me coming from a C&#x2F;assembler background originally.<p>With Rails you can build complex&#x2F;deep APIs with very efficient syntax and clear tests - the conventions enforced mean that everything is in the same place&#x2F;style no matter who coded it - so the finished app is more maintainable than in any other language&#x2F;framework I&#x27;ve ever known.
评论 #5881697 未加载
评论 #5882817 未加载
mixedbit将近 12 年前
I don&#x27;t like ad-hoc benchamarks that do not attempt at all to investigate what was the cause of measured differences.<p>There are many factors that influence request processing time, language is only one of them. Web APIs are most often IO bound, so large differences between frameworks often indicate the IO is handled differently. From my experience, dynamic languages can easily handle HTTP requests below 10ms without any DB interaction, and out-of-a-box DB interaction that framework provide is often suboptimal. If you investigate, it can for example turn out that ORM runs several SQL queries for operations that could be performed with just one, or that it makes a separate DB connection for each request (looking at you Django).<p>Ruby 10x faster than Golang tells nothing.<p>Why is that there there is a big spike around 15,000 requests? If you investigate, you may discover that Puma by default creates 16 threads, and the benchmark simulates 20 clients (<a href="https:&#x2F;&#x2F;github.com&#x2F;puma&#x2F;puma" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;puma&#x2F;puma</a>), so requests from 4 clients need to wait in queues. As a result, the benchmark may be comparing apples to oranges: code with no upper limit on number of concurrent requests, with code that can handle 16 concurrent requests.
trebor将近 12 年前
I wrote a simple service in Go that takes &lt;11MB RAM and can handle 7500 requests&#x2F;sec. That was a fast one-off when playing around. I&#x27;ve never had even a simple Sinatra app run half that fast.
评论 #5881703 未加载
grey-area将近 12 年前
The really important saving between the two will probably be memory usage for most uses - 10x less memory is far more important as memory is a limit far more frequently hit than processing speed. This does depend on the application of course, but for the vast majority of web applications speed is not really an issue, even when they have a lot of users, so then it comes down to tooling and libraries, where Go is a little lacking at the moment (though I&#x27;m sure it&#x27;ll catch up).<p>It&#x27;s a great language to work with though and I can see it easily overtaking Ruby in this space given a few more years, partly because it&#x27;s so easy to pick up when coming from languages like Ruby and Python.
kbojody将近 12 年前
Although I&#x27;m sure Go would still be faster than Ruby, this is comparing Go (and actually the Revel framework) to <i>Rails</i>.
评论 #5881340 未加载
swah将近 12 年前
10x is not enough to justify. I really expected around 50-100x.
评论 #5881450 未加载
rubyn00bie将近 12 年前
I really don&#x27;t think he understands ruby web servers well... Using Puma on MRI is silly. You get none of the threading gains it was designed for. It needs to run in jruby or rubinius for it to be mildly accurate.<p>Also, Puma ain&#x27;t the fastest ruby web server. I&#x27;d like to see this same test run using Thin 2.0 (though it&#x27;ll make you cry-- or so they say), Unicorn, or Rainbows.<p>As well, as others have said, comparing a large framework to one without is silly.<p>I&#x27;m not hating on go or saying rails is fast, I just feel like this is a particularly bad demonstration of the authors point.<p>This is more of a correlation, than causation. Too many factors not accounted for, or mentioned, which obviously contribute to the results.
Mikeb85将近 12 年前
So a statically typed compiled language is quicker than Ruby... Not exactly shocking. Ruby&#x27;s advantage isn&#x27;t in its speed, but in how easy and quick it is to get things done.
评论 #5881772 未加载
rartichoke将近 12 年前
Your benchmarks are ridiculously skewed and inaccurate. Note: I&#x27;m not a Ruby developer and I already gave up on Go months and months ago.<p>You&#x27;re comparing a full stack with a million bells and whistles attached to each request (Rails) vs basically nothing but a basic route mapper.<p>You should do real world benchmarks IMO. There&#x27;s no doubt Rails will be slower but you&#x27;re going to spend so much time reinventing things that every other popular web language has had for years upon years [note: this is the main reason why I stopped using Go, I kept having to solve problems that were solved in every major other framework].
dataminer将近 12 年前
A better comparison would be Golang vs Sinatra Synchrony, instead of using Rails.
kbd将近 12 年前
s&#x2F;Ruby&#x2F;Rails&#x2F;<p>Rails is a heavyweight framework. I&#x27;d be more interested in a comparison with a lightweight framework like Cuba. Ruby will still lose to Go, but the difference probably won&#x27;t be 10x.
评论 #5883781 未加载
timdorr将近 12 年前
For a little bit of fairness, shouldn&#x27;t he at least be comparing Sinatra, not Rails? And where&#x27;s the source code so we can compare the other part of this: developer effort.
评论 #5881741 未加载
评论 #5881526 未加载
adrianlmm将近 12 年前
He writes:<p>&quot;My code is simpler, more flexible and easily cross compiles&quot;<p>Show us the code then, cause I so much doubt that.
Shorel将近 12 年前
I would expect a greater factor.<p>In this case, this is good news for Ruby.
adrianlmm将近 12 年前
You mean, native is faster than interpreted?<p>Incredible!
DonnyV将近 12 年前
Is anyone really surprised by this.
MrBra将近 12 年前
it&#x27;s like they always need to find someething against ruby.
_progger_将近 12 年前
Slow train on rails is probably better then a fast one without :).