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 在處理其他的模型時,性能會更好吧。

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM