V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lbfeng
V2EX  ›  问与答

uwsgi worker 不工作

  •  
  •   lbfeng · 2019-11-22 03:06:38 +08:00 · 1627 次点击
    这是一个创建于 1857 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 kubernetes 起了 2 个 uwsgi 的 pod,每个都有 46 个 worker,listen queue 是 128。

    我起了 256 个线程做并发测试,发现一个 pod 没有问题,另一个 pod 只有 worker1 和 worker2 在工作。

    服务器 48 核 cpu

    [uwsgi]
    module = uwsgi_xx:xxx
    strict = true
    
    master = true
    processes = 48
    listen = 128
    
    http = 0.0.0.0:8093
    vacuum = true
    
    enable-threads = true
    single-interpreter = true
    need-app = true
    
    die-on-term = true
    
    disable-logging = false
    log-4xx = false
    log-5xx = true
    logformat = [worker_id: %(wid)|req: -/-] %(addr) [%(ctime)] %(method) %(uri) => generated %(rsize) bytes in %(msecs) msecs using %(core)
    
    
    [uWSGI] getting INI configuration from chatbot.ini
    *** Starting uWSGI 2.0.18 (64bit) on [Thu Nov 21 18:46:55 2019] ***
    compiled with version: 7.4.0 on 16 November 2019 00:13:59
    os: Linux-4.15.0-1054-aws #56-Ubuntu SMP Thu Nov 7 16:15:59 UTC 2019
    nodename: chatbot-6544775c9f-l449f
    machine: x86_64
    clock source: unix
    detected number of CPU cores: 48
    current working directory: /code
    detected binary path: /usr/local/bin/uwsgi
    !!! no internal routing support, rebuild with pcre support !!!
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
    your memory page size is 4096 bytes
    detected max file descriptor number: 1048576
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uWSGI http bound on 0.0.0.0:8093 fd 4
    uwsgi socket 0 bound to TCP address 127.0.0.1:38013 (port auto-assigned) fd 3
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
    Python version: 3.6.8 (default, Oct  7 2019, 12:59:55)  [GCC 8.3.0]
    Python main interpreter initialized at 0x5600b36b6a80
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
    python threads support enabled
    your server socket listen backlog is limited to 128 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 3427240 bytes (3346 KB) for 46 cores
    *** Operational MODE: preforking ***
    Starting chatbot
    WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x5600b36b6a80 pid: 1 (default app)
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
    spawned uWSGI master process (pid: 1)
    spawned uWSGI worker 1 (pid: 106, cores: 1)
    spawned uWSGI worker 2 (pid: 107, cores: 1)
    spawned uWSGI worker 3 (pid: 108, cores: 1)
    spawned uWSGI worker 4 (pid: 109, cores: 1)
    spawned uWSGI worker 5 (pid: 110, cores: 1)
    spawned uWSGI worker 6 (pid: 111, cores: 1)
    spawned uWSGI worker 7 (pid: 112, cores: 1)
    spawned uWSGI worker 8 (pid: 113, cores: 1)
    spawned uWSGI worker 9 (pid: 114, cores: 1)
    spawned uWSGI worker 10 (pid: 115, cores: 1)
    spawned uWSGI worker 11 (pid: 116, cores: 1)
    spawned uWSGI worker 12 (pid: 117, cores: 1)
    spawned uWSGI worker 13 (pid: 118, cores: 1)
    spawned uWSGI worker 14 (pid: 119, cores: 1)
    spawned uWSGI worker 15 (pid: 120, cores: 1)
    spawned uWSGI worker 16 (pid: 121, cores: 1)
    spawned uWSGI worker 17 (pid: 122, cores: 1)
    spawned uWSGI worker 18 (pid: 123, cores: 1)
    spawned uWSGI worker 19 (pid: 124, cores: 1)
    spawned uWSGI worker 20 (pid: 125, cores: 1)
    spawned uWSGI worker 21 (pid: 126, cores: 1)
    spawned uWSGI worker 22 (pid: 127, cores: 1)
    spawned uWSGI worker 23 (pid: 128, cores: 1)
    spawned uWSGI worker 24 (pid: 129, cores: 1)
    spawned uWSGI worker 25 (pid: 130, cores: 1)
    spawned uWSGI worker 26 (pid: 131, cores: 1)
    spawned uWSGI worker 27 (pid: 132, cores: 1)
    spawned uWSGI worker 28 (pid: 133, cores: 1)
    spawned uWSGI worker 29 (pid: 134, cores: 1)
    spawned uWSGI worker 30 (pid: 135, cores: 1)
    spawned uWSGI worker 31 (pid: 136, cores: 1)
    spawned uWSGI worker 32 (pid: 137, cores: 1)
    spawned uWSGI worker 33 (pid: 138, cores: 1)
    spawned uWSGI worker 34 (pid: 139, cores: 1)
    spawned uWSGI worker 35 (pid: 140, cores: 1)
    spawned uWSGI worker 36 (pid: 141, cores: 1)
    spawned uWSGI worker 37 (pid: 142, cores: 1)
    spawned uWSGI worker 38 (pid: 143, cores: 1)
    spawned uWSGI worker 39 (pid: 144, cores: 1)
    spawned uWSGI worker 40 (pid: 145, cores: 1)
    spawned uWSGI worker 41 (pid: 146, cores: 1)
    spawned uWSGI worker 42 (pid: 147, cores: 1)
    spawned uWSGI worker 43 (pid: 148, cores: 1)
    spawned uWSGI worker 44 (pid: 149, cores: 1)
    spawned uWSGI worker 45 (pid: 150, cores: 1)
    spawned uWSGI worker 46 (pid: 151, cores: 1)
    spawned uWSGI http 1 (pid: 152)
    
    [worker_id: 1|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:02 2019] POST /dialog => generated 947 bytes in 251 msecs using 0
    [worker_id: 2|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:02 2019] POST /dialog => generated 949 bytes in 278 msecs using 0
    [worker_id: 1|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:03 2019] POST /dialog => generated 949 bytes in 250 msecs using 0
    [worker_id: 2|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:03 2019] POST /dialog => generated 948 bytes in 268 msecs using 0
    [worker_id: 1|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:03 2019] POST /dialog => generated 949 bytes in 244 msecs using 0
    

    另一个正常

    [worker_id: 44|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:06 2019] POST /dialog => generated 1697 bytes in 322 msecs using 0
    [worker_id: 43|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:06 2019] POST /dialog => generated 1697 bytes in 277 msecs using 0
    [worker_id: 46|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 2176 bytes in 354 msecs using 0
    [worker_id: 45|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 1696 bytes in 358 msecs using 0
    [worker_id: 44|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 1697 bytes in 393 msecs using 0
    [worker_id: 37|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 2176 bytes in 487 msecs using 0
    [worker_id: 46|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 1697 bytes in 275 msecs using 0
    [worker_id: 43|req: -/-] 10.244.0.1 [Thu Nov 21 18:49:07 2019] POST /dialog => generated 1696 bytes in 258 msecs using 0
    

    这种情况大家有遇到过吗

    1 条回复    2019-11-22 03:29:49 +08:00
    lbfeng
        1
    lbfeng  
    OP
       2019-11-22 03:29:49 +08:00
    似乎一个 worker 占了一个 cpu,多出来的 worker 就没有工作。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2939 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 14:02 · PVG 22:02 · LAX 06:02 · JFK 09:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.