Skip to content
GuanxiLink 关系
  • FinOps
  • CloudFront
  • AWS
  • WordPress
  • China

Serving global content (Spain and China) on a minimal budget: why we traded RDS Multi-AZ for CloudFront and aggressive caching

Real case: a Spain-China website on one Docker instance and aggressive CloudFront caching instead of RDS Multi-AZ and load balancers. Costs and risks.

By Aldo Borghes Published 5 min read

Visual comparison between an architecture with RDS Multi-AZ and a load balancer and a lean architecture with CloudFront and aggressive caching

Key takeaways

  • On a content website, RDS Multi-AZ, an Application Load Balancer and a NAT Gateway pay for high availability that visitors almost never notice.
  • If CloudFront serves the vast majority of requests from cache, a short origin outage is absorbed at the edge thanks to stale-if-error.
  • A single Docker instance with daily S3 backups, EBS snapshots and Terraform rebuilds delivers a recovery time of minutes at up to 70% lower cost.
  • We do not recommend dropping Multi-AZ when there are critical writes, a 99.95% SLA or compliance requirements.

A company that connects Spanish suppliers with Chinese buyers asked us for something that sounds simple: a bilingual website (Spanish and Chinese) that loads fast in Madrid and in Shanghai, without the cloud bill eating the margin.

The first proposal they had received from another vendor was the “textbook architecture”: Application Load Balancer, an Auto Scaling group, RDS Multi-AZ, a NAT Gateway and a generic CDN in front. Technically flawless. Economically absurd for a website where the vast majority of requests are reads of content that changes a few times a week.

This article explains what we built instead, why we consciously gave up RDS Multi-AZ, and which risks we accepted (and which we did not).

The problem with “enterprise” architecture on a content site

Every component of the textbook design makes sense on its own. Together, for this use case, they are over-engineering:

  • RDS Multi-AZ keeps a standby replica in another Availability Zone. In practice you pay for twice the instance and storage, for a failover your visitors would only notice if the database died exactly while they were browsing.
  • Application Load Balancer has a fixed hourly charge plus capacity units, even with a single instance behind it.
  • NAT Gateway charges per hour and per processed GB, just so private instances can download updates.
  • A generic CDN with a European origin does not fix the main problem: from several Chinese provinces the experience was still unstable.

In other words: the expensive part of the bill was buying database high availability, while the part that actually hurt Chinese visitors (network latency) was still unsolved.

The right question: what does the business actually need?

Before drawing boxes, we agreed on the real requirements with the client:

Requirement “Enterprise” answer Our answer
Fast load in Spain and China Generic CDN + EU origin APAC origin + CloudFront with aggressive caching
Do not lose content (RPO) RDS Multi-AZ Daily backups to S3 + EBS snapshots
Recover fast (RTO) Automatic failover Rebuild with Terraform + Ansible in minutes
Stay online if the origin fails Several instances behind an ALB The edge keeps serving cache (stale-if-error)
Start-up budget — One well-sized instance

The key is the fourth row. If 95% or more of requests are served from the edge, the origin stops being critical to the visitor experience. A short origin outage is absorbed by the cache, not by the user.

The architecture we deployed

Visitors (ES / CN)
        │
        ▼
Amazon CloudFront  ── TLS, HTTP/3, Brotli, aggressive caching, security headers
        │  (only on cache miss or /wp-admin)
        ▼
Single EC2 instance (Docker)
 ├── Traefik      → origin TLS and routing
 ├── WordPress    → PHP-FPM with OPcache
 └── MariaDB      → encrypted gp3 EBS volume
        │
        ├── Daily backup (dump + files) → S3 with SSE-S3 encryption and lifecycle rules
        └── Scheduled EBS snapshots

Concrete decisions:

  1. A single instance with Docker Compose. WordPress, MariaDB and Traefik run in containers with restart policies and health checks. If a container hangs, a small self-healing service restarts it without human intervention.
  2. Database on the same host. For a content site, local PHP ↔ MySQL latency is lower than going to RDS, and write volume is minimal.
  3. CloudFront as the primary delivery layer. It is not an “extra” in front of the server: it is the server for the vast majority of traffic.
  4. Everything in Terraform. Instance, volumes, security groups, distribution and DNS records can be recreated from scratch with a single terraform apply.

Aggressive caching without breaking WordPress

