流媒体平台 S2.dev 的工程团队决定放弃使用 AWS Route53,转而构建并部署自定义的权威 DNS 系统,以解决因 API 速率限制导致的业务中断问题 1。此前,S2.dev 依赖 AWS Route53 来支持无限量的 Basin(子域名)创建,但 Route53 的 API 限制约为每秒 5 次 UPSERT 操作 1。当恶意用户快速创建数万个 Basin 时,Route53 配额迅速饱和,导致正常 DNS 更新积压长达数小时 1。鉴于新方案要求 DNS 记录具备强一致性,即 Basin 创建后地址需立即可解析,自建系统成为必然选择 1。
在技术实现上,S2.dev 利用 Go 语言和 miekg/dns 库开发了新的 DNS 解析器,该解析器直接通过 SELECT 查询 Google Cloud Spanner 数据库来获取记录 1。为了应对潜在的 NXDOMAIN 等 DDoS 攻击风险——这类攻击会因每次无效查询触发数据库查找而耗尽资源,团队引入了 Cloudflare DNS Firewall 作为前置防护层 1。最终形成的架构中,主域名由 Cloudflare 管理,basin 子域委托给 Cloudflare DNS Firewall,后端连接至分布在两个区域的 GKE 集群上的自定义 DNS 服务器 1。此外,证书使用的 ACME DNS-01 挑战仍保留在独立的 Route53 区域中,以避免处理动态 TXT 记录带来的复杂性 1。新系统上线后运行稳定,成功实现了 Basin 记录的即时一致性解析 1。
The engineering team at streaming platform S2.dev abandoned AWS Route53 for their Basin subdomain service after hitting API rate limits that caused significant service disruptions. The original plan relied on Route53, but its API allowed only approximately five UPSERT operations per second 1. When malicious users rapidly created tens of thousands of Basins, the quota was saturated, leading to a backlog of legitimate DNS updates that persisted for hours 1. To resolve this, the team developed a custom authoritative DNS server designed to support unlimited Basin creation while ensuring immediate consistency for new records 1.
The new system is built using the Go programming language and leverages the miekg/dns library to parse queries directly from Google Cloud Spanner via SELECT statements 1. This architecture ensures that addresses become resolvable immediately upon Basin creation, satisfying strict consistency requirements 1. However, the design raised concerns about DDoS attacks specifically targeting NXDOMAIN responses, where each invalid query would trigger a database lookup 1. To mitigate this risk, the team deployed Cloudflare DNS Firewall as a protective front layer 1. In the final setup, the main domain remains managed by Cloudflare, while basin subdomains are delegated to Cloudflare DNS Firewall, which routes traffic to custom DNS servers distributed across two regions in Google Kubernetes Engine (GKE) clusters 1. Notably, ACME DNS-01 challenges for certificates continue to operate within a separate Route53 zone to avoid handling dynamic TXT records 1.
评论
还没有评论,欢迎留下第一条。