Skip to content

Commit

Permalink
Merge pull request #3048 from ktleung2017/add-keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Gonzalez-Martin authored Apr 12, 2021
2 parents 2858011 + 9ccd636 commit 357ba4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/python/python_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
Expand Down
8 changes: 8 additions & 0 deletions python/seldon_core/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 357ba4d

Please sign in to comment.