Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark client 可以提供一下吗 #1

Closed
SpikeWong opened this issue Apr 25, 2023 · 18 comments
Closed

Benchmark client 可以提供一下吗 #1

SpikeWong opened this issue Apr 25, 2023 · 18 comments

Comments

@SpikeWong
Copy link

No description provided.

@lxzan
Copy link
Owner

lxzan commented Apr 25, 2023

tcpkali , 可能需要自己编译
https://github.com/satori-com/tcpkali

@lxzan
Copy link
Owner

lxzan commented Apr 25, 2023

这个项目里面的gws需要更新到最新版本

@SpikeWong
Copy link
Author

SpikeWong commented Apr 25, 2023

我没怎么配置过 grafana dashboard, 请教下 assets 目录下的那些 grafana 模板该怎么搭呢

@lxzan
Copy link
Owner

lxzan commented Apr 25, 2023

先安装配置Prometheus, 然后在从 assets/config/grafana-dashboard.json 复制配置并导入到Grafana

@SpikeWong
Copy link
Author

压完了,我用 https://github.com/plantain-00/ws-benchmark 压的。其中一个场景是瞬时并发 3500,总共请求 35000 次,payload 是一个 3kb 大小的文本,这个场景下 lxzan 的稳定性(成功请求数/总请求数)确实比别的框架好

框架 稳定性 P99 延迟(ms) MAX 内存(MB)
https://github.com/gobwas/ws 2.2% N/A N/A
https://github.com/gorilla/websocket 85% 0.208.5 32.5
https://github.com/lxzan/gws 100% 0.234.5 69
https://github.com/nhooyr/websocket 11.6% N/A N/A

@lxzan
Copy link
Owner

lxzan commented Apr 27, 2023

升级gws到最新版本, 使用NewServer启动服务, 内存占用可以降低一大截

@lxzan
Copy link
Owner

lxzan commented Apr 27, 2023

用go写一个wsbench, iops还会高很多

image

@lxzan
Copy link
Owner

lxzan commented Apr 27, 2023

没想到gorilla也有一些请求失败,它的实现比其他两个要好些

@SpikeWong
Copy link
Author

我想问下在 handler 里面单独起一个 goroutine 来处理 websocket 写入和读取事件好,还是直接在原来的 handler 里面一个 for 循环就 ok 呢? 两者在性能上和稳定性上会差距很大吗?

@lxzan
Copy link
Owner

lxzan commented Apr 28, 2023

我想问下在 handler 里面单独起一个 goroutine 来处理 websocket 写入和读取事件好,还是直接在原来的 handler 里面一个 for 循环就 ok 呢? 两者在性能上和稳定性上会差距很大吗?

性能差不多. 开启新的goroutine是为了让请求上下文顺利被gc, 内存方面稍微好点.

@lxzan
Copy link
Owner

lxzan commented Apr 28, 2023

实际上有些东西就是gc不了, 所以我后面自己实现了http parser, 内存占用降低了一大截

golang/go#59567

@SpikeWong
Copy link
Author

佩服,感觉你对这块的理解很深呀。

@lxzan
Copy link
Owner

lxzan commented Apr 28, 2023

在开发gws的过程中学到了很多东西

@SpikeWong
Copy link
Author

是什么样的契机想让你开发这个的?

@lxzan
Copy link
Owner

lxzan commented Apr 28, 2023

是什么样的契机想让你开发这个的?

因为我觉得流行的这些golang websocket package api设计得不好, 不如js websocket event简单明了. 后面发现它们性能也不够好.

@lxzan
Copy link
Owner

lxzan commented May 8, 2023

可以试试我写的这个压测工具, https://github.com/lxzan/wsbench

@SpikeWong
Copy link
Author

哥真的挺高产的,啥公司有这么多的自己的时间?

@lxzan
Copy link
Owner

lxzan commented May 11, 2023

哥真的挺高产的,啥公司有这么多的自己的时间?

😂

@lxzan lxzan closed this as completed Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants