惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 最新话题
L
LangChain Blog
量子位
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
Lohrmann on Cybersecurity
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
MongoDB | Blog
MongoDB | Blog
PCI Perspectives
PCI Perspectives
S
SegmentFault 最新的问题
O
OpenAI News
S
Securelist
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
G
Google Developers Blog
博客园 - 叶小钗
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客
V2EX - 技术
V2EX - 技术
小众软件
小众软件
IT之家
IT之家
Engineering at Meta
Engineering at Meta
Hacker News - Newest:
Hacker News - Newest: "LLM"
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
Recorded Future
Recorded Future
N
News and Events Feed by Topic
Cloudbric
Cloudbric
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
宝玉的分享
宝玉的分享

博客园 - Q.Lee.lulu

aProxy: 带认证授权和权限控制的反向代理 Nginx做前端Proxy时TIME_WAIT过多的问题 Cubieboard通过aria2和minidlna来架设家庭媒体中心 与IT&码农有关的电影和记录片 golang与node.js的http模块性能对比测试(go1) 用OpenCv来做人脸识别 linux下SublimeText的中文输入法问题之解决方案 作为Web开发人员,我为什么喜欢Google Chrome浏览器 sqlalchemy在web.py中的session使用 web.py大文件下载 Python和Node.js支持尾递归吗? 小文件、nginx、Redis、Moosefs 一道JavaScript面试题(setTimeout) 用Eclipse调试Node.js代码 Javascript中的类数组对象 Javascript正则分组命名 抛弃Fastcgi,用uwsgi来部署你的Django程序吧 Node.js:用JavaScript写服务器端程序-介绍并写个MVC框架 FaWave(发微)-Chrome上的多微博全能插件
golang与node.js的http对比测试
Q.Lee.lulu · 2011-09-07 · via 博客园 - Q.Lee.lulu

注:本文对于新版本的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:

100
Time 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:

100
Time 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

求真相!