Architecture pattern library

AWS field guide

Scale services around measurable demand

Scale long-lived services from demand and saturation signals, with deployment health treated as part of the architecture.

Use this pattern when

The workload needs a persistent runtime, custom networking, or more control than function execution provides.

Reference architecture

Responsibilities and controls, not a deployment template.

Synchronous Asynchronous

Client

Service request

Elastic Load Balancing

Health-aware routing

Amazon ECS

Desired service state

AWS Fargate

Isolated running tasks

Amazon CloudWatch

Scaling and rollback signal

AWS service marks use the official Q3 2026 AWS Architecture Icons. Abstract nodes represent application responsibilities rather than AWS services.

Decisions that shape the pattern

  • Set CPU and memory from measured profiles.
  • Scale on a workload signal, not CPU alone.
  • Keep tasks disposable and state external.

Security boundaries

  • Use one task role per service.
  • Keep tasks in private subnets where practical.
  • Pull secrets at runtime without baking them into images.

Reliability posture

  • Use meaningful health checks.
  • Keep capacity across multiple Availability Zones.
  • Roll back deployments from service-level signals.

Starter implementation

Start from deployable infrastructure

Review every permission, limit, Region, and cost assumption before production.

Download ADR template
container-service.stack.ts
import { Duration, Stack, StackProps } from 'aws-cdk-lib';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as athena from 'aws-cdk-lib/aws-athena';
import * as bedrock from 'aws-cdk-lib/aws-bedrock';
import * as budgets from 'aws-cdk-lib/aws-budgets';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
import * as cloudtrail from 'aws-cdk-lib/aws-cloudtrail';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as patterns from 'aws-cdk-lib/aws-ecs-patterns';
import * as events from 'aws-cdk-lib/aws-events';
import * as targets from 'aws-cdk-lib/aws-events-targets';
import * as glue from 'aws-cdk-lib/aws-glue';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as sources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { Construct } from 'constructs';

export class PatternStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const cluster = new ecs.Cluster(this, 'Cluster');
    const service = new patterns.ApplicationLoadBalancedFargateService(this, 'Service', {
      cluster,
      cpu: 512,
      memoryLimitMiB: 1024,
      desiredCount: 2,
      taskImageOptions: { image: ecs.ContainerImage.fromRegistry('public.ecr.aws/nginx/nginx:stable') },
    });
    service.targetGroup.configureHealthCheck({ path: '/health' });
    service.service.enableDeploymentAlarms(['HighErrorRate'], { behavior: ecs.AlarmBehavior.ROLLBACK_ON_ALARM });
  }
}

Before production

Adoption checklist

  1. 01Measure steady and peak demand.
  2. 02Set deployment circuit breakers.
  3. 03Test task termination.
  4. 04Add autoscaling cooldowns.
  5. 05Track cost per request or job.

From the journal

Selected from service names and architecture signals used by this pattern.

Was this playbook useful?

One click helps prioritize deeper examples and updates.