vertx.io 与nodejs 一个简单的性能比较

vertx.io 与node 都是可以进行js运行的一个引擎,但是vertx 支持的语言相对于node 多,可以查看官网。今天下网上查询相关的信息

时来了解到vertx.io 性能比node 好,于是自己编写简单的代码进行测试,同样书输出相同的信息。使用apache ab 模块进行性能呢比较。

1.node 端的代码:

var http = require('http');

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/html'});

res.end("<div><p>this is the first paragraph <p></div>");

}).listen(3000, '127.0.0.1');

使用3000端口进行

2.vertx 端代码:

var vertx = require('vertx');

vertx.createHttpServer().requestHandler(function(req) {

req.response.end("<div><p>this is the first paragraph <p></div>");

}).listen(8080, 'localhost');

3.运行脚本

分别进行

ab -n 1000 -c 100 http://localhost:8080/

ab -n 1000 -c 100 http://localhost:3000/

在测试时基本不相上下

ab -n 1000 -c 1000 http://localhost:8080/

ab -n 1000 -c 1000 http://localhost:3000/

在测试时基本不相上下但是vertx 会稍好一点

ab -n 5000 -c 1000 http://localhost:8080/

ab -n 5000 -c 1000 http://localhost:3000/

在测试时基本不相上下但是node会稍好一点

ab -n 50000 -c 1000 http://localhost:8080/

ab -n 50000 -c 1000 http://localhost:3000/

在测试时基本不相上下但是node会稍好一点

这是我一些简单的测试,基本上性能不相上下。

可能vertx 在处理其他的模型时,性能会更好吧。