“Aggressive caching” does not mean caching everything blindly. It means deciding explicitly what is cached, for how long, and how it is invalidated:

  • Hashed static assets (CSS, JS, optimised images): Cache-Control: public, max-age=31536000, immutable.
  • Public HTML: browsers always revalidate (max-age=0), but the edge keeps it for a long time (s-maxage) and we invalidate on publish.
  • Private areas (/wp-admin/*, /wp-login.php, previews): no caching, forwarding cookies and headers to the origin.
  • Resilience: stale-if-error lets CloudFront keep serving the last valid copy if the origin returns errors.

In Terraform, the behaviour for the admin area looks like this:

# Author: Aldo Borghes - GuanxiLink
data "aws_cloudfront_cache_policy" "disabled" {
  name = "Managed-CachingDisabled"
}

data "aws_cloudfront_origin_request_policy" "all_viewer" {
  name = "Managed-AllViewer"
}

resource "aws_cloudfront_distribution" "site" {
  # ... origin, certificate and default behaviour with aggressive caching ...

  ordered_cache_behavior {
    path_pattern             = "/wp-admin/*"
    target_origin_id         = "wordpress-origin"
    viewer_protocol_policy   = "redirect-to-https"
    allowed_methods          = ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
    cached_methods           = ["GET", "HEAD"]
    cache_policy_id          = data.aws_cloudfront_cache_policy.disabled.id
    origin_request_policy_id = data.aws_cloudfront_origin_request_policy.all_viewer.id
    compress                 = true
  }
}

And on the origin, a consistent header for public HTML:

# Author: Aldo Borghes - GuanxiLink
add_header Cache-Control "public, max-age=0, s-maxage=86400, stale-while-revalidate=600, stale-if-error=86400";

Does your website take more than 3 seconds to load from China? Request a free latency diagnosis and we will send you the Europe vs. Asia comparison for your own URL.

What if the database goes down?

This is the honest question to ask before giving up Multi-AZ. Our answer on this project:

  • RPO (maximum data loss): 24 hours, accepted by the client because content is published a few times a week and the editorial team keeps the originals. Bringing it down to one hour is one more cron job, not a database that costs twice as much.
  • RTO (recovery time): minutes. Recovery means bringing the instance up with Terraform, running the Ansible playbook and restoring the latest backup from S3.
  • Visitor impact: minimal. During recovery, CloudFront keeps serving cached HTML and assets. Only the admin panel is temporarily unavailable.

What we did not accept: untested backups. A backup that has never been restored is a hypothesis. We rehearsed a full restore in a temporary environment and documented the procedure.

Results

  • Up to 70% lower infrastructure cost compared with the ALB + RDS Multi-AZ + NAT Gateway proposal.
  • Most traffic is resolved at the edge, so the origin runs well below capacity and a modest instance is enough.
  • The experience from China no longer depends on the route to Europe: content is delivered from nearby edge locations in Asia.
  • The whole platform is reproducible: the same code deploys an identical staging environment in minutes.

When we do NOT recommend this approach

Giving up Multi-AZ is a business decision, not a dogma. We would not do it if:

  • There are many critical writes (orders, payments, bookings) that cannot be lost, even for minutes.
  • There is a contractual SLA of 99.95% or higher on the transactional side.
  • A compliance framework requires database high availability.

In those cases we split responsibilities: the transactional side gets its managed, highly available database, while public content still sits behind CloudFront with aggressive caching. You still save money, without gambling with the client’s business.

Checklist for your own project

  1. Measure what share of your requests are cacheable reads.
  2. Define RPO and RTO with the business, not by default.
  3. Make the CDN the primary layer and design cache rules per content type.
  4. Move the origin close to your most latency-sensitive market (for China, APAC).
  5. Automate backups, snapshots and, above all, restores.
  6. Codify everything in Terraform so rebuilding is a command, not a sleepless night.

If you want us to review your architecture with this approach, or you would rather host your website on our dedicated nodes in Paris and Singapore, already tuned for this, request the free audit right below.

About the author

Aldo Borghes · Founder & Cloud Architect (AWS · Alibaba Cloud)

Founder of GuanxiLink. Designs and operates multi-cloud infrastructure on AWS and Alibaba Cloud for Western companies that sell in Asia and China, including GuanxiLink’s dedicated nodes in Paris and Singapore, all codified in Terraform.

Back to all articles