Amazon SageMaker Function Retailer is a totally managed, purpose-built repository to retailer, share, and handle options for machine studying (ML) fashions. It supplies low-latency on-line serving for real-time inference, an offline retailer for historic retention and coaching characteristic information, and helps each streaming and batch ingestion patterns.
As ML platforms mature, two operational gaps floor repeatedly. First, groups operating high-throughput characteristic pipelines should name PutRecord (which writes a single characteristic file to the web retailer) in a loop. This implies one API name per file, per characteristic group, which creates connection overhead and poor throughput. A fraud-detection pipeline ingesting 10,000 information per second throughout 5 characteristic teams should maintain 50,000 particular person API calls per second solely to maintain options present. A second problem is that groups utilizing the In-Reminiscence storage tier don’t have any method to browse or enumerate information saved within the on-line retailer. If file identifiers are misplaced by way of a bug or pipeline failure, these information grow to be completely unrecoverable. There isn’t a offline retailer for the In-Reminiscence tier to fall again on, no Amazon Athena question to run, and no API to find what exists.
Right this moment, we’re saying two new APIs for Amazon SageMaker Function Retailer:
BatchWriteRecord — Write as much as 25 information throughout a number of characteristic teams in a single API name, with partial-success semantics, per-record time-to-live (TTL) management, and the identical EventTime-based ordering ensures as PutRecord.
ListRecords — Enumerate file identifiers inside a characteristic group utilizing pagination. Works with each Normal (Amazon DynamoDB-backed) and In-Reminiscence (Redis-backed) storage tiers.
On this publish, we stroll by way of every API with code examples you need to use to get began.
Stipulations
To observe together with the examples on this publish, you want:
BatchWriteRecord
The BatchWriteRecord API tackles the throughput limits of single-record ingestion. The next sections clarify the issue it solves and the way it works.
The problem with single-record ingestion
The prevailing PutRecord API in Function Retailer writes one file to at least one characteristic group per name. Every name performs a conditional write: the file is continued because the “newest” model provided that its EventTime, included within the request, is newer than the prevailing file. If the situation fails, the file remains to be written as a historic model for the offline retailer.
This design supplies robust ordering ensures, however at scale it forces an N×M calling sample (N information × M characteristic teams), creating connection overhead and tail latency that restrict throughput.
How BatchWriteRecord works
BatchWriteRecord accepts as much as 25 entries in a single request, concentrating on a number of characteristic teams concurrently. Every file succeeds or fails independently. It is a partial-success API, which means particular person file failures don’t fail your entire request.
The API preserves the identical EventTime-based ordering as PutRecord:
If the incoming file’s EventTime is newer than the prevailing file, it turns into the newest model within the on-line retailer.
If not, the file is written as a historic model to the offline retailer (for characteristic teams with offline storage).
Information that fail for different causes (authentication/validation errors, service throttling) are returned within the response with error particulars and the unique file.
The requests which are unprocessed will likely be returned in response as UnprocessedEntries which may be retried.
Request construction
The response returns solely the information that failed:
Information not listed in Errors or UnprocessedEntries succeeded. Your utility ought to retry solely the failed information utilizing exponential backoff for retriable errors.
Code instance: Batch ingestion with Boto3
Code instance: Writing throughout a number of characteristic teams
You’ll be able to goal a number of characteristic teams in a single request. Information are grouped by characteristic group and processed independently:
A failure in a single characteristic group doesn’t have an effect on information destined for different characteristic teams.
TTL (Time-to-Stay) assist
BatchWriteRecord helps TTL at three ranges of priority, proven within the following precedence order:
File-level TTL — Set with TtlDuration on particular person entries. Takes highest precedence.
Request-level TTL — A default TtlDuration on the high degree of the request, utilized to entries and not using a record-level TTL.
Function-group-level TTL — The TTL configured on the characteristic group itself, utilized when neither record-level nor request-level TTL is ready.
Key issues
Most 25 entries per request. This restrict applies to the overall variety of entries throughout all characteristic teams in a single request.
Partial-success semantics: Not like transactional APIs, BatchWriteRecord doesn’t roll again profitable writes if some information fail. Design your retry logic to re-submit solely the information returned in Errors.
Related IAM mannequin as PutRecord: The caller will need to have sagemaker:BatchWriteRecord and sagemaker:PutRecord permission on the Amazon Useful resource Identify (ARN) of every goal characteristic group. Per-feature-group authorization is checked earlier than processing.
EventTime ordering is preserved: BatchWriteRecord makes use of conditional writes to take care of the identical latest-record-wins semantics as PutRecord. A stale file can not overwrite a more moderen one within the on-line retailer.
TargetStores flexibility: Every entry can independently goal OnlineStore, OfflineStore, or each (defaults to the characteristic group’s enabled shops), supplying you with fine-grained management over the place every file lands.
ListRecords
The ListRecords API closes the hole in file discovery for each storage tiers. The next sections clarify the issue it solves and the way it works.
The problem with file discovery
Function Retailer helps PutRecord, GetRecord, and DeleteRecord, however all require the caller to know the precise file identifier. There isn’t a API to browse or enumerate information inside a characteristic group.
For the Normal tier, the workaround is querying the offline retailer by utilizing Amazon Athena. This requires offline retailer configuration, provides value, and isn’t real-time.
For the In-Reminiscence tier, the scenario is crucial. There isn’t a corresponding offline retailer by default. If file identifiers are misplaced, these information are utterly unrecoverable. You can not uncover them, and you can’t delete them. This results in phantom information, wasted storage prices, and potential compliance dangers when information topics request deletion.
How ListRecords works
ListRecords enumerates file identifiers inside a characteristic group utilizing pagination. It returns solely energetic, non-deleted, non-expired information which are prepared for use with GetRecord or DeleteRecord.
The API works with each storage tiers:
Normal tier (Amazon DynamoDB): Scans the web retailer, returning identifier of the newest model of every file. Gentle-deleted and expired information are mechanically excluded.
In-Reminiscence tier (Redis): Scans keys and filters out soft-deleted information and inside system keys. Returns file identifiers extracted from key names.
Request and response construction
Request physique:
Preliminary name
Or
Response:
When NextToken is absent within the response, pagination is full.
Code instance: Enumerate all information in a characteristic group
Code instance: Clear up orphaned information
A standard use case is figuring out and deleting information which are now not wanted. That is crucial for In-Reminiscence tier characteristic teams, the place orphaned information persist indefinitely:
Web page measurement: Configurable by way of MaxResults (default 10, most 100).
Token format: Opaque, encrypted string. Don’t parse or assemble tokens. Move them by way of unchanged.
Ordering: Outcomes usually are not assured to be in any explicit order.
Concurrent writes: If information are written or deleted throughout pagination, chances are you’ll observe duplicates or gaps. That is documented conduct.
Token scope: Tokens are tied to a selected characteristic group and account and can’t be reused throughout both.
Key issues
File identifiers solely. The present launch returns file identifiers with out characteristic values. Use GetRecord or BatchGetRecord to retrieve full information for the identifiers you want.
Computerized filtering. The API excludes soft-deleted information, expired information (Normal tier TTL), and inside system keys (In-Reminiscence tier). You see solely energetic, retrievable information.
IAM permission. The caller will need to have sagemaker:ListRecords permission on the characteristic group ARN.
Each tiers supported. ListRecords works identically from the caller’s perspective no matter whether or not the characteristic group makes use of Normal or In-Reminiscence storage.
Placing it collectively
These two APIs complement one another naturally. Think about a compliance workflow that verifies full information deletion for a consumer throughout a number of characteristic teams:
Cleanup
To keep away from ongoing fees, delete characteristic teams you created whereas following this walkthrough. For In-Reminiscence tier characteristic teams, use ListRecords to enumerate information and DeleteRecord to take away them earlier than deleting the characteristic group.
Conclusion
BatchWriteRecord and ListRecords present key enhancements within the information airplane of Amazon SageMaker Function Retailer. BatchWriteRecord reduces the API name quantity for high-throughput ingestion by as much as 25x whereas preserving the EventTime-based ordering ensures that preserve your on-line retailer right. ListRecords unlocks file discovery and lifecycle administration. That is crucial for In-Reminiscence tier clients who beforehand had no method to enumerate or clear up their information.
Collectively, these APIs assist patterns that had been beforehand troublesome or unimaginable: bulk ingestion pipelines with fewer connections and decrease latency, compliance workflows that may confirm full information deletion, and operational tooling that may browse characteristic group contents in actual time.
For extra info, see the Function Retailer documentation, the Function Retailer API reference, the offline retailer configuration documentation, and the What’s New announcement.
For background on Function Retailer capabilities, discover these associated posts:





