mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
disable threads in web workers
This commit is contained in:
parent
b6ec3e5f5c
commit
5de15c33ec
@ -62,7 +62,6 @@ config = {
|
|||||||
'loglevel': logging.getLevelName(
|
'loglevel': logging.getLevelName(
|
||||||
log_config['handlers']['console']['level']).lower(),
|
log_config['handlers']['console']['level']).lower(),
|
||||||
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
||||||
'threads': None, # if none, the value will be cpu_count * 2 + 1
|
|
||||||
},
|
},
|
||||||
'wsserver': {
|
'wsserver': {
|
||||||
'host': os.environ.get('BIGCHAINDB_WSSERVER_HOST') or 'localhost',
|
'host': os.environ.get('BIGCHAINDB_WSSERVER_HOST') or 'localhost',
|
||||||
|
@ -48,7 +48,7 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication):
|
|||||||
return self.application
|
return self.application
|
||||||
|
|
||||||
|
|
||||||
def create_app(*, debug=False, threads=4):
|
def create_app(*, debug=False, threads=1):
|
||||||
"""Return an instance of the Flask application.
|
"""Return an instance of the Flask application.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -102,7 +102,10 @@ def create_server(settings):
|
|||||||
settings['workers'] = (multiprocessing.cpu_count() * 2) + 1
|
settings['workers'] = (multiprocessing.cpu_count() * 2) + 1
|
||||||
|
|
||||||
if not settings.get('threads'):
|
if not settings.get('threads'):
|
||||||
settings['threads'] = (multiprocessing.cpu_count() * 2) + 1
|
# Note: Threading is not recommended currently, as the frontend workload
|
||||||
|
# is largely CPU bound and parallisation across Python threads makes it
|
||||||
|
# slower.
|
||||||
|
settings['threads'] = 1
|
||||||
|
|
||||||
settings['logger_class'] = 'bigchaindb.log.loggers.HttpServerLogger'
|
settings['logger_class'] = 'bigchaindb.log.loggers.HttpServerLogger'
|
||||||
app = create_app(debug=settings.get('debug', False),
|
app = create_app(debug=settings.get('debug', False),
|
||||||
|
@ -142,7 +142,7 @@ If you used `bigchaindb -y configure mongodb` to create a default local config f
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## server.bind, server.loglevel, server.workers & server.threads
|
## server.bind, server.loglevel & server.workers
|
||||||
|
|
||||||
These settings are for the [Gunicorn HTTP server](http://gunicorn.org/), which is used to serve the [HTTP client-server API](../http-client-server-api.html).
|
These settings are for the [Gunicorn HTTP server](http://gunicorn.org/), which is used to serve the [HTTP client-server API](../http-client-server-api.html).
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ These settings are for the [Gunicorn HTTP server](http://gunicorn.org/), which i
|
|||||||
[Gunicorn's documentation](http://docs.gunicorn.org/en/latest/settings.html#loglevel)
|
[Gunicorn's documentation](http://docs.gunicorn.org/en/latest/settings.html#loglevel)
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
`server.workers` is [the number of worker processes](http://docs.gunicorn.org/en/stable/settings.html#workers) for handling requests. If `None` (the default), the value will be (cpu_count * 2 + 1). `server.threads` is [the number of threads-per-worker](http://docs.gunicorn.org/en/stable/settings.html#threads) for handling requests. If `None` (the default), the value will be (cpu_count * 2 + 1). The HTTP server will be able to handle `server.workers` * `server.threads` requests simultaneously.
|
`server.workers` is [the number of worker processes](http://docs.gunicorn.org/en/stable/settings.html#workers) for handling requests. If `None` (the default), the value will be (cpu_count * 2 + 1). If `None` (the default), the value will be 1. The HTTP server will be able to handle `server.workers` requests simultaneously.
|
||||||
|
|
||||||
**Example using environment variables**
|
**Example using environment variables**
|
||||||
```text
|
```text
|
||||||
@ -168,7 +168,6 @@ export BIGCHAINDB_SERVER_THREADS=5
|
|||||||
"bind": "0.0.0.0:9984",
|
"bind": "0.0.0.0:9984",
|
||||||
"loglevel": "debug",
|
"loglevel": "debug",
|
||||||
"workers": 5,
|
"workers": 5,
|
||||||
"threads": 5
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -178,7 +177,6 @@ export BIGCHAINDB_SERVER_THREADS=5
|
|||||||
"bind": "localhost:9984",
|
"bind": "localhost:9984",
|
||||||
"loglevel": "info",
|
"loglevel": "info",
|
||||||
"workers": null,
|
"workers": null,
|
||||||
"threads": null
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -209,7 +209,6 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
'loglevel': logging.getLevelName(
|
'loglevel': logging.getLevelName(
|
||||||
log_config['handlers']['console']['level']).lower(),
|
log_config['handlers']['console']['level']).lower(),
|
||||||
'workers': None,
|
'workers': None,
|
||||||
'threads': None,
|
|
||||||
},
|
},
|
||||||
'wsserver': {
|
'wsserver': {
|
||||||
'host': WSSERVER_HOST,
|
'host': WSSERVER_HOST,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user