Skip to main content

Overview

The Lightweight pattern uses Fargate Spot to run your containers at a significant discount compared to on-demand Fargate pricing. It is a good fit for simple applications, internal tools, and workloads that can tolerate occasional interruptions.

What’s Included

fjall create app --type lightweight
Creates:
  • ECS on Fargate Spot (up to 70% cost savings)
  • RDS Instance in single AZ
  • Application Load Balancer
  • Basic monitoring

Architecture

┌─────────────────┐
│      ALB        │ (2 AZ)
└────────┬────────┘
         |
┌────────┴────────┐
│  ECS Fargate    │ (FARGATE_SPOT, 1 task)
│  Spot           │ (256 CPU, 512 MiB)
└────────┬────────┘
         |
┌────────┴────────┐
│  RDS Instance   │ (2 AZ)
└─────────────────┘

Generated Infrastructure

#!/usr/bin/env node

import {
  App,
  DatabaseFactory,
  ComputeFactory,
  getConfig,
} from "@fjall/components-infrastructure";

const appName = "simple";
const app = App.getApp(appName);

app.addTags({
  "fjall:costAllocation:owner": "engineering",
});

const simpleStorage = app.addDatabase(
  DatabaseFactory.build("SimpleStorage", {
    type: "Instance",
    databaseName: "SimpleDatabase",
  }),
);

app.addCompute(
  ComputeFactory.build("SimpleCompute", {
    type: "ecs",
    ecrRepository: app.getDefaultContainerRegistry(),
    services: [
      {
        name: "app",
        capacityProvider: "FARGATE_SPOT",
        cpu: 256,
        memoryLimitMiB: 512,
        desiredCount: 1,
        scaling: {
          maxCapacity: 3,
        },
        containers: [
          {
            port: 3000,
            environment: {
              ENVIRONMENT: getConfig().environment,
              DATABASE_HOST: simpleStorage.getHostEndpoint(),
              DATABASE_PORT: `${simpleStorage.getHostPort()}`,
              DATABASE_NAME: simpleStorage.getDatabaseName(),
            },
            secretsImport: {
              DATABASE_PASSWORD: simpleStorage
                .getCredentials()
                .getImport("password"),
            },
          },
        ],
      },
    ],
  }),
);

Specifications

Compute (ECS on Fargate Spot)

  • Capacity provider: FARGATE_SPOT (up to 70% savings vs on-demand)
  • CPU: 256 units (0.25 vCPU)
  • Memory: 512 MiB
  • Tasks: 1 (scales up to 3)
  • Availability: 2 AZ

Database (RDS Instance)

  • Engine: PostgreSQL 17.5
  • Instance: t4g.small
  • Storage: 20 GB gp3
  • Backup: 7-day retention
  • Multi-AZ: No (single AZ)

Networking

  • VPC: 2 AZ setup
  • Subnets: Public and private
  • Load Balancer: Basic ALB
  • NAT: 1 NAT gateway

Cost Comparison

PatternMonthly CostAvailability
Tinkerer$0*2 AZ, EC2 direct access
Lightweight~$352 AZ, Fargate Spot
Standard~$86Multi-AZ capable
Resilient~$150+Multi-AZ, enhanced monitoring
* Tinkerer is $0 only within AWS free-tier limits. Data-transfer and over-limit usage incur charges.

Use Cases

Perfect for:
  • Internal tools
  • Development environments
  • Low-traffic websites
  • Simple APIs
  • Prototypes going to production
  • Cost-sensitive projects
Not suitable for:
  • High availability requirements (Spot tasks can be interrupted)
  • Mission-critical applications
  • High traffic loads
  • Multi-region needs

Key Differences from Standard

FeatureLightweightStandard
Capacity providerFARGATE_SPOTFARGATE
CPU256512
Memory512 MiB1024 MiB
Default tasks12
Max tasks35
Interruption riskYes (Spot)No
Cost~40% cheaperFull price, full reliability

Customisation

Upgrading to On-Demand Fargate

If you need guaranteed capacity, switch the capacity provider:
app.addCompute(
  ComputeFactory.build("SimpleCompute", {
    type: "ecs",
    services: [
      {
        name: "app",
        capacityProvider: "FARGATE", // Switch from FARGATE_SPOT
        cpu: 256,
        memoryLimitMiB: 512,
      },
    ],
  }),
);

Upgrading Database

const simpleStorage = app.addDatabase(
  DatabaseFactory.build("SimpleStorage", {
    type: "Instance",
    databaseName: "SimpleDatabase",
    instanceType: "t4g.medium", // More power
  }),
);

Monitoring

Basic CloudWatch monitoring includes:
  • ECS service health
  • RDS basic metrics
  • ALB request count
  • Application logs

Upgrade Path

To Standard Pattern

  1. Change capacity provider to FARGATE
  2. Increase CPU to 512 and memory to 1024 MiB
  3. Increase desired count to 2 for high availability

To Resilient Pattern

  • Migrate database to Aurora
  • Increase task count and scaling limits
  • Add KMS encryption

Security Considerations

Network Security

  • Private subnets for database
  • Security groups with minimal rules
  • No direct internet access for compute

Data Security

  • Encryption at rest enabled
  • TLS for data in transit
  • Secrets in AWS Secrets Manager

Best Practices

  1. Start with Lightweight for new projects that do not need guaranteed uptime
  2. Monitor Spot interruptions via CloudWatch
  3. Regular backups even with automation
  4. Plan for growth but do not over-provision
  5. Use caching to maximise performance
  6. Keep it simple. Complexity adds cost

Next Steps

Deploy an Application

Deploy your Lightweight application to AWS

Add Resources

Add databases, storage, and more to your application

Compute Factory

Customise the compute configuration

Storage Factory

Configure S3 storage for your application