Skip to content

Commit c8da085

Browse files
authored
Improve API inter-process queue fairness (#1526)
1 parent 326df0c commit c8da085

File tree

26 files changed

+362
-77
lines changed

26 files changed

+362
-77
lines changed

cli/local/docker_spec.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package local
1919
import (
2020
"context"
2121
"fmt"
22-
"math"
2322
"path/filepath"
2423
"strings"
2524

@@ -92,9 +91,7 @@ func getAPIEnv(api *spec.API, awsClient *aws.Client) []string {
9291
"CORTEX_PROJECT_DIR="+_projectDir,
9392
"CORTEX_PROCESSES_PER_REPLICA="+s.Int32(api.Predictor.ProcessesPerReplica),
9493
"CORTEX_THREADS_PER_PROCESS="+s.Int32(api.Predictor.ThreadsPerProcess),
95-
// add 1 because it was required to achieve the target concurrency for 1 process, 1 thread
96-
"CORTEX_MAX_PROCESS_CONCURRENCY="+s.Int64(1+int64(math.Round(float64(consts.DefaultMaxReplicaConcurrency)/float64(api.Predictor.ProcessesPerReplica)))),
97-
"CORTEX_SO_MAX_CONN="+s.Int64(consts.DefaultMaxReplicaConcurrency+100), // add a buffer to be safe
94+
"CORTEX_MAX_REPLICA_CONCURRENCY="+s.Int32(api.Predictor.ProcessesPerReplica*api.Predictor.ThreadsPerProcess+1024), // allow a queue of 1024
9895
"AWS_REGION="+awsClient.Region,
9996
)
10097

dev/versions.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ Note: it's ok if example training notebooks aren't upgraded, as long as the expo
172172
* be careful not to update any of the versions for Inferentia that are not latest in `images/python-predictor-inf/Dockerfile`
173173
1. Rerun all examples and check their logs
174174

175+
## S6-overlay supervisor
176+
177+
1. Locate the `s6-overlay` installation in `images/python-predictor-*/Dockerfile`, `images/tensorflow-predictor/Dockerfile` and `images/onnx-predictor-*/Dockerfile`
178+
1. Update the version in each serving image with the newer one in https://github.com/just-containers/s6-overlay.
179+
180+
## Nginx
181+
182+
1. Run a base image of ubuntu that matches the version tag used for the serving images. The running command is `docker run -it --rm <base-image>`
183+
1. Run `apt update && apt-cache policy nginx`. Notice the latest minor version of nginx (e.g. `1.14`)
184+
1. Locate the `nginx` package in `images/python-predictor-*/Dockerfile`, `images/tensorflow-predictor/Dockerfile` and `images/onnx-predictor-*/Dockerfile`
185+
1. Update the version for all `nginx` appearances using the minor version from step 2 and add an asterisk at the end to denote any version (e.g. `1.14.*`)
186+
175187
## Istio
176188

177189
1. Find the latest [release](https://istio.io/latest/news/releases) and check the release notes (here are the [latest IstioOperator Options](https://istio.io/latest/docs/reference/config/istio.operator.v1alpha1/))

examples/sklearn/iris-classifier/cortex.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
model_type: classification
1313
compute:
1414
cpu: 0.2
15-
mem: 100M
15+
mem: 200M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
boto3
2+
scikit-learn==0.21.3

images/neuron-rtd/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ RUN yum install -y \
1313
aws-neuron-runtime-1.0.9592.0 \
1414
procps-ng-3.3.10-26.amzn2.x86_64 \
1515
gzip \
16-
tar
16+
tar \
17+
curl
1718

1819
ENV PATH="/opt/aws/neuron/bin:${PATH}"
1920

images/onnx-predictor-cpu/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ RUN apt-get update -qq && apt-get install -y -q \
99
unzip \
1010
zlib1g-dev \
1111
locales \
12+
nginx=1.14.* \
1213
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1314

15+
RUN cd /tmp/ && \
16+
curl -L --output s6-overlay-amd64-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer" && \
17+
cd - && \
18+
chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / && rm /tmp/s6-overlay-amd64-installer
19+
1420
RUN locale-gen en_US.UTF-8
1521
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.en LC_ALL=en_US.UTF-8
1622

@@ -68,4 +74,6 @@ COPY pkg/workloads/cortex/consts.py /src/cortex
6874
COPY pkg/workloads/cortex/lib /src/cortex/lib
6975
COPY pkg/workloads/cortex/serve /src/cortex/serve
7076

71-
ENTRYPOINT ["/src/cortex/serve/run.sh"]
77+
RUN mv /src/cortex/serve/init/bootloader.sh /etc/cont-init.d/bootloader.sh
78+
79+
ENTRYPOINT ["/init"]

images/onnx-predictor-gpu/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ RUN apt-get update -qq && apt-get install -y -q \
99
unzip \
1010
zlib1g-dev \
1111
locales \
12+
nginx=1.14.* \
1213
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1314

15+
RUN cd /tmp/ && \
16+
curl -L --output s6-overlay-amd64-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer" && \
17+
cd - && \
18+
chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / && rm /tmp/s6-overlay-amd64-installer
19+
1420
RUN locale-gen en_US.UTF-8
1521
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.en LC_ALL=en_US.UTF-8
1622

@@ -68,4 +74,6 @@ COPY pkg/workloads/cortex/consts.py /src/cortex
6874
COPY pkg/workloads/cortex/lib /src/cortex/lib
6975
COPY pkg/workloads/cortex/serve /src/cortex/serve
7076

71-
ENTRYPOINT ["/src/cortex/serve/run.sh"]
77+
RUN mv /src/cortex/serve/init/bootloader.sh /etc/cont-init.d/bootloader.sh
78+
79+
ENTRYPOINT ["/init"]

images/python-predictor-cpu/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ RUN apt-get update -qq && apt-get install -y -q \
99
unzip \
1010
zlib1g-dev \
1111
locales \
12+
nginx=1.14.* \
1213
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1314

15+
RUN cd /tmp/ && \
16+
curl -L --output s6-overlay-amd64-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer" && \
17+
cd - && \
18+
chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / && rm /tmp/s6-overlay-amd64-installer
19+
1420
RUN locale-gen en_US.UTF-8
1521
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.en LC_ALL=en_US.UTF-8
1622

@@ -88,4 +94,6 @@ COPY pkg/workloads/cortex/consts.py /src/cortex
8894
COPY pkg/workloads/cortex/lib /src/cortex/lib
8995
COPY pkg/workloads/cortex/serve /src/cortex/serve
9096

91-
ENTRYPOINT ["/src/cortex/serve/run.sh"]
97+
RUN mv /src/cortex/serve/init/bootloader.sh /etc/cont-init.d/bootloader.sh
98+
99+
ENTRYPOINT ["/init"]

images/python-predictor-gpu/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ RUN apt-get update -qq && apt-get install -y -q \
1111
unzip \
1212
zlib1g-dev \
1313
locales \
14+
nginx=1.14.* \
1415
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1516

17+
RUN cd /tmp/ && \
18+
curl -L --output s6-overlay-amd64-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer" && \
19+
cd - && \
20+
chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / && rm /tmp/s6-overlay-amd64-installer
21+
1622
RUN locale-gen en_US.UTF-8
1723
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.en LC_ALL=en_US.UTF-8
1824

@@ -93,4 +99,6 @@ COPY pkg/workloads/cortex/consts.py /src/cortex
9399
COPY pkg/workloads/cortex/lib /src/cortex/lib
94100
COPY pkg/workloads/cortex/serve /src/cortex/serve
95101

96-
ENTRYPOINT ["/src/cortex/serve/run.sh"]
102+
RUN mv /src/cortex/serve/init/bootloader.sh /etc/cont-init.d/bootloader.sh
103+
104+
ENTRYPOINT ["/init"]

images/python-predictor-inf/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ RUN apt-get update -qq && apt-get install -y -q \
1010
aws-neuron-runtime=1.1.1402.0 && \
1111
apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1212

13+
RUN wget -P /tmp/ https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer && \
14+
chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / && rm /tmp/s6-overlay-amd64-installer
15+
1316
ENV PATH=/opt/aws/neuron/bin/:$PATH
1417

1518
RUN apt-get update -qq && apt-get install -y -q \
@@ -21,6 +24,7 @@ RUN apt-get update -qq && apt-get install -y -q \
2124
unzip \
2225
zlib1g-dev \
2326
locales \
27+
nginx=1.14.* \
2428
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
2529

2630
RUN locale-gen en_US.UTF-8
@@ -100,4 +104,6 @@ COPY pkg/workloads/cortex/consts.py /src/cortex
100104
COPY pkg/workloads/cortex/lib /src/cortex/lib
101105
COPY pkg/workloads/cortex/serve /src/cortex/serve
102106

103-
ENTRYPOINT ["/src/cortex/serve/run.sh"]
107+
RUN mv /src/cortex/serve/init/bootloader.sh /etc/cont-init.d/bootloader.sh
108+
109+
ENTRYPOINT ["/init"]

0 commit comments

Comments
 (0)