Go 的快速 HTTP 包 fasthttp

码农软件 · 软件分类 · 网络工具包 · 2019-02-25 14:28:44

软件介绍

fasthttp 是 Go 的快速 HTTP 实现,当前在 1M 并发的生产环境使用非常成功,可以从单个服务器进行 100K qps 的持续连接。

HTTP 服务器性能与 net/http 比较

总而言之,fasthttp 比 net/http 快 10 倍

GOMAXPROCS=1

net/http:

$ GOMAXPROCS=1 go test -bench=NetHTTPServerGet -benchmem
PASS
BenchmarkNetHTTPServerGet1ReqPerConn              100000         21211 ns/op        2407 B/op         30 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn              100000         15682 ns/op        2373 B/op         24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn             200000          9957 ns/op        2103 B/op         19 allocs/op
BenchmarkNetHTTPServerGet10000ReqPerConn          200000          8243 ns/op        2034 B/op         18 allocs/op
BenchmarkNetHTTPServerGet1ReqPerConn1KClients      50000         23474 ns/op        2704 B/op         30 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn1KClients     100000         18124 ns/op        2539 B/op         24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn1KClients    100000         11815 ns/op        2689 B/op         19 allocs/op
BenchmarkNetHTTPServerGet10KReqPerConn1KClients   200000          9106 ns/op        2034 B/op         18 allocs/op

fasthttp:

$ GOMAXPROCS=1 go test -bench=kServerGet -benchmem
PASS
BenchmarkServerGet1ReqPerConn                     500000          2495 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet2ReqPerConn                    1000000          1925 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10ReqPerConn                   1000000          1300 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10KReqPerConn                  1000000          1140 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet1ReqPerConn1KClients            500000          2460 ns/op           1 B/op          0 allocs/op
BenchmarkServerGet2ReqPerConn1KClients           1000000          1962 ns/op           1 B/op          0 allocs/op
BenchmarkServerGet10ReqPerConn1KClients          1000000          1340 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10KReqPerConn1KClients         1000000          1180 ns/op           0 B/op          0 allocs/op

GOMAXPROCS=4

net/http:

$ GOMAXPROCS=4 go test -bench=NetHTTPServerGet -benchmem
PASS
BenchmarkNetHTTPServerGet1ReqPerConn-4                200000          5929 ns/op        2434 B/op         30 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn-4                300000          4153 ns/op        2399 B/op         24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn-4               500000          2751 ns/op        2118 B/op         19 allocs/op
BenchmarkNetHTTPServerGet10000ReqPerConn-4            500000          2398 ns/op        2037 B/op         18 allocs/op
BenchmarkNetHTTPServerGet1ReqPerConn1KClients-4       200000          5979 ns/op        2494 B/op         30 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn1KClients-4       300000          4582 ns/op        2457 B/op         24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn1KClients-4      300000          3589 ns/op        2537 B/op         19 allocs/op
BenchmarkNetHTTPServerGet10KReqPerConn1KClients-4     500000          2465 ns/op        2036 B/op         18 allocs/op

fasthttp:

$ GOMAXPROCS=4 go test -bench=kServerGet -benchmem
PASS
BenchmarkServerGet1ReqPerConn-4                      2000000          1094 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet2ReqPerConn-4                      2000000           707 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10ReqPerConn-4                     3000000           417 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10KReqPerConn-4                    5000000           351 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet1ReqPerConn1KClients-4             2000000           916 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet2ReqPerConn1KClients-4             2000000           655 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10ReqPerConn1KClients-4            3000000           404 ns/op           0 B/op          0 allocs/op
BenchmarkServerGet10KReqPerConn1KClients-4           5000000           359 ns/op           0 B/op          0 allocs/op

本文地址:https://codercto.com/soft/d/106.html

深度学习

深度学习

[美] 伊恩·古德费洛、[加] 约书亚·本吉奥、[加] 亚伦·库维尔 / 赵申剑、黎彧君、符天凡、李凯 / 人民邮电出版社 / 2017-7-1 / 168

《深度学习》由全球知名的三位专家Ian Goodfellow、Yoshua Bengio 和Aaron Courville撰写,是深度学习领域奠基性的经典教材。全书的内容包括3个部分:第1部分介绍基本的数学工具和机器学习的概念,它们是深度学习的预备知识;第2部分系统深入地讲解现今已成熟的深度学习方法和技术;第3部分讨论某些具有前瞻性的方向和想法,它们被公认为是深度学习未来的研究重点。 《深度......一起来看看 《深度学习》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试