Cloud Computing 16 min read

How to Build a High‑Availability Web Architecture on JD Cloud with Docker and WordPress

This guide walks through designing and deploying a highly available, scalable WordPress web application on JD Cloud using elastic IaaS, PAAS services, load balancers, HA groups, Docker containers, MySQL, Redis, and automated scripts to demonstrate fault‑tolerance across availability zones.

JD Cloud Developers
JD Cloud Developers
JD Cloud Developers
How to Build a High‑Availability Web Architecture on JD Cloud with Docker and WordPress

JD Cloud High‑Availability Architecture Design

The scenario simulates a typical web application requiring public IP/domain access, with separate layers for entry, application, cache, and database, achieving zone‑level redundancy.

Resource Requirements

Key resources include:

2–3 host instances (2C8G, 50G system disk) with public IP for demo purposes.

1 HA group using an application host template, configured for auto‑scaling and CPU‑threshold alerts.

MySQL 5.7 instance (2C8G, 50G SSD) and a Redis instance.

Load balancer with a public IP, NAT gateway, and bastion host in the public subnet.

CFS shared storage mounted to all HA hosts for WordPress data.

Application Deployment

Prepare the environment by creating a /wp directory, installing Docker, mounting CFS, and adding startup scripts to /etc/rc.local for automatic mounting and service launch.

# Create application data directory and set permissions
mkdir -p /wp
chmod 777 /wp
yum install docker vim -y
systemctl enable docker
systemctl start docker
# Mount CFS
yum install nfs-utils -y
systemctl enable rpcbind
systemctl start rpcbind
mount -t nfs -o vers=3 -o noresvport 10.0.0.200:/cfs /wp
# Add to rc.local for boot-time execution
cat <<'EOF' >/etc/rc.local
#!/bin/bash
mount -t nfs -o vers=3 -o noresvport 10.0.0.200:/cfs /wp
bash /root/start.sh
EOF
chmod +x /etc/rc.d/rc.local
# Pull and run WordPress container
docker pull wordpress
docker run -d --name=wordpress --restart=unless-stopped -p 443:443 -p 80:80 -v /wp:/var/www/html wordpress

Configure WordPress to display the host IP and hostname by adding shortcodes in function.php and using them in pages.

function get_the_user_ip() {
  if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
    $ip = $_SERVER["HTTP_CLIENT_IP"];
  } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
    $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
  } else {
    $ip = $_SERVER["REMOTE_ADDR"];
  }
  return apply_filters("wpb_get_ip", $ip);
}
add_shortcode("show_ip", "get_the_user_ip");

function get_hostname() {
  $hostname = gethostname();
  echo "$hostname
";
  return apply_filters("hostname", $hostname);
}
add_shortcode("show_hostname", "get_hostname");

HA Group, Instance Template, and Load Balancer Configuration

After confirming the host can auto‑restart WordPress, create an image from the host to serve as the instance template for the HA group. The HA group automatically scales new instances, which mount the same CFS and register with the load balancer.

The load balancer listener points to the HA group backend and includes health checks.

Application Demonstration

Scripts simulate traffic and stress to trigger auto‑scaling:

#!/bin/bash
for i in {1..15000}; do
  curl 100.126.35.4
  echo $i
  echo $(date +%T)
  sleep 3
done

Another script targets a single host to show the impact of a host failure.

#!/bin/bash
for i in {1..15000}; do
  curl 100.126.38.16
  echo $i
  echo $(date +%T)
  sleep 3
done

Stress testing with stress --CPU 2 drives the HA group to launch additional instances, which are automatically added to the load balancer.

Failover tests include shutting down a host, simulating RDS primary failure, and killing the Redis primary; the system continues serving traffic without interruption.

The entire process demonstrates a production‑grade, zone‑redundant, auto‑scaling web service on JD Cloud.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

cloud computinghigh availabilityAuto ScalingLoad BalancerInfrastructure as CodeWordPress
JD Cloud Developers
Written by

JD Cloud Developers

JD Cloud Developers (Developer of JD Technology) is a JD Technology Group platform offering technical sharing and communication for AI, cloud computing, IoT and related developers. It publishes JD product technical information, industry content, and tech event news. Embrace technology and partner with developers to envision the future.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.