# Variance V2: Template Reference

<!-- Source: src/generate/processing/variance_v2/templates/*.yaml
     If you add a template there, add a row here too. -->

**Purpose:** Complete reference for built-in cost pattern templates
**Parent Guide:** [variance-v2-guide.md](../how-to/variance-v2-guide.md)

## Overview

Built-in templates provide pre-configured cost patterns for common workload
types. Use them via `cost_patterns.template` in generate configs:

```yaml
cost_patterns:
  template: saas_workload
```

Templates are built-in — no file paths needed.

## Quick Reference

| Template | Use for | Growth | Hours | Weekends |
|----------|---------|--------|-------|----------|
| `saas_workload` | B2B APIs, web apps | 12%/mo | Business peak | Quiet |
| `saas_workload_seasonal` | Same + Q4 spike | 12%/mo | Business peak | Quiet |
| `consumer_gaming` | Game servers, player APIs | 5%/mo | **Evening peak** | **Busy** |
| `database_workload` | RDS, ElastiCache, Cloud SQL | 10%/mo | Business peak | Quiet |
| `batch_processing` | ETL, background jobs | 10%/mo | **Night peak** | **Busy** |
| `warehouse_compute` | Snowflake, BigQuery | 20%/mo | Business peak | Quiet |
| `compute_cluster` | Databricks, EMR clusters | 15%/mo | None | None |
| `serverless` | Lambda, Cloud Functions | 15%/mo | Business peak | Quiet |
| `ml_training` | SageMaker, Vertex AI GPU | 15%/mo | **Night peak** | **Busy** |
| `storage_steady` | EBS, Managed Disks | 5%/mo | None | None |
| `storage_active` | S3, GCS, Blob Storage | 8%/mo | None | None |
| `storage_declining` | Deprecated/migrating storage | -25%/mo | None | None |
| `realtime_streaming` | Kafka, Kinesis, Pub/Sub | 8%/mo | None | None |
| `network_egress` | Data Transfer, CDN | 12%/mo | None | None |
| `managed_services` | SQS, SNS, Service Bus | 12%/mo | None | None |
| `ai_api` | Bedrock, Claude, GPT | 25%/mo | Business peak | Quiet |
| `ai_api_seasonal` | Same + Q4 spike | 25%/mo | Business peak | Quiet |

**Hours**: "Business peak" = `business_hours: standard`, "Night peak" = `business_hours: inverted`
**Weekends**: "Quiet" = `weekday_weekend: standard`, "Busy" = `weekday_weekend: inverted`

---

## Compute Templates

### saas_workload

B2B APIs, web apps, SaaS platforms. Business hours peak, near-zero weekends.

```yaml
variance:
  monthly_pct: 25.0
  weekly_pct: 20.0
  daily_pct: 40.0
  hourly_pct: 50.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.12
```

### saas_workload_seasonal

Same as `saas_workload` with Q4 seasonal spike.

```yaml
variance:
  monthly_pct: 25.0
  weekly_pct: 20.0
  daily_pct: 40.0
  hourly_pct: 50.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.12
  quarterly_seasonal:
    q1: 0.85
    q2: 1.0
    q3: 1.05
    q4: 2.0
```

### consumer_gaming

Player-facing game servers, gaming APIs. **Inverted**: evening/weekend peak, quiet during business hours.

```yaml
variance:
  monthly_pct: 20.0
  weekly_pct: 25.0
  daily_pct: 45.0
  hourly_pct: 55.0
  business_hours: inverted
  weekday_weekend: inverted
trends:
  monthly_growth_rate: 0.05
```

### compute_cluster

Databricks clusters, persistent GPU pools, EMR clusters. No temporal pattern.

```yaml
variance:
  monthly_pct: 40.0
  weekly_pct: 35.0
  daily_pct: 70.0
  hourly_pct: 80.0
trends:
  monthly_growth_rate: 0.15
```

### serverless

Lambda, Cloud Functions, Azure Functions. Invocation-driven with business hours peak.

```yaml
variance:
  monthly_pct: 80.0
  weekly_pct: 70.0
  daily_pct: 180.0
  hourly_pct: 200.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.15
```

---

## Database Templates

### database_workload

RDS, ElastiCache, DynamoDB, Cloud SQL, Redis. Query-driven with business hours peak.

```yaml
variance:
  monthly_pct: 20.0
  weekly_pct: 15.0
  daily_pct: 40.0
  hourly_pct: 50.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.10
```

### warehouse_compute

Snowflake, BigQuery, Databricks SQL. Credit-based, analyst-driven.

```yaml
variance:
  monthly_pct: 25.0
  weekly_pct: 20.0
  daily_pct: 40.0
  hourly_pct: 50.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.20
```

---

## Storage Templates

### storage_steady

EBS volumes, Azure Managed Disks, GCP Persistent Disks. Provisioned capacity, minimal variance.

```yaml
variance:
  monthly_pct: 10.0
  weekly_pct: 10.0
  daily_pct: 20.0
  hourly_pct: 30.0
trends:
  monthly_growth_rate: 0.05
```

### storage_active

S3, GCS, Azure Blob Storage. Request/transfer costs track workload activity.

```yaml
variance:
  monthly_pct: 50.0
  weekly_pct: 40.0
  daily_pct: 80.0
  hourly_pct: 120.0
trends:
  monthly_growth_rate: 0.08
```

### storage_declining

Deprecated storage with declining access. Triggers Optimize recommendations (e.g., CIR-AZURE-00259).

```yaml
variance:
  monthly_pct: 10.0
  weekly_pct: 10.0
  daily_pct: 20.0
  hourly_pct: 30.0
trends:
  monthly_growth_rate: -0.25
```

---

## Data & Networking Templates

### batch_processing

ETL pipelines, background jobs. **Inverted**: night/weekend peak for off-peak pricing.

```yaml
variance:
  monthly_pct: 20.0
  weekly_pct: 25.0
  daily_pct: 35.0
  hourly_pct: 50.0
  business_hours: inverted
  weekday_weekend: inverted
trends:
  monthly_growth_rate: 0.10
```

### realtime_streaming

Kinesis, Kafka, Pub/Sub, Event Hubs. Continuous 24/7, moderate variance.

```yaml
variance:
  monthly_pct: 50.0
  weekly_pct: 50.0
  daily_pct: 80.0
  hourly_pct: 80.0
trends:
  monthly_growth_rate: 0.08
```

### network_egress

Data transfer, CDN egress, inter-region traffic. Very high variance.

```yaml
variance:
  monthly_pct: 70.0
  weekly_pct: 70.0
  daily_pct: 150.0
  hourly_pct: 200.0
trends:
  monthly_growth_rate: 0.12
```

### managed_services

SQS, SNS, EventBridge, Service Bus. Event-driven, extremely bursty.

```yaml
variance:
  monthly_pct: 80.0
  weekly_pct: 80.0
  daily_pct: 150.0
  hourly_pct: 200.0
trends:
  monthly_growth_rate: 0.12
```

---

## AI/ML Templates

### ml_training

ML training, batch inference, GPU workloads. **Inverted**: night/weekend for cheaper rates.

```yaml
variance:
  monthly_pct: 25.0
  weekly_pct: 25.0
  daily_pct: 45.0
  hourly_pct: 55.0
  business_hours: inverted
  weekday_weekend: inverted
trends:
  monthly_growth_rate: 0.15
```

### ai_api

Anthropic Claude, OpenAI GPT, Bedrock, Vertex AI. Developer-driven, business hours.

```yaml
variance:
  monthly_pct: 30.0
  weekly_pct: 25.0
  daily_pct: 45.0
  hourly_pct: 55.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.25
```

### ai_api_seasonal

Same as `ai_api` with Q4 seasonal spike (model evaluations, year-end budget burns).

```yaml
variance:
  monthly_pct: 30.0
  weekly_pct: 25.0
  daily_pct: 45.0
  hourly_pct: 55.0
  business_hours: standard
  weekday_weekend: standard
trends:
  monthly_growth_rate: 0.25
  quarterly_seasonal:
    q1: 0.85
    q2: 1.0
    q3: 1.1
    q4: 2.0
```

---

## Custom Templates

If built-in templates don't fit, define explicit config:

```yaml
cost_patterns:
  variance:
    hourly_pct: 15.0
    daily_pct: 8.0
  patterns:
    time_of_week:
      weekday: 1.0
      weekend: 0.7
    business_hours:
      peak_hours: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
      peak_multiplier: 1.3
      off_hours_multiplier: 0.85
  trends:
    monthly_growth_rate: 0.06
    quarterly_seasonal:
      q1: 0.9
      q2: 1.0
      q3: 1.0
      q4: 1.3
  events:
    holidays:
      - name: "Product Launch"
        date: "2025-05-15"
        duration_days: 7
        multiplier: 3.0
```

### Template Override Pattern

Start with a template, override specific parts:

```yaml
cost_patterns:
  template: saas_workload
  patterns:
    time_of_week:
      weekend: 0.8  # Less weekend reduction (global users)
  events:
    holidays:
      - name: "Annual Sale"
        date: "2025-06-01"
        duration_days: 5
        multiplier: 4.0
```

Override precedence: explicit config > template defaults.
