# Multi-Cloud vs. Single-Cloud

> Resilience and vendor flexibility vs. operational complexity and cost. Operational complexity, vendor lock-in, negotiating leverage, latency, data egress costs, and disaster recovery trade-offs.

- **Category**: Trade-offs
- **Subcategory**: Cloud Infrastructure
- **Canonical URL**: https://designpattern.fyi/trade_offs/multi-cloud-vs-single-cloud/

---

## Description
**Intent**: Balance the benefits of using multiple cloud providers (resilience, vendor flexibility) against the operational complexity and costs of multi-cloud architecture.

**Context**: Single-cloud offers low operational complexity (single control plane, APIs, billing) but high vendor lock-in and negotiating leverage. Multi-cloud provides high resilience (cloud-level redundancy) and negotiating leverage but adds significant operational complexity (multiple control planes, higher data egress costs, cross-cloud latency).

**Solution**: Default to single-cloud for early-stage products. Adopt multi-cloud for regulatory requirements, specific service needs (GCP TPUs, Azure OpenAI), or negotiation leverage. Use cloud-agnostic abstractions (Terraform, Kubernetes, Kafka) to reduce lock-in. Consider data gravity — where your data lives determines which cloud runs compute cheapest.



## Use Cases
Startup using single AWS cloud for simplicity. Financial services using multi-cloud for regulatory compliance. Global company using multi-cloud for negotiating leverage and redundancy.



## Implementation Example

```javascript
// Multi-Cloud vs. Single-Cloud Architecture

// Cloud-agnostic Infrastructure with Terraform
resource "aws_db_instance" "primary" {
  engine = "postgres"
  instance_class = "db.t3.medium"
  # ... AWS-specific config
}

resource "google_sql_database_instance" "backup" {
  database_version = "POSTGRES_14"
  tier = "db-f1-micro"
  # ... GCP-specific config
}

// Cloud-agnostic application code
class CloudAgnosticStorage {
  constructor(provider) {
    this.provider = provider; // 'aws' | 'gcp' | 'azure'
  }

  async upload(bucket, key, data) {
    switch (this.provider) {
      case 'aws':
        return this.uploadAWS(bucket, key, data);
      case 'gcp':
        return this.uploadGCP(bucket, key, data);
      case 'azure':
        return this.uploadAzure(bucket, key, data);
    }
  }

  async uploadAWS(bucket, key, data) {
    const AWS = require('aws-sdk');
    const s3 = new AWS.S3();
    return s3.putObject({ Bucket: bucket, Key: key, Body: data }).promise();
  }

  // Similar implementations for GCP and Azure...
}

// Multi-cloud deployment strategy
async function deployMultiCloud(application) {
  // Primary deployment in AWS (us-east-1)
  const awsDeployment = await deployToAWS(application, 'us-east-1');

  // Backup deployment in GCP (us-central1) for disaster recovery
  const gcpDeployment = await deployToGCP(application, 'us-central1');

  // DNS routing with health checks
  await configureDNSRouting({
    primary: awsDeployment.url,
    backup: gcpDeployment.url,
    healthCheck: '/health'
  });

  return { primary: awsDeployment, backup: gcpDeployment };
}

// Cost optimization: Data gravity consideration
async function optimizeDataPlacement(dataLocation, computeRegion) {
  if (dataLocation.cloud === computeRegion.cloud) {
    return 'same-cloud'; // No egress costs
  } else {
    const egressCost = calculateEgressCost(dataLocation, computeRegion);
    if (egressCost > computeSavings) {
      return 'move-compute-to-data'; // Follow data gravity
    } else {
      return 'accept-egress-cost'; // Compute savings outweigh egress
    }
  }
}

```



## Trade-offs


### Advantages

- map[Single-cloud:low operational complexity, unified tooling]

- map[Single-cloud:lower data egress costs, better integration]

- map[Multi-cloud:vendor flexibility, negotiating leverage]

- map[Multi-cloud:cloud-level redundancy, reduced lock-in]




### Considerations & Drawbacks

- map[Single-cloud:high vendor lock-in, single point of failure]

- map[Single-cloud:limited negotiating leverage]

- map[Multi-cloud:high operational complexity, multiple billing systems]

- map[Multi-cloud:significant data egress costs, cross-cloud latency]







