From 8797030a085dadafcb5513ee894956f502d00d42 Mon Sep 17 00:00:00 2001 From: ktleunghk01 Date: Thu, 11 Mar 2021 18:05:51 +0800 Subject: [PATCH 1/3] Add keepalive --- python/seldon_core/microservice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/seldon_core/microservice.py b/python/seldon_core/microservice.py index 0aba339796..bae6973b95 100644 --- a/python/seldon_core/microservice.py +++ b/python/seldon_core/microservice.py @@ -266,6 +266,12 @@ def main(): default=int(os.environ.get("GUNICORN_MAX_REQUESTS_JITTER", "0")), help="Maximum random jitter to add to max-requests.", ) + parser.add_argument( + "--keepalive", + type=int, + default=int(os.environ.get("GUNICORN_KEEPALIVE", "2")), + help="The number of seconds to wait for requests on a Keep-Alive connection.", + ) parser.add_argument( "--single-threaded", @@ -406,6 +412,7 @@ def rest_prediction_server(): "max_requests_jitter": args.max_requests_jitter, "post_worker_init": post_worker_init, "worker_exit": partial(worker_exit, seldon_metrics=seldon_metrics), + "keepalive": args.keepalive, } if args.pidfile is not None: options["pidfile"] = args.pidfile @@ -468,6 +475,7 @@ def rest_metrics_server(): "max_requests": args.max_requests, "max_requests_jitter": args.max_requests_jitter, "post_worker_init": post_worker_init, + "keepalive": args.keepalive, } if args.pidfile is not None: options["pidfile"] = args.pidfile From f42d70af46b46dc3e5682de163b42014b2a7f370 Mon Sep 17 00:00:00 2001 From: ktleung2017 Date: Tue, 16 Mar 2021 09:54:47 +0800 Subject: [PATCH 2/3] doc: add gunicorn keepalive --- doc/source/python/python_server.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/python/python_server.md b/doc/source/python/python_server.md index bd40a397a9..0b871efd1a 100644 --- a/doc/source/python/python_server.md +++ b/doc/source/python/python_server.md @@ -193,6 +193,7 @@ Python Server can be configured using environmental variables or command line fl | `--threads` | `GUNICORN_THREADS` | `10` | Number of threads to run per Gunicorn worker. | | `--max-requests` | `GUNICORN_MAX_REQUESTS` | `0` | Maximum number of requests gunicorn worker will process before restarting. | | `--max-requests-jitter` | `GUNICORN_MAX_REQUESTS_JITTER` | `0` | Maximum random jitter to add to max-requests. | +| `--keepalive` | `GUNICORN_KEEPALIVE ` | `2` | The number of seconds to wait for requests on a Keep-Alive connection. | | `--access-log` | `GUNICORN_ACCESS_LOG` | `false` | Enable gunicorn access log. | | `--pidfile` | N/A | None | A file path to use for the Gunicorn PID file. | | `--single-threaded` | `FLASK_SINGLE_THREADED` | `0` | Force the Flask app to run single-threaded. Also applies to Gunicorn. Can be `0` or `1`. | From 9ccd636820aa586912c79e327cff61c47376a11e Mon Sep 17 00:00:00 2001 From: ktleung2017 Date: Tue, 16 Mar 2021 09:56:14 +0800 Subject: [PATCH 3/3] doc: add gunicorn keepalive --- doc/source/python/python_server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/python/python_server.md b/doc/source/python/python_server.md index 0b871efd1a..46ce15bfe1 100644 --- a/doc/source/python/python_server.md +++ b/doc/source/python/python_server.md @@ -193,7 +193,7 @@ Python Server can be configured using environmental variables or command line fl | `--threads` | `GUNICORN_THREADS` | `10` | Number of threads to run per Gunicorn worker. | | `--max-requests` | `GUNICORN_MAX_REQUESTS` | `0` | Maximum number of requests gunicorn worker will process before restarting. | | `--max-requests-jitter` | `GUNICORN_MAX_REQUESTS_JITTER` | `0` | Maximum random jitter to add to max-requests. | -| `--keepalive` | `GUNICORN_KEEPALIVE ` | `2` | The number of seconds to wait for requests on a Keep-Alive connection. | +| `--keepalive` | `GUNICORN_KEEPALIVE` | `2` | The number of seconds to wait for requests on a Keep-Alive connection. | | `--access-log` | `GUNICORN_ACCESS_LOG` | `false` | Enable gunicorn access log. | | `--pidfile` | N/A | None | A file path to use for the Gunicorn PID file. | | `--single-threaded` | `FLASK_SINGLE_THREADED` | `0` | Force the Flask app to run single-threaded. Also applies to Gunicorn. Can be `0` or `1`. |