From 8b4a424df105313fc7d36ebf29b9ecdcb238fd95 Mon Sep 17 00:00:00 2001 From: David McDonald Date: Fri, 12 Jun 2020 14:52:04 +0100 Subject: [PATCH] Tidy up --- app/__init__.py | 13 ++++++------- gunicorn_config.py | 2 +- manifest.yml.j2 | 19 +------------------ tests/app/v2/test_errors.py | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index aefc92d08..62fe06c50 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -68,6 +68,11 @@ clients = Clients() api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user) authenticated_service = LocalProxy(lambda: _request_ctx_stack.top.authenticated_service) +CONCURRENT_REQUESTS = Gauge( + 'concurrent_web_request_count', + 'How many concurrent requests are currently being served', +) + def create_app(application): from app.config import configs @@ -263,11 +268,6 @@ def register_v2_blueprints(application): def init_app(app): - CONCURRENT_REQUESTS = Gauge( - 'concurrent_web_request_count', - 'How many concurrent requests are currently being served', - ) - @app.before_request def record_user_agent(): statsd_client.incr("user-agent.{}".format(process_user_agent(request.headers.get('User-Agent', None)))) @@ -334,7 +334,7 @@ def setup_sqlalchemy_events(app): TOTAL_DB_CONNECTIONS = Gauge( 'db_connection_total_connected', - 'How many db connections are currently held (potentially idel) by the server', + 'How many db connections are currently held (potentially idle) by the server', ) TOTAL_CHECKED_OUT_DB_CONNECTIONS = Gauge( @@ -381,7 +381,6 @@ def setup_sqlalchemy_events(app): } # celery apps elif current_task: - print(current_task) connection_record.info['request_data'] = { 'method': 'celery', 'host': current_app.config['NOTIFY_APP_NAME'], # worker name diff --git a/gunicorn_config.py b/gunicorn_config.py index 87db63ded..d32eaba2d 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -7,7 +7,7 @@ from gds_metrics.gunicorn import child_exit # noqa workers = 4 worker_class = "eventlet" -worker_connections = 30 +worker_connections = 256 errorlog = "/home/vcap/logs/gunicorn_error.log" bind = "0.0.0.0:{}".format(os.getenv("PORT")) statsd_host = "{}:8125".format(os.getenv("STATSD_HOST")) diff --git a/manifest.yml.j2 b/manifest.yml.j2 index 42a21862d..80c991309 100644 --- a/manifest.yml.j2 +++ b/manifest.yml.j2 @@ -25,23 +25,6 @@ }, }, - 'notify-api-loadtesting': { - 'comments': 'DELETE ME LATER', - 'NOTIFY_APP_NAME': 'api', - 'disk_quota': '2G', - 'sqlalchemy_pool_size': 30, - 'routes': { - 'staging': [], - }, - 'health-check-type': 'port', - 'health-check-invocation-timeout': 3, - 'instances': { - 'preview': None, - 'staging': 4, - 'production': None - }, - }, - 'notify-delivery-celery-beat': {'memory': '128M'}, 'notify-delivery-worker-jobs': {}, 'notify-delivery-worker-research': {}, @@ -87,7 +70,7 @@ applications: services: - notify-db - logit-ssl-syslog-drain - {% if CF_APP in ('notify-api', 'notify-api-loadtesting') %} + {% if CF_APP == 'notify-api' %} - notify-prometheus {% endif %} diff --git a/tests/app/v2/test_errors.py b/tests/app/v2/test_errors.py index 7c1c6b09a..390afb605 100644 --- a/tests/app/v2/test_errors.py +++ b/tests/app/v2/test_errors.py @@ -3,7 +3,7 @@ from flask import url_for from sqlalchemy.exc import DataError -@pytest.fixture(scope='session') +@pytest.fixture(scope='function') def app_for_test(): import flask from flask import Blueprint