分享
  1. 首页
  2. 文章

golang与node.js的http对比测试

happylife1527 · · 2103 次点击 · · 开始浏览
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

注:本文对于新版本的golang并不使用,go1以后go的性能已经有了比较好的提升,具体测试见: http://www.cnblogs.com/QLeelulu/archive/2012/08/12/2635261.html

听说Go是很不错的语言,了解了一下,一些特性确实很不错。

顺便测试了一下http与node.js的性能对比。

go的代码:

image
(注:是用8g, 8l编译的)

node.js的代码:

image

ab测试结果:

==** GO **==

$ ab -c 100 -n 1000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3<$Revision: 655654$>
Server Software: 
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 1 bytes
Concurrency Level: 100Time taken for tests: 0.322 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 97000 bytes
HTML transferred: 1000 bytes
Requests per second: 3105.62 [#/sec] (mean)Time per request: 32.200 [ms] (mean)Time per request: 0.322 [ms] (mean, across all concurrent requests)
Transfer rate: 294.18 [Kbytes/sec] received
Connection Times (ms)
 min mean[+/-sd] median max
Connect: 000.703
Processing: 13010.52955
Waiting: 13010.52955
Total: 43010.12955

==** Node.js **==

$ ab -c 100 -n 1000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3<$Revision: 655654$>
Server Software: 
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100Time taken for tests: 0.143 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 50000 bytes
HTML transferred: 12000 bytes
Requests per second: 6993.50 [#/sec] (mean)Time per request: 14.299 [ms] (mean)Time per request: 0.143 [ms] (mean, across all concurrent requests)
Transfer rate: 341.48 [Kbytes/sec] received
Connection Times (ms)
 min mean[+/-sd] median max
Connect: 001.104
Processing: 2136.61330
Waiting: 2136.61330
Total: 2146.41430

webbench测试结果

==** GO **==

$ webbench -t 30 -c 100 http://127.0.0.1:8080/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://127.0.0.1:8080/100 clients, running 30 sec.
Speed=146934 pages/min, 262032 bytes/sec.
Requests: 73467 susceed,0 failed.

==** Node.js **==

$ webbench -t 30 -c 100 http://127.0.0.1:8080/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://127.0.0.1:8080/100 clients, running 30 sec.
Speed=485128 pages/min, 404273 bytes/sec.
Requests: 242564 susceed,0 failed.

从测试结果来看,node.js的HTTP SERVER性能是Go的两倍还多,而且让我比较郁闷的是,在用webbench进行测试的时候,可以看到go是用了我的笔记本上的四个核的CPU的,而node.js当然是只跑在一个核上,而Go居然还比node.js慢这么多。

然后我google,就看到:golang helloworld 45% slower than node.js

求真相!


有疑问加站长微信联系(非本文作者)

本文来自:CSDN博客

感谢作者:happylife1527

查看原文:golang与node.js的http对比测试

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

关注微信
2103 次点击
暂无回复
添加一条新回复 (您需要 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传

用户登录

没有账号?注册
(追記) (追記ここまで)

今日阅读排行

    加载中
(追記) (追記ここまで)

一周阅读排行

    加载中

关注我

  • 扫码关注领全套学习资料 关注微信公众号
  • 加入 QQ 群:
    • 192706294(已满)
    • 731990104(已满)
    • 798786647(已满)
    • 729884609(已满)
    • 977810755(已满)
    • 815126783(已满)
    • 812540095(已满)
    • 1006366459(已满)
    • 692541889

  • 关注微信公众号
  • 加入微信群:liuxiaoyan-s,备注入群
  • 也欢迎加入知识星球 Go粉丝们(免费)

给该专栏投稿 写篇新文章

每篇文章有总共有 5 次投稿机会

收入到我管理的专栏 新建专栏