V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
heliotrope
V2EX  ›  程序员

参照 ShenYu 也 WebFlux 用 WebClient 转发 性能一直不行 终于找到问题了

  •  
  •   heliotrope · 20 天前 · 1122 次点击
    # wrk -c600 -t4 -T10 -d180 --latency http://192.168.101.233:9195/gateway/sys/api
    Running 3m test @ http://192.168.101.233:9195/gateway/sys/api
    4 threads and 600 connections
    Thread Stats Avg Stdev Max +/- Stdev
    Latency 3.17s 3.10s 9.84s 76.92%
    Req/Sec 473.03 366.87 1.79k 55.65%
    Latency Distribution
    50% 2.32s
    75% 5.89s
    90% 7.60s
    99% 9.78s
    35926 requests in 3.00m, 8.81MB read
    Socket errors: connect 0, read 0, write 2669, timeout 712
    Requests/sec: 199.51
    Transfer/sec: 50.07KB

    去掉日志

    # wrk -c600 -t4 -T10 -d180 --latency http://192.168.101.233:9195/gateway/sys/api
    Running 3m test @ http://192.168.101.233:9195/gateway/sys/api
    4 threads and 600 connections
    Thread Stats Avg Stdev Max +/- Stdev
    Latency 89.75ms 36.12ms 442.22ms 89.28%
    Req/Sec 1.71k 513.97 2.94k 70.65%
    Latency Distribution
    50% 78.67ms
    75% 93.57ms
    90% 128.32ms
    99% 252.93ms
    1224552 requests in 3.00m, 300.13MB read
    Socket errors: connect 0, read 0, write 152, timeout 0
    Requests/sec: 6799.68
    Transfer/sec: 1.67MB



    感情是在等着写日志呢 查了好久的问题...
    6 条回复    2024-09-05 18:10:51 +08:00
    sagaxu
        1
    sagaxu  
       20 天前
    日志同步写入日志服务了?正常写日志性能影响应该很小
    diagnostics
        2
    diagnostics  
       20 天前
    Log 都不是 async 的吗?至少 logback 是
    heliotrope
        3
    heliotrope  
    OP
       20 天前
    @sagaxu
    没有 就正常的 logback 写文件和 console
    我实测性能影响特别大 关了提升 30 倍打底
    我刚搜了一下很多写 日志拖垮系统的文章
    并且 ShenYu 的基准测试说明里面
    特地写了一条 日志级别 WARN
    我用的是 INFO 就采坑了 排查了好久才发现
    heliotrope
        4
    heliotrope  
    OP
       20 天前
    @diagnostics
    用的就是 logback
    heliotrope
        5
    heliotrope  
    OP
       20 天前
    @diagnostics
    可能打印的数量少不影响吧
    我的转发目标接口也是 WebFlux 写的 但是只打印了一行日志
    性能就没什么问题

    转发接口打印了十几行日志
    性能掉了 30 倍以上
    sagaxu
        6
    sagaxu  
       20 天前
    @heliotrope 不要写 Console ,它是同步的,单线程阻塞的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2880 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 14:24 · PVG 22:24 · LAX 07:24 · JFK 10:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.