Merge pull request #1488 from bigchaindb/nothreads

Disable threads in web workers
This commit is contained in:
libscott 2017-05-31 14:36:44 +02:00 committed by GitHub
commit 1d96768db8
4 changed files with 7 additions and 8 deletions

View File

@ -62,7 +62,6 @@ config = {
'loglevel': logging.getLevelName(
log_config['handlers']['console']['level']).lower(),
'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': {
'host': os.environ.get('BIGCHAINDB_WSSERVER_HOST') or 'localhost',

View File

@ -48,7 +48,7 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication):
return self.application
def create_app(*, debug=False, threads=4):
def create_app(*, debug=False, threads=1):
"""Return an instance of the Flask application.
Args:
@ -102,7 +102,10 @@ def create_server(settings):
settings['workers'] = (multiprocessing.cpu_count() * 2) + 1
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'
app = create_app(debug=settings.get('debug', False),

View File

@ -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).
@ -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)
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). Each worker process has a single thread. The HTTP server will be able to handle `server.workers` requests simultaneously.
**Example using environment variables**
```text
@ -168,7 +168,6 @@ export BIGCHAINDB_SERVER_THREADS=5
"bind": "0.0.0.0:9984",
"loglevel": "debug",
"workers": 5,
"threads": 5
}
```
@ -178,7 +177,6 @@ export BIGCHAINDB_SERVER_THREADS=5
"bind": "localhost:9984",
"loglevel": "info",
"workers": null,
"threads": null
}
```

View File

@ -209,7 +209,6 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
'loglevel': logging.getLevelName(
log_config['handlers']['console']['level']).lower(),
'workers': None,
'threads': None,
},
'wsserver': {
'host': WSSERVER_HOST,