- Latency
- China
- CloudFront
- Alibaba Cloud
- Terraform
0.3s latency in China from outside the country: a real architecture comparison (Paris vs. Singapore + CloudFront) automated with Terraform
The same website measured from mainland China on three architectures: Europe + CDN, Singapore direct and Singapore + CloudFront. Results and Terraform.
By Aldo Borghes Published 4 min read
Key takeaways
- Measured from mainland China, the same website was variable with a Paris origin and a generic CDN, about 4.5s with a direct Singapore origin and about 0.3s with Singapore + CloudFront / Aliyun Edge.
- An ICP licence is only mandatory when the site is hosted in, or served from CDN nodes inside, mainland China; serving it from Singapore or Hong Kong does not require one.
- Slowness in China comes mainly from congested international links, TCP and TLS round trips, and blocked resources such as Google Fonts or reCAPTCHA.
- Every scenario is defined in Terraform so it can be deployed, measured and destroyed repeatably.
When a client tells us “our website is slow in China”, it is almost never a server problem. It is a problem of geography, network routes and blocked resources. To prove it with data, we deployed the same website on three different architectures and measured it from mainland China.
Spoiler: the gap between the worst and the best is not 20%. It is going from an unstable or multi-second experience to ~0.3s, a native experience, without an ICP licence.
Why China is a special case
Serving a website to users in mainland China from outside the country has three enemies:
- Congested international links. All traffic entering or leaving China goes through a limited number of interconnection points. At peak hours packet loss and latency spike, and each carrier (China Telecom, China Unicom, China Mobile) behaves differently.
- The number of round trips. Before receiving a single byte of HTML, the browser needs DNS, a TCP connection and a TLS handshake. At 250 ms per round trip, the initial handshake alone costs close to a second.
- Resources blocked by the Great Firewall. Google Fonts, reCAPTCHA, Google Analytics, some maps and JavaScript CDNs do not load. The browser waits until it times out and the page looks “frozen” even if your server responds quickly.
Do I need an ICP licence?
An ICP licence (备案) is mandatory when you host the website in mainland China or use CDN nodes inside mainland China. If you serve content from outside (Hong Kong, Singapore, Japan…), it is not required.
That comes with a cost and a benefit:
- Benefit: you avoid a process that requires a legal entity or representative in China and can take weeks.
- Cost: you have no servers inside the country, so delivery from the closest, best-connected locations must be squeezed to the maximum.
Our architecture is designed precisely for that scenario. If your business does need a presence inside mainland China, we guide you through the ICP process with Alibaba Cloud; but in many B2B cases it is not needed.
Methodology
To keep the comparison fair:
- Same website, same content and same page weight in all three scenarios.
- Measurements from test nodes in mainland China, spread across several provinces and the three major carriers, using Chinese multi-node testing services (such as ITDOG, 17CE or Boce).
- Several time slots, including the evening peak in China.
- Timing breakdown with
curlto separate DNS, connection, TLS and first byte:
#!/usr/bin/env bash
# Author: Aldo Borghes - GuanxiLink
# Latency breakdown for a URL (run it from a test node in China).
URL="${1:-https://example.com/}"
for i in 1 2 3 4 5; do
curl -o /dev/null -s -w \
"dns=%{time_namelookup}s tcp=%{time_connect}s tls=%{time_appconnect}s ttfb=%{time_starttransfer}s total=%{time_total}s\n" \
"$URL"
done
The three scenarios and their results
| Architecture | Setup | Result from China |
|---|---|---|
| Europe + CDN | Origin in Paris (eu-west-3) with a generic CDN |
Variable: unstable in certain provinces |
| Singapore direct | Origin in Singapore (ap-southeast-1), no edge |
~4.5s: depends on the fibre route |
| GuanxiLink | Singapore + CloudFront / Aliyun Edge | ~0.3s: native experience |
How to read it:
- Europe + CDN works well in some areas and badly in others. When the request is not cached, or the CDN node picked has a poor route into China, the user pays for the full trip to Europe.
- Singapore direct brings the origin closer, but every visit still negotiates TCP and TLS over the international link, and the result depends too much on the carrier and the time of day.
- Singapore + edge terminates TLS close to the user, serves HTML and assets from cache and takes advantage of HTTP/3 and Brotli. The origin is barely involved.
Want to see these numbers for your own website? Get your free latency test or migrate your site to our dedicated nodes in Paris and Singapore within 24–48h.
Automated with Terraform
A comparison is only useful if it can be repeated. That is why each scenario is code: one terraform apply brings the environment up, one terraform destroy removes it. The core is one provider per region and a CloudFront distribution with a Singapore origin:
# Author: Aldo Borghes - GuanxiLink
provider "aws" {
alias = "paris"
region = "eu-west-3"
}
provider "aws" {
alias = "singapore"
region = "ap-southeast-1"
}
# CloudFront certificates are always issued in us-east-1.
provider "aws" {
alias = "us_east_1"
region = "us-east-1"
}
data "aws_cloudfront_cache_policy" "optimized" {
name = "Managed-CachingOptimized" # Gzip + Brotli enabled
}
resource "aws_cloudfront_distribution" "apac" {
enabled = true
is_ipv6_enabled = true
http_version = "http2and3"
price_class = "PriceClass_All" # includes Hong Kong, Taiwan and the rest of Asia
origin {
domain_name = aws_s3_bucket.singapore_origin.bucket_regional_domain_name
origin_id = "singapore-origin"
origin_access_control_id = aws_cloudfront_origin_access_control.oac.id
}
default_cache_behavior {
target_origin_id = "singapore-origin"
viewer_protocol_policy = "redirect-to-https"
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
cache_policy_id = data.aws_cloudfront_cache_policy.optimized.id
compress = true
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
viewer_certificate {
acm_certificate_arn = aws_acm_certificate_validation.site.certificate_arn
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.2_2021"
}
}
The Paris node stays in place for European traffic and as a secondary origin, using the same code parameterised by region.
When we add Aliyun Edge
For clients with heavy traffic in specific provinces we add Alibaba Cloud CDN with coverage outside mainland China, which does not require ICP and has excellent interconnection with Chinese carriers. Traffic is split at DNS level with geolocation routing:
# Author: Aldo Borghes - GuanxiLink
resource "aws_route53_record" "www_china" {
zone_id = data.aws_route53_zone.main.zone_id
name = "www.example.com"
type = "CNAME"
ttl = 300
set_identifier = "china-aliyun-edge"
records = [var.aliyun_cdn_cname]
geolocation_routing_policy {
country = "CN"
}
}
resource "aws_route53_record" "www_default" {
zone_id = data.aws_route53_zone.main.zone_id
name = "www.example.com"
type = "CNAME"
ttl = 300
set_identifier = "default-cloudfront"
records = [aws_cloudfront_distribution.apac.domain_name]
geolocation_routing_policy {
country = "*"
}
}
The front-end matters too
The best network in the world cannot make up for a page waiting on Google Fonts. Before closing any optimisation we check:
- No blocked dependencies: system or self-hosted fonts, no Google reCAPTCHA, China-compatible analytics.
- Controlled weight: modern image formats, lazy loading and minimal JavaScript.
- Correct cache headers: hashed assets immutable for a year, HTML revalidated.
- Forms that work in China: reachable endpoints and no blocked captchas.
Conclusion
A Western website can feel native in China without an ICP licence and without an enterprise-sized bill. The recipe is unglamorous but very effective: APAC origin, edge with aggressive caching, a clean front-end and everything automated with Terraform so you can measure, compare and repeat.
If you want to know which scenario your website is in today, we will measure it for free.
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.