Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Add gunicorn timeout #220

Merged
merged 13 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ For notebook examples, see: [Amazon SageMaker Examples](https://github.com/awsla
3. [Running the tests](#running-the-tests)
4. [Pre/Post-Processing](#pre/post-processing)
5. [Deploying a TensorFlow Serving Model](#deploying-a-tensorflow-serving-model)
6. [Deploying to Multi-Model Endpoint](#deploying-to-multi-model-endpoint)
6. [Enable Batching](#enabling-batching)
7. [Other Configurable Environment Variables](#other-configurable-environment-variables)
8. [Deploying to Multi-Model Endpoint](#deploying-to-multi-model-endpoint)

## Getting Started

Expand Down Expand Up @@ -612,6 +614,16 @@ SAGEMAKER_TFS_NUM_BATCH_THREADS="16"
SAGEMAKER_TFS_MAX_ENQUEUED_BATCHES="10000"
```

## Other Configurable Environment Variables
The following environment variables can be set on a SageMaker Model or Transform Job if further configuration is required:

```bash
# Configures how long to wait in seconds for GUnicorn
# to finish starting up before timing out.
# Defaults to 30.
SAGEMAKER_GUNICORN_SETUP_TIMEOUT_SECONDS="60"
```

## Deploying to Multi-Model Endpoint

SageMaker TensorFlow Serving container (version 1.5.0 and 2.1.0, CPU) now supports Multi-Model Endpoint. With this feature, you can deploy different models (not just different versions of a model) to a single endpoint.
Expand Down
5 changes: 4 additions & 1 deletion docker/build_artifacts/sagemaker/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def __init__(self):
self._tfs_inter_op_parallelism = os.environ.get("SAGEMAKER_TFS_INTER_OP_PARALLELISM", 0)
self._tfs_intra_op_parallelism = os.environ.get("SAGEMAKER_TFS_INTRA_OP_PARALLELISM", 0)
self._gunicorn_worker_class = os.environ.get("SAGEMAKER_GUNICORN_WORKER_CLASS", "gevent")
self._gunicorn_setup_timeout_seconds = int(os.environ.get(
"SAGEMAKER_GUNICORN_SETUP_TIMEOUT_SECONDS", 30
))

if os.environ.get("OMP_NUM_THREADS") is None:
os.environ["OMP_NUM_THREADS"] = "1"
Expand Down Expand Up @@ -449,7 +452,7 @@ def start(self):
self._setup_gunicorn()
self._start_gunicorn()
# make sure gunicorn is up
with self._timeout(seconds=30):
with self._timeout(seconds=self._gunicorn_setup_timeout_seconds):
self._wait_for_gunicorn()

self._start_nginx()
Expand Down