unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.47k stars 692 forks source link

CPU usage remains constant #1954

Open felocru opened 5 years ago

felocru commented 5 years ago

Hi, I have a geolocation monitoring system for several vehicles through uwsgi-gevent to 1000 cores. The number of users to monitor varies depending on the day and time. However, the use of the CPU remains constant.

When I restart the server, CPU usage remains between 1% and 2%, so it remains for a few hours. Then in a matter of seconds it grows until it reaches 83%, and so it remains constant. image

This is my information:

*** Starting uWSGI 2.0.17.1 (64bit) on [Sun Dec 30 14:17:21 2018] ***
compiled with version: 5.4.0 20160609 on 08 December 2018 01:24:01
os: Linux-4.15.0-1026-gcp #27~16.04.1-Ubuntu SMP Fri Dec 7 09:59:47 UTC 2018
nodename: instance-1
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /
detected binary path: /bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home..
your processes number limit is 7074
your memory page size is 4096 bytes
detected max file descriptor number: 1024
- async cores set to 1000 - fd table size: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 inherited UNIX address /home/voyserver.sock fd 3
Python version: 3.5.2 (default, Nov 12 2018, 13:43:14)  [GCC 5.4.0 20160609]
Set PythonHome to /home/voyserver-3B8mbtHy
Python main interpreter initialized at 0x15d1660
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 21036928 bytes (20543 KB) for 1000 cores
*** Operational MODE: async ***
/home/virtualenvs/voyserver-3B8mbtHy/lib/python3.5/site-packages/sentry_sdk/_compat.py:78: Warning: We detected the use of uwsgi with disabled threads.  This will cause issues with the transport you are trying to use.  Please enable threading for uwsgi.  (Enable the "enable-threads" flag).
  "We detected the use of uwsgi with disabled threads.  "
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x15d1660 pid: 3236 (default app)
*** uWSGI is running in multiple interpreter mode ***
gracefully (RE)spawned uWSGI master process (pid: 3236)
spawned uWSGI worker 1 (pid: 19209, cores: 1000)
*** running gevent loop engine [addr:0x48e4f0] ***

Could someone give me an orientation on what could be happening?
Thank you
felocru commented 5 years ago

I have more info: Thu Jan 3 10:21:11 2019 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET /favicon.ico OSError: write error

Apparently after these messages the CPU started to rise.

I do not know if that is related to this:

OSError: unable to complete websocket handshake
  File "engineio/middleware.py", line 47, in __call__
    return self.engineio_app.handle_request(environ, start_response)
  File "socketio/server.py", line 360, in handle_request
    return self.eio.handle_request(environ, start_response)
  File "engineio/server.py", line 282, in handle_request
    environ, start_response)
  File "engineio/socket.py", line 103, in handle_get_request
    start_response)
  File "engineio/socket.py", line 145, in _upgrade_websocket
    return ws(environ, start_response)
  File "engineio/async_gevent_uwsgi.py", line 35, in __call__
    uwsgi.websocket_handshake()

I would appreciate any help you can give me.

bgehman commented 5 years ago

See possibly related: https://github.com/unbit/uwsgi/issues/1010#issuecomment-452935459 if you using pymongo...

Per your log:

/home/virtualenvs/voyserver-3B8mbtHy/lib/python3.5/site-packages/sentry_sdk/_compat.py:78: Warning: We detected the use of uwsgi with disabled threads.  This will cause issues with the transport you are trying to use.  Please enable threading for uwsgi.  (Enable the "enable-threads" flag).
  "We detected the use of uwsgi with disabled threads.  "

Suggest you enable-threads in uwsgi and see if that sorts it out. See: https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#a-note-on-python-threads