You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deploy.md
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,11 +76,11 @@ curl http://localhost:5001/predictions -X POST \
76
76
77
77
```json
78
78
{
79
-
"status": "succeeded",
80
-
"output": "data:image/png;base64,...",
81
-
"metrics": {
82
-
"predict_time": 4.52
83
-
}
79
+
"status": "succeeded",
80
+
"output": "data:image/png;base64,...",
81
+
"metrics": {
82
+
"predict_time": 4.52
83
+
}
84
84
}
85
85
```
86
86
@@ -144,8 +144,8 @@ the response contains a base64-encoded data URL by default:
144
144
145
145
```json
146
146
{
147
-
"status": "succeeded",
148
-
"output": "data:image/png;base64,iVBORw0KGgo..."
147
+
"status": "succeeded",
148
+
"output": "data:image/png;base64,iVBORw0KGgo..."
149
149
}
150
150
```
151
151
@@ -172,8 +172,8 @@ contains the uploaded URL instead of a data URL:
172
172
173
173
```json
174
174
{
175
-
"status": "succeeded",
176
-
"output": "https://example.com/upload/image.png"
175
+
"status": "succeeded",
176
+
"output": "https://example.com/upload/image.png"
177
177
}
178
178
```
179
179
@@ -215,21 +215,25 @@ to stop.)
215
215
216
216
## Concurrency
217
217
218
-
By default, the server processes one run at a time. To enable concurrent runs, set the `concurrency.max` option in `cog.yaml`:
218
+
By default, the server processes one run at a time. To enable concurrent runs, make your `run()` method async and decorate it with `@cog.concurrent(max=N)`:
219
219
220
-
```yaml
221
-
concurrency:
222
-
max: 4
220
+
```py
221
+
import cog
222
+
223
+
classRunner(cog.BaseRunner):
224
+
@cog.concurrent(max=4)
225
+
asyncdefrun(self) -> str:
226
+
return"hello world"
223
227
```
224
228
225
-
See the [`cog.yaml` reference](yaml.md#concurrency) for more details.
229
+
The deprecated[`concurrency.max`](yaml.md#concurrency)field in `cog.yaml` is still supported and takes precedence over the decorator by baking `COG_MAX_CONCURRENCY` into the image.
226
230
227
231
## Environment variables
228
232
229
233
You can configure runtime behavior with environment variables:
230
234
231
235
-`COG_SETUP_TIMEOUT`: Maximum time in seconds for the `setup()` method (default: no timeout).
232
-
- `COG_MAX_CONCURRENCY`: Number of concurrent prediction slots (default: 1).
236
+
-`COG_MAX_CONCURRENCY`: Number of concurrent prediction slots (default: 1). Overrides both `@cog.concurrent` and deprecated `cog.yaml` concurrency.
233
237
234
238
See the [environment variables reference](environment.md) for the full list.
Copy file name to clipboardExpand all lines: docs/environment.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,9 +173,18 @@ These variables affect a running model server. Set them in `cog.yaml` under `env
173
173
174
174
### `COG_MAX_CONCURRENCY`
175
175
176
-
Controls how many predictions the model server can run concurrently.
176
+
Controls how many predictions the model server can run concurrently. This overrides both `@cog.concurrent(max=N)` and the deprecated `concurrency.max` field in `cog.yaml`.
177
177
178
-
By default, Cog runs one prediction at a time. Invalid values are ignored and the default of `1` is used.
178
+
By default, Cog runs one prediction at a time unless the model uses `@cog.concurrent(max=N)`. Invalid values are ignored and the default of `1` is used.
179
+
180
+
Values greater than `1` require an async `run()` method. This applies even when `COG_MAX_CONCURRENCY` is set as a runtime operator override.
181
+
182
+
Concurrency is resolved in this order, from highest to lowest precedence:
183
+
184
+
1.`COG_MAX_CONCURRENCY` set at runtime
185
+
2. Deprecated `concurrency.max` in `cog.yaml`, which is baked into the image as `COG_MAX_CONCURRENCY`
186
+
3.`@cog.concurrent(max=N)` on the async `run()` method
187
+
4. Default: `1`
179
188
180
189
```console
181
190
$ COG_MAX_CONCURRENCY=4 docker run -p 5000:5000 my-model
0 commit comments