翻译于 2015/05/13 16:15
1 人 顶 此译文
We noted with some interest the recent announcement of the io.js v2.0.0 release candidate. This community fork of node.js promises a supported version of the V8 engine, along with a greatly increased frequency of commits to master vs. the parent project.
As we’ve mentioned before, we’re keen on these developments as Node.js powers the Raygun API nodes, and ensuring these can handle the highest loads with the lowest possible response times is crucial to providing a great service to our users. A previous blog post benchmarked Node.js vs. io.js, and with the advent of the V2 release of the latter, we’d like to revisit those benchmarks to see how it stacks up in various situations.
我们注意到 io.js v2.0.0 RC 版公告中有些有趣的内容。这个社区版的 Node.js 同样基于 V8 引擎实现，而且主版本提交的频率远高于它的父项目（Node.js）。
就像我们之前提到的，之前我们热衷于用 Node.js 开发了 Raygun API，以确保在高负载情况下达到尽可能短的响应时间，给我们的用户提供最佳的服务。之前的一片博客比较了一下 Node.js 与 io.js的性能，后来 io.js V2 版本发布了，我们准备重温下不同情况下的性能测试。
Same as before, the following are synthetic micro-benchmarks, caveat emptor, huge grain of salt, etc. However, the charts do provide some interesting food for thought, and may provide a springboard for you to perform your own real-world tests, and potentially gain a significant speedup.
The benchmarks were conducted with identical runs through ApacheBench on a 64-bit Ubuntu VM. The configuration was 20,000 requests with a concurrency level of 100, and the test results were averaged over five runs of this.
We benchmarked two versions of node, and two versions of io.js. For node, v0.10.38 (the last release of the .10 branch) was compared against v0.12.2 (the absolute latest version of node.js).
For io.js, we compared v1.8.1, the last release on the 1.x branch against the newest v2.0.0 release.
像之前一样，下面测试综合了micro-benchmarks, caveat emptor, huge grain of salt 等等。不论如何，下面的图表提供了几个有趣的结果，值得思考一番，也给你自己的实地测试提供一个参考，而且以后你可能会获得一个显著的速度提升。
测试环境为：64-bit Ubuntu VM ApacheBench。配置为以100个并发运行20000个请求，结果为5次运行的平均值。
我们测试了2个版本的 node 跟2个版本的 io.js。node 是v0.10.38(0.10分支的最新版本)跟v0.12.2(现有最新的版本)
This test involved created a simple server with the
http module, and setting it to return a JSON payload on request. The results were:
What is interesting to note is the performance drop from node 0.10 to 0.12, which io.js corrects on the 1.x branch – but then dominates with v2.0.0.
When sending a raw response, in this benchmark io.js v2.0.0 has a 14% speedup over node 0.12! They’ve even managed a 5% speedup over their own previous release. Not bad at all, but there’s more we can test.
Express was and is still a very popular choice for quickly getting the backend of a web application up and running. Last time we documented some of the performance hit you take with it, but let’s see how it does under node 0.12 vs io.js v2.0.0:
There’s a 4.5% speedup when running this test on io.js v2.0.0 – pretty good for an older framework (considering how fast the JS ecosystem is moving)!
Many newer frameworks are competing for mindshare in the JS micro web framework space, however – we benchmarked some popular ones previously. One which we missed was Koa.js, which was in fact made by the authors of Express.js.
One of the huge benefits with Koa is that you can build code using
ES6 features – including generators and the yield syntax which enable
asynchronous code (no more callback hell). This benchmark was written
using generators and run with the
node --harmony flag enabled. The logic involved a simple bit of routing, and set the response to be an HTML fragment.
Let’s see how Koa does running on Node vs. io.js:
A 14.8% speedup from Node to the latest version of io.js
– certainly worthy of note. If you’re looking at one of the latest
generation of JS backend frameworks, it certainly pays to give io.js a
look as out-of-the-box you get some rather impressive perf improvements.
When running a cluster of VMs using the Node stack, depending on scale,
that speedup may result in several fewer boxes needed and
correspondingly less infrastructure costs – all for free.
We love perf improvements here at Raygun, so if you have any experience running io.js or Node in production feel free to post in the comments. We also have a kickass Node error tracking implementation – there’s a free 30-day trial available here. Keep improving that perf, and blasting those errors!
让我们观察 Koa 在 Node 和 io.js 上的运行情况：
从 Node 到 io.js 最新版本上有14.8%的速度提升-差距很大。如果你看过最新的 JS 后端框架，显而易见 io.js 有了相当的性能改进。当在一个 VM 集群运行 Node，根据规模，这个提升也许能少用几台机器及相应的设施成本 - 全都免费。
我们十分喜欢 Raygun 的性能改进，如果你有在产品中使用 io.js 或 Node 的经验欢迎随时在评论中发表。另外我们有一个强大的 Node 错误跟踪的实现 - 获取30天免费试用期。不断改进，让错误远离！