Deploying a Highly Available Stateless WordPress Architecture on GCP

By Mesue Collins Asibong • Cloud Architecture • 7 min read Stateless WordPress Architecture on GCP

Traditional single-VM content management deployments create a brittle single point of failure where local disk exhaustion, database contention, or a zone outage takes down the entire site. In this updated architectural walkthrough, we design and deploy a 99.99% available, stateless WordPress platform on Google Cloud Platform (GCP) using Regional Managed Instance Groups (MIGs), Cloud SQL Enterprise Plus / Regional HA, Cloud Memorystore for Redis, Secret Manager, and Google Cloud Armor.

Enterprise Stateless WordPress Architecture on GCP

graph TD subgraph GCP ["Google Cloud Platform"] Armor["Cloud Armor WAF + Cloud CDN"]:::sec LB["Global External Application Load Balancer"]:::gcp subgraph MIG ["Multi-Zone Managed Instance Group"] VM1["Stateless WP Node Zone A"]:::vm VM2["Stateless WP Node Zone B"]:::vm VM3["Stateless WP Node Zone C"]:::vm end subgraph StateLayer ["Private Managed State Layer"] DB[("Cloud SQL MySQL 8.0 Regional HA")]:::db Cache[("Memorystore Redis 7.2 HA")]:::db Media[("Cloud Storage + Cloud CDN")]:::db Secrets["Secret Manager"]:::sec end Armor --> LB LB --> VM1 & VM2 & VM3 VM1 & VM2 & VM3 -->|Auth Proxy Private IP| DB VM1 & VM2 & VM3 -->|Stateless Media Offload| Media VM1 & VM2 & VM3 -->|Object Cache TCP 6379| Cache VM1 & VM2 & VM3 -.->|IAM Runtime Fetch| Secrets end classDef gcp fill:#4285F4,stroke:#fff,stroke-width:2px,color:#fff classDef vm fill:#34a853,stroke:#fff,stroke-width:2px,color:#fff classDef db fill:#f4b400,stroke:#000,stroke-width:2px,color:#000 classDef sec fill:#ea4335,stroke:#fff,stroke-width:2px,color:#fff

Step 1: Provisioning Regional HA State (Cloud SQL & Memorystore)

A stateless compute tier requires that zero session state, database files, or user uploads reside on local VM boot disks. We provision Cloud SQL for MySQL 8.0 with --availability-type=REGIONAL (synchronous primary-to-standby replication across two zones with automatic failover) over Private Services Access, alongside a High-Availability Cloud Memorystore for Redis 7.2 instance for WordPress object caching:

export PROJECT_ID=$(gcloud config get-value project)
export REGION="us-central1"

# 1. Create Regional HA Cloud SQL MySQL 8.0 Instance on Private VPC IP
gcloud sql instances create wp-db-enterprise-ha \
    --database-version=MYSQL_8_0 \
    --edition=ENTERPRISE \
    --tier=db-custom-2-8192 \
    --availability-type=REGIONAL \
    --region=$REGION \
    --network=projects/${PROJECT_ID}/global/networks/default \
    --no-assign-ip \
    --storage-auto-increase

# 2. Create Standard HA Cloud Memorystore for Redis 7.2
gcloud redis instances create wp-object-cache \
    --tier=STANDARD_HA \
    --size=2 \
    --region=$REGION \
    --redis-version=redis_7_2 \
    --network=default

Step 2: Offloading Media to Cloud Storage with `gcloud storage`

WordPress normally writes user uploads to local disk at wp-content/uploads, which breaks immediately when a load balancer round-robins requests across multiple VMs. Using the modern gcloud storage CLI (replacing legacy `gsutil`), we provision a bucket with Uniform Bucket-Level Access and serve media globally via Cloud CDN:

gcloud storage buckets create gs://wp-media-assets-${PROJECT_ID} \
    --location=$REGION \
    --uniform-bucket-level-access

gcloud storage buckets add-iam-policy-binding gs://wp-media-assets-${PROJECT_ID} \
    --member="allUsers" \
    --role="roles/storage.objectViewer"

Step 3: Secret Manager Integration & Stateless VM Golden Image

Hardcoding database passwords in `wp-config.php` or plain-text VM metadata is a security vulnerability. Instead, our Golden Image runs the Cloud SQL Auth Proxy v2 as a local systemd service (listening on `127.0.0.1:3306` with IAM database authentication or credentials pulled into tmpfs memory from Google Secret Manager at boot):

# Store DB Password in Secret Manager
printf "StrongProdSecret2026!" | gcloud secrets create wp-db-password --data-file=-

# Runtime retrieval inside startup script into in-memory /run/secrets
export WP_DB_PASS=$(gcloud secrets versions access latest --secret="wp-db-password")

Step 4: Autoscaling MIG & Cloud Armor Edge WAF Protection

Finally, we deploy our stateless instance template across three zones in a Regional Managed Instance Group (MIG) with predictive autoscaling, and attach a Google Cloud Armor security policy at the Global External Application Load Balancer to block SQLi, XSS, and XML-RPC brute-force attacks at the Google edge:

# 1. Configure Multi-Zone Autoscaling & Autohealing
gcloud compute instance-groups managed set-autoscaling wp-stateless-mig \
    --region=$REGION \
    --min-num-replicas=2 \
    --max-num-replicas=15 \
    --target-cpu-utilization=0.65 \
    --cool-down-period=90

# 2. Enforce OWASP Top 10 WAF rules at the Edge via Cloud Armor
gcloud compute security-policies create wp-edge-armor-policy
gcloud compute security-policies rules create 1000 \
    --security-policy=wp-edge-armor-policy \
    --expression="evaluatePreconfiguredWaf('sqli-v33-stable') || evaluatePreconfiguredWaf('xss-v33-stable')" \
    --action=deny-403

Summary

By decoupling stateless compute (Multi-Zone MIG) from regional high-availability state (Cloud SQL Regional HA, Memorystore Redis, and Cloud Storage) and hardening the perimeter with Secret Manager and Cloud Armor, we transform WordPress into a cloud-native, resilient web platform ready for millions of concurrent requests.