Skip to content

Commit be9d478

Browse files
Merge pull request #209 from kate-goldenring/kv-provider-limits
kv: document the limits and requirements of each kv provider
2 parents 8aa1d33 + 31c4ce9 commit be9d478

2 files changed

Lines changed: 44 additions & 7 deletions

File tree

content/v4/dynamic-configuration.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ Spin creates the path and file if they don't already exist.
266266

267267
> If, during development, you need to examine keys and values, you can open the file using `sqlite3` or another SQLite tools. However, the file format is subject to change, and you should not rely on it.
268268
269+
#### Limits and Requirements
270+
271+
* Key size: Up to 256 bytes (UTF-8 encoded)
272+
* Value size: Up to 1 MB
273+
* Capacity: 1024 key value tuples
274+
* Reads per second: unlimited
275+
* Writes per second: unlimited
276+
* Global replication: none
277+
269278
### Redis Key Value Store Provider
270279

271280
To use a Redis store as a backend for Spin's key-value store, set the type to `redis` and provide the URL of the Redis host:
@@ -276,6 +285,15 @@ type = "redis"
276285
url = "redis://localhost"
277286
```
278287

288+
#### Limits and Requirements
289+
290+
* Key size: Key/value pair size cannot exceed 128 MB
291+
* Value size: Key/value pair size cannot exceed 128 MB
292+
* Capacity: Unlimited key-value tuples
293+
* Reads per second: Determined by Redis server configuration
294+
* Writes per second: Determined by Redis server configuration
295+
* Global replication: Depends on Redis deployment (single instance = no; Redis Cluster/Sentinel = yes)
296+
279297
### Azure CosmosDB Key Value Store Provider
280298

281299
To use an Azure CosmosDB database as a backend for Spin's key-value store, set the type to `azure_cosmos` and specify your database account details:
@@ -291,6 +309,16 @@ container = "<cosmos-container>"
291309

292310
> Note: The CosmosDB container must be created with the default partition key, `/id`.
293311
312+
#### Limits and Requirements
313+
314+
* Key size: Up to 255 characters (Cosmos DB document id limit)
315+
* Value size: Up to ~400 KB per item total (Cosmos DB hard limit; not validated in Spin code)
316+
* Key syntax: Keys must NOT contain: /, \, ?, #
317+
* Capacity: Unlimited
318+
* Reads per second: Determined by provisioned RU/s on the Cosmos DB container
319+
* Writes per second: Determined by provisioned RU/s on the Cosmos DB container
320+
* Global replication: Yes (Cosmos DB supports multi-region replication)
321+
294322
### AWS DynamoDB Key Value Store Provider
295323

296324
To use an Amazon Web Services DynamoDB database as a backend for Spin's key-value store, set the type to `aws_dynamo` and specify your database account details:
@@ -309,6 +337,15 @@ By default, the DynamoDB backend uses eventually consistent reads. The `consiste
309337

310338
> Note: The DynamoDB table must be created with the partition key `PK`. It must have no sort key (so that the partition key is the primary key).
311339
340+
#### Limits and Requirements
341+
342+
* Key size: Up to 2048 bytes
343+
* Value size: Up to 400 KB per item
344+
* Capacity: Unlimited
345+
* Reads per second: Determined by DynamoDB table capacity mode (provisioned or on-demand)
346+
* Writes per second: Determined by DynamoDB table capacity mode
347+
* Global replication: Depends on deployment
348+
312349
### Multiple and Non-Default Key-Value Stores
313350

314351
Whilst a single default store may be sufficient for certain application use cases, each Spin application can be configured to support multiple stores of any `type`, as shown in the `runtime-config.toml` file below:

content/v4/kv-store-api-guide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ Spin provides an interface for you to persist data in a key value store managed
1616

1717
## Using Key Value Store From Applications
1818

19-
The Spin SDK surfaces the Spin key value store interface to your language. The following characteristics are true of keys and values:
20-
21-
* Keys as large as 256 bytes (UTF-8 encoded)
22-
* Values as large as 1 megabyte
23-
* Capacity for 1024 key value tuples
24-
25-
The set of operations is common across all SDKs:
19+
The Spin SDK surfaces the Spin key value store interface to your language. The set of operations is common across all SDKs:
2620

2721
| Operation | Parameters | Returns | Behavior |
2822
|------------|------------|---------|----------|
@@ -201,6 +195,12 @@ func example() error {
201195

202196
{{ blockEnd }}
203197

198+
## Key Value Store Limits
199+
200+
The key/value size limits and syntactic requirements of a key value store depends on which [key value store provider](./dynamic-configuration#key-value-store-runtime-configuration) your app uses. The Spin command line currently supports a [default local SQLite provider]((./dynamic-configuration#file-key-value-store-provider)), a Redis KV provider, an Azure Cosmos DB backed provider, and an AWS Dynamo DB provider. See the [key value store runtime configuration](./dynamic-configuration#key-value-store-runtime-configuration) documentation for more information about the limits and requirements of each provider.
201+
202+
When you deploy your application, bear in mind that your deployment platform may have a KV provider with different characteristics from your local one!
203+
204204
## Custom Key Value Stores
205205

206206
Spin defines a key-value store named `"default"` and provides automatic backing storage. If you need to customize Spin with additional stores, or to change the backing storage for the default store, you can do so via the `--runtime-config-file` flag and the `runtime-config.toml` file. See [Key Value Store Runtime Configuration](./dynamic-configuration#key-value-store-runtime-configuration) for details.

0 commit comments

Comments
 (0)