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

[fix] solve concurrent coroutine request problem #11

Closed
ronething-bot opened this issue Aug 5, 2022 · 12 comments
Closed

[fix] solve concurrent coroutine request problem #11

ronething-bot opened this issue Aug 5, 2022 · 12 comments
Labels

Comments

@ronething-bot
Copy link
Contributor

fix #10

@ronething-bot
Copy link
Contributor Author

@ronething-bot
Copy link
Contributor Author

@ronething
Copy link
Member

  • 可新开分支进行测试,加锁理论上对分数有一定的影响。

@ronething ronething changed the title [fix] 并发协程请求问题解决 [fix] solve concurrent coroutine request problem Aug 7, 2022
@ronething
Copy link
Member

ronething commented Aug 13, 2022

  • 需要注意一点:client-go 内部有实现退避重试算法,所以假如开 1000 个协程,edge-proxy 计算出来的 count 不一定是 1000,即使使用了 atomic add.

edge-proxy

image

benchmark

image

client-go request.go

image

目前测试 200 协程没问题,500 协程有一部分(几十个)会 error,1000 的话就 error 的更多。

  • 还有 klog.Infof 可能成为瓶颈,可以通过注释或者提高级别 V(5) 进行打印

image

  • list resource usage 可参考 benchmark ,目前是可以考虑同时开 25 个左右的协程,达到 460+ tps

@ronething
Copy link
Member

详见 commit: ebaec51

@ronething
Copy link
Member

并发 docker image 目前评测资源分:48917.3797(submit time: 2022-08-13 15:56:54),当然也可以再测试几次,先 close,主要是为了验证并发下的请求 count 一致性问题以及类似 redis 缓存击穿问题。

缓存击穿: 一个热点的Key,有大并发集中对其进行访问,突然间这个Key失效了,导致大并发全部打在数据库上。

@ronething
Copy link
Member

47870.4015(submit time: 2022-08-13 16:12:59)

@ronething
Copy link
Member

49928.8520(submit time: 2022-08-13 18:45:43)

@ronething-bot
Copy link
Contributor Author

  • 先本地构建二进制,再复制到镜像:c9a4e88

@ronething-bot
Copy link
Contributor Author

ronething-bot commented Aug 19, 2022

  • 有趣的是,在 linux 上暂时没有测试出 no buffer available 的情况:

4k or 8k 表示 net/http/server.go newBufferSize 的 size 大小

4k nums: 10, count is 24177, tps: 402/s
4k nums: 20, count is 26753, tps: 445/s
4k nums: 30, count is 27273, tps: 454/s
4k nums: 50, count is 28636, tps: 477/s
4k nums: 10000, count is 38265, tps: 637/s

8k nums: 10, count is 25842, tps: 430/s
8k nums: 20, count is 28038, tps: 467/s
8k nums: 50, count is 28001, tps: 466/s
8k nums: 100, count is 29345, tps: 489/s
8k nums: 1000, count is 31493, tps: 524/s

@ronething-bot
Copy link
Contributor Author

ronething-bot commented Aug 19, 2022

  • 目前主要呈现的瓶颈在于 rw.Write(无论是并发安全版本还是单协程版本),通过修改 go 源码(newbuffersize)重新编译效果不是很显著,考虑躺平。
  • 经过两天测试,tag: v0.0.37 目前最高是 13w 左右(130075.7496)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants