wsl下的ab测试存在严重问题
1. 简单的 golang http 服务器
package main
import "C"
import (
"log"
"net/http"
"time"
)
func init() {
log.SetFlags(log.Lshortfile | log.LstdFlags)
log.Println("init done ", time.Now())
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello"))
})
http.ListenAndServe(":8001", nil)
}
wsl 下 ab 压测
ab -c 100 -n 10000 http://localhost:8001/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software:
Server Hostname: localhost
Server Port: 8001
Document Path: /
Document Length: 5 bytes
Concurrency Level: 100
Time taken for tests: 4.292 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1210000 bytes
HTML transferred: 50000 bytes
Requests per second: 2329.67 [#/sec] (mean)
Time per request: 42.925 [ms] (mean)
Time per request: 0.429 [ms] (mean, across all concurrent requests)
Transfer rate: 275.28 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 9 21 4.2 21 31
Processing: 2 22 4.9 22 43
Waiting: 0 15 5.7 14 31
Total: 26 43 6.1 42 66
Percentage of the requests served within a certain time (ms)
50% 42
66% 45
75% 47
80% 48
90% 51
95% 54
98% 55
99% 55
100% 66 (longest request)
ubuntu 2004 虚拟机内测试
ab -c 100 -n 100000 http://localhost:8001/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software:
Server Hostname: localhost
Server Port: 8001
Document Path: /
Document Length: 5 bytes
Concurrency Level: 100
Time taken for tests: 3.902 seconds
Complete requests: 100000
Failed requests: 0
Total transferred: 12100000 bytes
HTML transferred: 500000 bytes
Requests per second: 25627.61 [#/sec] (mean)
Time per request: 3.902 [ms] (mean)
Time per request: 0.039 [ms] (mean, across all concurrent requests)
Transfer rate: 3028.26 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.4 1 7
Processing: 0 3 20.7 2 502
Waiting: 0 2 20.6 1 502
Total: 0 4 20.6 3 503
Percentage of the requests served within a certain time (ms)
50% 3
66% 3
75% 3
80% 3
90% 3
95% 3
98% 4
99% 6
100% 503 (longest request)
经过多次测试,wsl 根本无法测试展示正常的 http 性能。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY