Conclusion first: Not enough. Regardless of whether your backend has deployed Kong, APISIX, Nginx, or a cloud provider's built-in API gateway, as long as the gateway is directly exposed to the public internet, when facing a real DDoS or high-frequency CC attack, often before the gateway rate limiting rules can even execute, the server's outbound bandwidth, connection table, or TLS handshake computing power is already exhausted. Truly resilient API DDoS protection cannot rely on piling all defenses onto the API gateway; it must be a three-layer division of labor and coordinated effort: "edge high-defense CDN to absorb volume and hide origin + intelligent WAF to filter malicious scripts + origin API gateway for fine-grained rate control".
If you have already deployed a gateway but still get crashed, or are about to adopt high-defense and worry about blocking your APP and payment callbacks together, the following breaks down step by step the reasons for failure, the three-layer division of labor, and the 5 most common engineering pitfalls when connecting them.
1. Why does the API gateway's built-in rate limiting fail prematurely in the face of DDoS?
Industry monitoring data has long shown that the pressure on APIs is shifting from "occasional scanning" to "normalized impact": Cloudflare's report shows API calls already account for 57% of its network's dynamic HTTP traffic, while Akamai's 2026 Internet Security Status Report points out that 87% of surveyed enterprises experienced API security incidents in the past year, with daily API attacks increasing by 113% year-over-year.
Many teams wonder: "I've already configured per-IP rate limiting and JWT authentication on the gateway, why do interfaces still instantly return 502/504 when attacked?" The reasons usually lie in the following three aspects:
- L3/L4 floods and TLS handshakes first saturate the machine hosting the gateway
The API gateway runs on your origin server or cluster VPC entry. Attackers only need to launch large-traffic UDP/SYN floods or high-frequency invalid HTTPS handshakes; before packets even enter layer 7 routing and rate limiting logic, the host's NIC bandwidth, firewall connection tracking table, and SSL decryption CPU are already exhausted. - The resource exhaustion trap: "RPS doesn't spike, but concurrency collapses first"
The OWASP API Security Top 10 lists "Unrestricted Resource Consumption (API4)" as a high-risk item. In API protection, RPS (requests per second) and concurrency (number of in-flight requests) are two different things: suppose a query API normally handles 20 RPS with an average latency of 2 seconds, occupying about 40 threads; once an attacker uses a huge pagination parameter (e.g.,page_size=20000) or complex search requests to slow the backend to 10 seconds, even if RPS is still strictly capped at 20 by the gateway, the backend in-flight concurrency instantly quintuples to 200, directly overwhelming the database connection pool and worker queue. - Distributed proxy pools make static per-IP rate limiting a dilemma
Facing low-rate, wave-like CC attacks launched from overseas proxy pools, the QPS from each exit IP is not high. If the gateway sets the per-IP threshold too strict, legitimate users sharing a NAT exit or mobile base station IP will see widespread 429 errors; if set too loose, the aggregated requests will still overwhelm the database.
2. Three-layer coordinated architecture: what do high-defense CDN, WAF, and API gateway each handle?
To change API protection from "single-point hard resistance" to "defense in depth", you must first clarify boundaries: the edge is responsible for blocking "large traffic, fake clients, and known malformed packets" outside the origin, while the gateway focuses solely on handling "authenticated business requests".

| Protection Layer | Deployment Location | Core Responsibilities | What It Should Never Handle |
|---|---|---|---|
| Edge High-Defense CDN | Global edge nodes (outermost layer) | Anycast distributed scrubbing of L3/L4 floods, TLS handshake offloading, blocking basic high-frequency CC, hiding real origin IP | Not responsible for validating business JWT permissions and tenant quotas |
| Intelligent WAF | Same link at edge nodes | Intercepting common OWASP injections/command execution, scanners, malicious scripts, and abnormal bot behavior | Do not enable browser JS challenges or slider CAPTCHAs on API paths |
| Origin API Gateway | Customer's own servers/cluster | Validating Token/API Key, rate limiting by account/tenant/API cost, controlling payload size and timeout circuit breaking | Do not expose it naked on the public internet to hard-resist network-layer floods with gateway CPU |
In actual selection, splitting high-defense, WAF, and acceleration across three vendors for serial deployment not only complicates configuration but also adds unnecessary API latency due to cross-network multi-hop forwarding, and may even leave gaps in policy coordination.
If you want to establish the two outer gates with minimal modification cost, consider directly using RockCloud High-Defense CDN (https://rockcloud.net/security/) as the edge entry for APIs:
- Same-path DDoS and CC scrubbing: Adopts Anycast distributed scrubbing architecture; L3/L4 DDoS resistance and L7 CC resistance are on the same request path, so you don't need to separately purchase high-defense IP and CC scrubbing packages; once connected, the real origin IP is hidden.
- Smooth access without changing NS: Simply add a CNAME record at your original DNS provider to connect, without migrating domain NS; during the switch, old and new links run in parallel, making it safer for live APPs and third-party services.
- Intelligent WAF and custom exceptions: One-click enable RockCloud Intelligent WAF (https://rockcloud.net/security/waf/) in the control panel; it is based on the OWASP Core Rule Set (covering SQL injection, XSS, file inclusion, command injection, scanner and bot detection, etc.) plus machine learning to identify unknown malicious requests; for API-specific business fields or signature features, the security technical team can assist in configuring custom rules and exception allowlists.
As for the existing backend Kong, APISIX, Nginx, or self-developed microservice gateway, it remains on your own cloud host as the origin (RockCloud does not sell servers, focusing on providing perimeter network and security protection), receiving only cleaned back-to-origin traffic, and concentrating on Token authentication, tenant quotas, and business circuit breaking.
3. The 5 most common practical pitfalls when chaining the three defense layers
Many teams have bought high-defense and WAF and configured API gateways, yet still encounter problems upon launch; nine out of ten times they step on the following five integration details:
Pitfall 1: After connecting to high-defense CDN, the gateway sees all users as the same IP
After the high-defense node proxies back to origin, the origin gateway by default reads $remote_addr as the high-defense node's back-to-origin exit IP, not the end user's real IP. If the gateway is not correctly configured for transparent restoration, the original rate limit rule of "50 requests per second per IP" becomes "all users site-wide share 50 requests per second", instantly cutting off normal business.
- Fix: Configure
real_ipin the origin Nginx or API gateway (e.g.,set_real_ip_fromonly fill in the high-defense CDN's official back-to-origin IP ranges,real_ip_header X-Forwarded-For), and ensure only forwarding headers from the back-to-origin whitelist are trusted, preventing attackers from forgingX-Forwarded-Forto bypass gateway rate limiting.
Pitfall 2: Directly applying web "JS challenge / 5-second shield" kills APPs and callbacks
Pop-up sliders or JS challenges are very effective when a website is attacked, but API callers are mobile APP code, IoT terminals, or WeChat/Alipay/Stripe webhook servers, which do not execute browser JavaScript at all. This is why mainstream cloud vendor documentation explicitly states: strict human verification mode is only for web/H5, and must not be directly applied to APIs or native APPs.
- Fix: Separate policies for web page domains (
www) and API domains (api); disable browser JS challenges on API policies, and instead use fine-grained interception based on protocol specifications, request header features, bot behavior identification, and key signatures; whitelist third-party payment callback paths according to specifications (for detailed steps, see "How to Whitelist When WAF Blocks Payment Callbacks" and "How to Implement API DDoS Protection: Architecture for Handling Multi-Vector Mixed Attacks and Avoiding False Positives on Legitimate Clients").
Pitfall 3: Only changed CNAME without changing origin IP, attackers bypass CDN and hit the gateway directly
As long as your API server has ever been directly resolved to the public internet before adopting high-defense, historical DNS record lookup platforms may have stored the old IP; in addition, test subdomains, email notification headers, or leaked configuration files can also expose the origin address. Once attackers obtain the real IP and attack the origin directly, even the strongest high-defense perimeter is completely bypassed.
- Fix: After connecting protection, you must thoroughly lock down at the origin security group/firewall level—only allow high-defense CDN back-to-origin node IPs to access ports 80/443, and drop all other public inbound traffic; if you urgently connect to RockCloud during an attack, be sure to simultaneously change the origin server IP and lock down the back-to-origin whitelist (for a complete leak self-check list, see "Why Am I Still Breached After Connecting to High-Defense CDN?").
Pitfall 4: Lengthened link causes cross-border timeouts, client auto-retries amplify traffic
APIs are extremely sensitive to jitter. If the cross-border return path from the high-defense node to the origin takes a detour, API latency rises from 150ms to 2s, mobile SDKs trigger automatic retries on timeout, and a single normal call instantly becomes 3-4 concurrent back-to-origin requests, crashing the origin itself.
- Fix: Enable edge node support for HTTP/3 and TLS 1.3 0-RTT to compress handshake time, and standardize client exponential backoff retry mechanisms. If your service is deployed overseas but domestic users frequently call the API, you can combine RockCloud Global Acceleration Network (https://rockcloud.net/network/) and CN2 China Acceleration Dedicated Line (https://rockcloud.net/network/cn2/), using nodes around China in Hong Kong, Japan, South Korea, Singapore, etc., connecting back to mainland China via Telecom CN2 GIA, Unicom AS9929, and Mobile CMI direct connections, exempt from ICP filing, and supporting custom back-to-origin retries and backup origin rules, reducing the risk of avalanche caused by packet loss during peak hours.
Pitfall 5: Billed by request count or elastic scrubbing, long-term CC leads to astronomical bills
API request counts are naturally much higher than ordinary static pages. If high-defense or CDN charges by millions of requests or tiers based on post-scrubbing malicious traffic, a low-frequency persistent CC war of attrition lasting weeks may not bring down the business, but the bill will explode first.
- Fix: Verify billing details before signing. RockCloud plans (https://rockcloud.net/pricing/) by default charge monthly based on a fixed peak, with unlimited traffic and requests; acceleration and DDoS/CC defense, intelligent WAF, and free fully automated SSL are all included in the same plan, so defense does not need to be purchased separately (CN2 mainland acceleration dedicated line and anti-hijacking are billed separately); you can confirm specifications with customer service and apply for a free test first, effectively avoiding uncontrollable bills during attacks.
4. Implementation self-check list: 5-step sequence for launch or emergency access
Whether you are proactively refactoring your architecture or your API is already under high-frequency attack, you can quickly implement the following 5 steps:
- Inventory APIs and exposure surface: Go through shadow APIs, old version debug interfaces, and undocumented interfaces; take offline what can be taken offline, and distinguish web and pure API entries by domain or path.
- Smooth edge access: Point API domains to RockCloud High-Defense CDN via CNAME, use parallel old and new links for canary switching, and enable free automated SSL and HTTP/3.
- Verify real IP and WAF exceptions: Enable Intelligent WAF in the control panel, check origin gateway logs to confirm
real_ipis restored accurately, and have the security team assist in configuring exception rules for SDK features and webhook callbacks; to further govern low-frequency proxy CC, you can tighten behavior baselines with "How to Defend Against CC Attacks on APIs and Dynamic Interfaces". - Lock down origin and gateway rate limiting: After confirming the high-defense link is stable, if old IPs are exposed, immediately change the origin server IP, and the firewall should only allow back-to-origin nodes; in the origin API gateway, complete per-user/token quotas, payload size limits, and slow API circuit breaking (API4 protection requirements).
- Connect alerts and emergency channels: Enable traffic/bandwidth reports, network logs, and Telegram real-time data push (https://rockcloud.net/features/) in the RockCloud control panel, along with gateway QPS and P99 latency monitoring; if your API is currently under sustained attack and you need immediate switching to stop the bleeding, you can directly contact emergency access via the Security Response Contact Page or official Telegram (https://t.me/rockclouds).
Leave edge volume resistance to high-defense and WAF, leave identity and quotas to the API gateway, and with each of the three layers fulfilling its role with strict boundaries, your API will truly be capable of stable operation under real attacks.