Urgent.News

What's breaking now, across thousands of outlets.

AI

Architecture patterns for fast session startup on Amazon Bedrock AgentCore runtime

Amazon Bedrock AgentCore runtime V2 snapshots your initialized environment and restores it for each new session, so session start no longer grows with image size. This post explains how V2 starts a session, how to measure session start time, and four patterns to keep work off the first request.

Architecture patterns for fast session startup on Amazon Bedrock AgentCore runtime

Amazon Bedrock AgentCore runtime offers a managed, serverless environment for agents that run sessions in isolated microVMs. When platformVersion is set to "V2", the platform prepares the environment once, snapshots it, and restores the snapshot for each new session. This results in faster and more consistent session start times, as well as memory optimization since unreferenced memory is reclaimed.

The V2 runtime differs from V1 in that it starts the container once, waits for the first healthy ping within 120 seconds, freezes the microVM, and stores its memory and disk as a snapshot. After this initial build, every new session invocation restores the snapshot into a new microVM, resuming the process exactly where it was frozen.

Three key observations can be made from these flows:

1. Memory is restored whole, with any data held at snapshot time or in RAM-backed file systems available at memory speed during the first access.

2. File reads don't carry over from the initial initialization, as the file cache is cleared before freezing the microVM.

3. Image files are fetched on first read, meaning they are fetched from snapshot storage and then cached closer to the host during the restore process.

These observations apply to agents that can keep what they need in their own process. However, for agents dealing with large files, CLIs, or browsers early on (which can't be held in memory), a build hook can be added to load and prime these resources while the snapshot is being built. This method is covered in the post under the "Working with hooks" section.

To measure session start times, agents should monitor two Amazon CloudWatch metrics published by AgentCore runtime in the AWS/Bedrock-AgentCore namespace: Latency (the time to first byte) and OverheadLatency (the platform-specific overhead, including microVM initialization and snapshot restoration). The goal is to minimize the time spent on platform-related tasks by subtracting OverheadLatency from the total Latency, which reveals the actual runtime time for your agent's code.

By understanding these patterns and optimizing session startup in your agent's code, you can significantly improve the overall performance and user experience of your application on Amazon Bedrock AgentCore runtime.

Written by urgent.news from AWS Machine Learning's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at aws.amazon.com →

More in AI

More from Friday 13 November →