Guide · AWS App Runner · Auto Scaling · MCP Server

App Runner Auto Scaling for MCP Servers — Concurrency, Min/Max Instances, and Cold Starts

AWS App Runner scales MCP server instances automatically based on concurrent requests — not CPU or memory like traditional auto-scaling. This model maps well to MCP servers because each tool call is a discrete request with bounded duration. The key configuration decisions are: how many concurrent requests each instance should handle, the minimum number of instances to keep warm, and the maximum cap to control costs under unexpected traffic spikes. Getting these wrong leads to either avoidable cold-start latency or unnecessary idle compute spend.

TL;DR

App Runner's auto-scaling trigger is concurrent requests per instance, not CPU. Set maxConcurrency to 10–25 for typical MCP servers (each tool call takes 100ms–5s). Set minSize: 0 for cost-first (accept cold starts), or minSize: 1 for latency-first (~$3–8/month extra for the warm instance). Set maxSize to cap total instances and control your maximum spend. App Runner scales out in ~30 seconds and scales in after ~1 minute of idle.

How App Runner's auto-scaling works

App Runner measures concurrent active requests on each running instance. When the number of concurrent requests exceeds maxConcurrency, App Runner starts a new instance. When a new instance is healthy (passes health checks), App Runner starts routing some traffic to it. When all instances are idle for approximately 1 minute, App Runner may pause instances (scaling to zero), which stops per-instance charges.

This is different from CPU-based auto-scaling (like ECS/EC2 Auto Scaling Groups) in an important way: App Runner can add instances even when CPU is low, if many slow requests are running in parallel. For MCP servers, where a single tool call might spend several seconds waiting for a DynamoDB response, this is the right model — you want to scale out based on how many tool calls are in-flight, not how much CPU they're using.

ParameterWhat it controlsDefaultRecommended range
maxConcurrencyConcurrent requests per instance before scale-out10010–25 for typical MCP tools
minSizeMinimum number of provisioned instances10 (cost-first) or 1 (latency-first)
maxSizeMaximum number of instances (cost cap)253–10 for most MCP servers

Choosing the right maxConcurrency

The default maxConcurrency of 100 is too high for most MCP servers. It means a single instance will accept up to 100 simultaneous tool calls before App Runner starts a new instance. If each tool call takes 2 seconds (waiting on DynamoDB, calling an external API), 100 concurrent calls means up to 200 seconds of queued work on a single instance — that's not acceptable latency.

Calculate a sensible maxConcurrency based on your expected tool call duration and your target concurrency headroom:

// Rule of thumb:
// maxConcurrency = (target max p99 latency) / (avg tool call duration) * safety_factor

// Example: target p99 <= 3s, avg tool call takes 500ms
// maxConcurrency = (3000ms / 500ms) * 1.5 ≈ 9 → use 10

// Example: target p99 <= 10s, avg tool call takes 1s (DynamoDB + processing)
// maxConcurrency = (10000ms / 1000ms) * 1.5 ≈ 15 → use 15

// Example: MCP server with heavy LLM tool calls taking 5-10s each
// maxConcurrency = 5 → scale out aggressively to keep latency bounded

For MCP servers that do minimal work (mostly forwarding requests to external APIs), set maxConcurrency higher (25–50). For servers doing local computation (parsing, transformation, local model inference), keep it low (5–10).

Creating an auto-scaling configuration

Auto-scaling configurations are standalone resources in App Runner that can be shared across services or pinned to a specific service:

# Create an auto-scaling configuration
aws apprunner create-auto-scaling-configuration \
  --auto-scaling-configuration-name mcp-server-scaling \
  --max-concurrency 15 \
  --min-size 1 \
  --max-size 5 \
  --region us-east-1

# Note the ARN from the output, e.g.:
# arn:aws:apprunner:us-east-1:ACCOUNT:autoscalingconfiguration/mcp-server-scaling/1/HASH

# Associate with a service (update existing service)
aws apprunner update-service \
  --service-arn arn:aws:apprunner:us-east-1:ACCOUNT:service/my-mcp-server/SERVICE_ID \
  --auto-scaling-configuration-arn \
    arn:aws:apprunner:us-east-1:ACCOUNT:autoscalingconfiguration/mcp-server-scaling/1/HASH

Auto-scaling configurations are versioned. When you create a new version, you can associate it with the service independently of a full service deployment. This lets you tune scaling behaviour without triggering a container restart.

Cold starts: causes and mitigations

A cold start occurs when App Runner must start a new instance from scratch to handle a request — either because all existing instances are at maxConcurrency and need a new one, or because there are no instances running (scaled to zero). The cold start time is the sum of:

  1. Image pull — 10–30 seconds for a typical Node.js Docker image (500MB–1GB). Mitigate by keeping images small (multi-stage builds, alpine base, omit dev dependencies).
  2. Container start — 1–5 seconds for Node.js to start and load modules.
  3. Application initialization — time for your server to listen on the port and pass the first health check (depends on your startup logic).

Total cold start for a well-optimized MCP server: 15–45 seconds. For a larger image with slow initialization: 60–120 seconds.

Strategies to minimize cold start impact:

# Strategy 1: Keep the Docker image small
# - Use node:20-alpine instead of node:20 (saves ~400MB, ~10s pull time)
# - Use multi-stage builds to exclude dev dependencies
FROM node:20-alpine AS runner
# ...

# Strategy 2: Set minSize: 1 to avoid cold starts entirely for the first instance
# (extra cost: ~$3-8/month for 0.25 vCPU / 0.5 GB instance)
aws apprunner create-auto-scaling-configuration \
  --auto-scaling-configuration-name mcp-no-cold-start \
  --min-size 1 \
  --max-concurrency 15 \
  --max-size 5

# Strategy 3: Keep startup code fast
# - Defer expensive initialization (DB connection pools, model loading)
#   to the first actual request using lazy initialization:
let dbPool: Pool | null = null;
function getDbPool(): Pool {
  if (!dbPool) dbPool = createPool(process.env.DATABASE_URL!);
  return dbPool;
}

# Strategy 4: Prewarm critical connections during health check
# - On first /health call, initialize the DB pool so it's ready before tool calls

Scaling to zero vs minimum one instance

App Runner's ability to scale to zero (pause all instances when idle) is a key cost-saving feature. The tradeoff is cold start latency on the next request after a period of inactivity.

ConfigurationMonthly cost (0.25vCPU/0.5GB)Cold start on first requestBest for
minSize: 0~$0 (instance cost) + per-request charges15–60 secondsDevelopment, personal tools, batch MCP servers
minSize: 1~$3–8/month baselineNone (instance always warm)Production MCP servers where UX matters
minSize: 2~$6–16/month baselineNone; continues serving during deploymentsProduction with zero-downtime deployment requirement

For a Claude Desktop MCP extension used by a single person, minSize: 0 is fine — Claude Desktop can tolerate a 30-second cold start when first connecting. For a shared team MCP server or a commercial product, use minSize: 1 so the first tool call after any idle period is instant.

Observing scaling events in CloudWatch

App Runner emits metrics to CloudWatch under the AWS/AppRunner namespace. Key metrics to monitor:

MetricWhat it meansAlert condition
ActiveInstancesNumber of instances currently runningConsistently hitting maxSize → increase cap
ConcurrencyCurrent concurrent request count across all instancesConsistently near maxConcurrency × ActiveInstances → scale out sooner
RequestLatencyEnd-to-end request latency (p50, p90, p99)p99 > your SLA target
2xxStatusResponsesCount of 2xx responsesDrop in 2xx without a matching drop in requests → errors
5xxStatusResponsesCount of 5xx errorsAny sustained 5xx rate → check application logs
# CloudWatch alarm: notify when consistently at max instances
aws cloudwatch put-metric-alarm \
  --alarm-name mcp-apprunner-at-max-instances \
  --metric-name ActiveInstances \
  --namespace AWS/AppRunner \
  --dimensions Name=ServiceName,Value=my-mcp-server \
  --statistic Maximum \
  --period 300 \
  --threshold 5 \
  --comparison-operator GreaterThanOrEqualToThreshold \
  --evaluation-periods 2 \
  --alarm-actions arn:aws:sns:us-east-1:ACCOUNT:mcp-alerts

SSE and long-lived connections

MCP servers using the Server-Sent Events (SSE) transport hold connections open for the duration of a session. Each open SSE connection counts as one concurrent request against maxConcurrency. This matters significantly for scaling calculations:

// If using SSE transport:
// - Each MCP client session = 1 long-lived SSE connection
// - A session may last minutes or hours
// - maxConcurrency of 15 means at most 15 simultaneous MCP sessions per instance

// For SSE-based MCP servers, use a lower maxConcurrency than for
// request-response transports:
// - Set maxConcurrency to your desired max sessions per instance (e.g., 5-10)
// - App Runner will add instances as more clients connect

// For the newer MCP Streamable HTTP transport (stateless request/response):
// - Each tool call is a brief request (not a long-lived connection)
// - maxConcurrency can be set higher (15-25)
// - Better fit for App Runner's scaling model

App Runner has a default maximum request duration of 20 minutes. SSE connections held longer than 20 minutes are terminated by the load balancer. If your MCP sessions need longer lifetimes, prefer the Streamable HTTP transport or implement client-side reconnect logic.

Related guides