ประโยชน์ด้านประสิทธิภาพ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บทนำ: สาเหตุและการลดเวลาในการตอบสนองของ DNS
เมื่อหน้าเว็บซับซ้อนยิ่งขึ้น การอ้างอิงทรัพยากรจากโดเมนจำนวนมาก การค้นหา DNS จึงเป็นจุดคอขวดที่สำคัญในการท่องเว็บ
เมื่อใดก็ตามที่ไคลเอ็นต์ต้องการค้นหารีโซลเวอร์ DNS ผ่านเครือข่าย เวลาในการตอบสนองที่แนะนำจะมีนัยสำคัญ ทั้งนี้ขึ้นอยู่กับความใกล้เคียงและจำนวนของเนมเซิร์ฟเวอร์ที่รีโซลเวอร์ต้องค้นหา (มีมากกว่า 2 ประเภทซึ่งเกิดขึ้นไม่บ่อยนักแต่อาจเกิดขึ้นได้)
ดูตัวอย่างภาพหน้าจอต่อไปนี้แสดงเวลาที่เครื่องมือวัดประสิทธิภาพเว็บของ Page Speed รายงานไว้
แต่ละแถบแสดงทรัพยากรที่อ้างอิงจากหน้าเว็บ ส่วนกลุ่มสีดำจะระบุถึงการค้นหา DNS
ในหน้านี้จะมีการค้นหา 13 รายการภายใน 11 วินาทีแรกที่โหลดหน้าเว็บ
แม้ว่าการค้นหาหลายครั้งจะทำพร้อมกัน แต่ภาพหน้าจอแสดงให้เห็นว่าต้องใช้เวลาในการค้นหาแบบอนุกรม 5 ครั้ง ซึ่งคิดเป็นหลายวินาทีจากทั้งหมด 11 วินาทีในการโหลดหน้าเว็บ

เวลาในการตอบสนองของ DNS มี 2 องค์ประกอบดังนี้
- เวลาในการตอบสนองระหว่างไคลเอ็นต์ (ผู้ใช้) กับเซิร์ฟเวอร์แปลง DNS
ในกรณีส่วนใหญ่ สาเหตุส่วนใหญ่มักเกิดจากข้อจํากัดของเวลารับส่งข้อมูล (RTT) ตามปกติในระบบเครือข่าย ได้แก่ ความห่างทางภูมิศาสตร์ระหว่างเครื่องไคลเอ็นต์และเซิร์ฟเวอร์ ความคับคั่งของเครือข่าย การสูญเสียแพ็กเก็ตและความล่าช้าในการส่งซ้ำ (โดยเฉลี่ย 1 วินาที) เซิร์ฟเวอร์ทำงานหนักเกินไป การโจมตีแบบปฏิเสธการให้บริการ และอื่นๆ
- เวลาในการตอบสนองระหว่างเซิร์ฟเวอร์การแปลงค่าและเนมเซิร์ฟเวอร์อื่นๆ
แหล่งที่มาของเวลาในการตอบสนองนี้มีสาเหตุหลักมาจากปัจจัยต่อไปนี้
- ไม่พบแคช
หากการตอบสนองจากแคชของรีโซลเวอร์ทำไม่ได้ แต่ต้องมีการค้นหาเนมเซิร์ฟเวอร์อื่นซ้ำๆ เวลาในการตอบสนองของเครือข่ายที่เพิ่มก็จะต้องได้รับการพิจารณา โดยเฉพาะอย่างยิ่งหากเซิร์ฟเวอร์ที่เชื่อถือได้อยู่ห่างไกลกันในทางภูมิศาสตร์
- การจัดสรรน้อยเกินไป
หากรีโซลเวอร์ DNS ทำงานหนักเกินไป รีโซลเวอร์จะต้องจัดคิวคำขอและคำตอบในการแก้ปัญหา DNS และอาจเริ่มทิ้งและส่งแพ็กเก็ตอีกครั้ง
- การเข้าชมที่เป็นอันตราย
แม้ว่าบริการ DNS จะมีการจัดสรรมากเกินไป แต่การรับส่งข้อมูล DoS ก็อาจทำให้เซิร์ฟเวอร์มีภาระงานเกินควรได้
ในทำนองเดียวกัน การโจมตีรูปแบบ Kaminsky อาจเกี่ยวข้องกับรีโซลเวอร์น้ำท่วมซึ่งมีคำค้นหาที่รับประกันว่าจะข้ามแคชและต้องส่งคำขอขาออกสำหรับการแก้ไข
เราเชื่อว่าปัจจัยการพลาดของแคชเป็นสาเหตุหลักของเวลาในการตอบสนองของ DNS ซึ่งเราจะกล่าวถึงรายละเอียดเพิ่มเติมด้านล่าง
ไม่พบข้อมูลในแคช
แม้ว่ารีโซลเวอร์จะมีทรัพยากรในเครื่องมากมาย แต่ความล่าช้าพื้นฐานที่เกี่ยวข้องกับการติดต่อกับเนมเซิร์ฟเวอร์ระยะไกลก็หลีกเลี่ยงได้ยาก
กล่าวคือ สมมติว่ามีการจัดสรรรีโซลเวอร์ดีพอเพื่อให้ Hit แคชใช้เวลาเป็นศูนย์ในฝั่งเซิร์ฟเวอร์ การไม่พบแคชจะมีราคาแพงมากในแง่ของเวลาในการตอบสนอง
ในการจัดการการสูญหาย รีโซลเวอร์จะต้องสื่อสารกับเนมเซิร์ฟเวอร์ภายนอกอย่างน้อย 1 รายการ แต่บ่อยครั้งก็มักจะเป็นเซิร์ฟเวอร์ภายนอกอย่างน้อย 2 รายการ
เมื่อใช้โปรแกรมรวบรวมข้อมูลเว็บของ Googlebot เราพบว่าเนมเซิร์ฟเวอร์ที่มีการตอบสนองใช้เวลาเฉลี่ย 130 มิลลิวินาที
อย่างไรก็ตาม คำขอทั้ง 4-6% จะหมดเวลาเนื่องจากแพ็กเก็ต UDP สูญหายและเซิร์ฟเวอร์เข้าถึงไม่ได้
หากเราพิจารณาข้อผิดพลาดต่างๆ เช่น แพ็กเก็ตสูญหาย เนมเซิร์ฟเวอร์ที่ใช้งานไม่ได้ ข้อผิดพลาดในการกำหนดค่า DNS ฯลฯ เวลาในการแก้ปัญหาเฉลี่ยจากต้นทางถึงปลายทางตามจริงคือ 300-400 มิลลิวินาที
อย่างไรก็ตาม มีความแปรปรวนสูงและมีระยะเวลายาว
แม้ว่าอัตราการพลาดของแคชอาจแตกต่างกันไปสำหรับเซิร์ฟเวอร์ DNS แต่พื้นฐานแล้ว การไม่พบแคชอาจหลีกเลี่ยงได้ยากด้วยเหตุผลดังต่อไปนี้
- ขนาดและการเติบโตของอินเทอร์เน็ต
หรือพูดง่ายๆ ก็คือ เมื่ออินเทอร์เน็ตเติบโตขึ้น ทั้งการเพิ่มผู้ใช้ใหม่และเว็บไซต์ใหม่ เนื้อหาส่วนใหญ่จะเป็นความสนใจของคนกลุ่มเล็ก
แม้ว่าจะมีเว็บไซต์ไม่กี่แห่ง (ซึ่งนำไปสู่ชื่อ DNS) ที่ได้รับความนิยมสูง แต่ส่วนใหญ่เป็นที่สนใจของผู้ใช้เพียงไม่กี่รายและไม่สามารถเข้าถึงได้น้อย ดังนั้นคำขอส่วนใหญ่จึงทำให้ไม่พบแคช
- ค่า Time to Live (TTL) ต่ำ
แนวโน้มที่ค่า DNS TTL ต่ำลงหมายความว่าการแปลงจำเป็นต้องมีการค้นหาบ่อยขึ้น
- การแยกแคช
โดยทั่วไปแล้ว เซิร์ฟเวอร์ DNS จะใช้งานหลังตัวจัดสรรภาระงาน ซึ่งกำหนดการค้นหาให้กับเครื่องหลายเครื่องแบบสุ่ม
ซึ่งจะส่งผลให้เซิร์ฟเวอร์แต่ละเครื่องเก็บแคชแยกต่างหากไว้แทนที่จะสามารถนำความละเอียดที่แคชไว้มาใช้ซ้ำจากพูลที่ใช้ร่วมกันได้
การบรรเทาปัญหา
ใน Google Public DNS เราได้ใช้หลายวิธีในการเพิ่มความเร็วในการค้นหา DNS
โดยบางวิธีเป็นวิธีการมาตรฐานที่ค่อนข้างมาตรฐาน ขณะที่วิธีการอื่นๆ ยังอยู่ในขั้นทดลอง
- จัดสรรเซิร์ฟเวอร์อย่างเพียงพอเพื่อจัดการกับภาระงานจากการรับส่งข้อมูลของไคลเอ็นต์ ซึ่งรวมถึงการรับส่งข้อมูลที่เป็นอันตราย
- การป้องกันการโจมตี DoS และการขยายความครอบคลุม
แม้ว่าปัญหานี้ส่วนใหญ่แล้วจะเป็นปัญหาด้านความปลอดภัยและส่งผลต่อรีโซลเวอร์แบบปิดน้อยกว่าการเปิด แต่การป้องกันการโจมตี DoS ก็ช่วยเพิ่มประสิทธิภาพได้เช่นกัน โดยการลดภาระในการรับส่งข้อมูลที่เพิ่มขึ้นในเซิร์ฟเวอร์ DNS
สำหรับข้อมูลเกี่ยวกับวิธีการที่เราใช้ในการลดโอกาสภัยคุกคาม โปรดดูหน้าเกี่ยวกับประโยชน์ด้านความปลอดภัย
- การจัดสรรภาระงานสำหรับการแคชที่แชร์เพื่อปรับปรุงอัตรา Hit ของแคชแบบรวมในคลัสเตอร์การแสดงผล
- มอบบริการที่ครอบคลุมทั่วโลกเพื่ออำนวยความสะดวกให้แก่ผู้ใช้ทั้งหมด
การจัดสรรคลัสเตอร์ที่ให้บริการอย่างเพียงพอ
รีโซลเวอร์ DNS ที่แคชต้องใช้การดำเนินการที่มีราคาแพงกว่าเนมเซิร์ฟเวอร์ที่เชื่อถือได้ เนื่องจากการตอบสนองหลายรายการไม่สามารถให้บริการจากหน่วยความจำได้ แต่จำเป็นต้องสื่อสารกับเนมเซิร์ฟเวอร์อื่นๆ แทน จึงต้องการอินพุต/เอาต์พุตของเครือข่ายจำนวนมาก
นอกจากนี้ รีโซลเวอร์แบบเปิดยังมีความเสี่ยงสูงต่อการโจมตีจากแคช ซึ่งจะเพิ่มอัตราการพลาดของแคช (การโจมตีดังกล่าวเป็นการส่งคำขอชื่อปลอมที่แก้ไขไม่ได้จากแคชโดยเฉพาะ) และการโจมตีแบบ DoS ซึ่งจะเพิ่มปริมาณการรับส่งข้อมูล
หากรีโซลเวอร์ไม่ได้รับการจัดสรรอย่างเพียงพอและตามโหลดให้ทันไม่ได้ ปัญหานี้อาจส่งผลเสียต่อประสิทธิภาพได้อย่างมาก
แพ็กเกตอาจถูกลบและต้องส่งใหม่ คำขอเนมเซิร์ฟเวอร์ต้องอยู่ในคิว และอื่นๆ
ปัจจัยทั้งหมดนี้ล้วนทำให้เกิดความล่าช้า
ด้วยเหตุนี้ รีโซลเวอร์ DNS จึงจำเป็นต้องมีการจัดสรรอินพุต/เอาต์พุตปริมาณมาก
ซึ่งรวมถึงการจัดการกับการโจมตีแบบ DDoS ที่อาจเกิดขึ้นได้ ซึ่งวิธีแก้ปัญหาเดียวที่ได้ผลคือการจัดเตรียมอุปกรณ์หลายเครื่องมากเกินไป
อย่างไรก็ตาม ในขณะเดียวกัน สิ่งสำคัญคือไม่ควรลดอัตราการพบแคชเมื่อเพิ่มเครื่อง เนื่องจากต้องใช้นโยบายการจัดสรรภาระงานที่มีประสิทธิภาพ ซึ่งเราจะอธิบายไว้ด้านล่าง
การจัดสรรภาระงานสำหรับการแคชที่แชร์
การปรับขนาดโครงสร้างพื้นฐานของรีโซลเวอร์โดยการเพิ่มเครื่องคอมพิวเตอร์สามารถเริ่มทำงานจริงได้ และลดอัตราการพบแคชหากการจัดสรรภาระงานไม่ถูกต้อง
ในการทำให้ใช้งานได้โดยทั่วไป เครื่องหลายเครื่องจะอยู่หลังตัวจัดสรรภาระงานที่กระจายการรับส่งข้อมูลไปยังแต่ละเครื่องอย่างเท่าเทียม โดยใช้อัลกอริทึมง่ายๆ เช่น การสลับกันทำงาน
ผลที่ได้ก็คือแต่ละเครื่องจะมีแคชอิสระของตัวเอง
เพื่อให้มีการแยกเนื้อหาที่แคชไว้ในเครื่องแต่ละเครื่อง
หากการค้นหาขาเข้าแต่ละรายการกระจายไปยังเครื่องแบบสุ่ม ทั้งนี้ขึ้นอยู่กับลักษณะของการรับส่งข้อมูล อัตราการพลาดแคชที่มีประสิทธิภาพอาจเพิ่มขึ้นในสัดส่วนที่เหมาะสม
เช่น สำหรับชื่อที่มี TTL แบบยาวซึ่งมีการค้นหาซ้ำๆ อัตราการไม่พบแคชอาจเพิ่มขึ้นตามจำนวนเครื่องในคลัสเตอร์
(สำหรับชื่อที่มี TTL สั้นมากซึ่งมีการค้นหาไม่บ่อยนัก หรือส่งผลให้มีการตอบกลับที่แคชไม่ได้ (TTL 0 รายการและข้อผิดพลาด) อัตราการไม่พบแคชของแคชจะไม่ได้รับผลกระทบใดๆ เมื่อเพิ่มเครื่อง)
หากต้องการเพิ่มอัตรา Hit สำหรับชื่อที่แคชได้ สิ่งสำคัญคือเซิร์ฟเวอร์ที่มีการจัดสรรภาระงานเพื่อให้แคชไม่แยกส่วน
ใน Google Public DNS เรามีการแคชสองระดับ
ในกลุ่มเครื่อง 1 เครื่องที่ใกล้กับผู้ใช้มาก แคชต่อเครื่องขนาดเล็กจะมีชื่อที่ได้รับความนิยมมากที่สุด
หากไม่พบคำค้นหาจากแคชนี้ ระบบจะส่งรายการดังกล่าวไปยังกลุ่มเครื่องอื่นที่แบ่งพาร์ติชันแคชตามชื่อ
สำหรับแคชระดับที่ 2 นี้ ระบบจะส่งคำค้นหาทั้งหมดที่มีชื่อเดียวกันไปยังเครื่องเดียวกัน โดยที่ชื่อนั้นจะมีการแคชไว้หรือไม่ก็ได้
การกระจายคลัสเตอร์ที่แสดงผลสำหรับการครอบคลุมทางภูมิศาสตร์ในวงกว้าง
ปัญหานี้ไม่ใช่ปัญหาสำหรับตัวแก้ไขแบบปิด
สำหรับรีโซลเวอร์แบบเปิด ยิ่งเซิร์ฟเวอร์ของคุณอยู่ใกล้กับผู้ใช้มากเท่าใด ผู้ใช้จะเห็นเวลาในการตอบสนองน้อยลงที่ฝั่งของไคลเอ็นต์มากเท่านั้น
นอกจากนี้ การมีความครอบคลุมทางภูมิศาสตร์เพียงพออาจช่วยปรับปรุงเวลาในการตอบสนองจากต้นทางถึงปลายทางได้ทางอ้อม เนื่องจากเนมเซิร์ฟเวอร์มักจะแสดงผลลัพธ์ที่เพิ่มประสิทธิภาพสำหรับตำแหน่งของรีโซลเวอร์ DNS
กล่าวคือ หากผู้ให้บริการเนื้อหาโฮสต์เว็บไซต์ที่จำลองข้อมูลไว้ทั่วโลก เนมเซิร์ฟเวอร์ของผู้ให้บริการนั้นจะส่งกลับที่อยู่ IP ที่ใกล้กับรีโซลเวอร์ DNS มากที่สุด
DNS สาธารณะของ Google โฮสต์อยู่ในศูนย์ข้อมูลทั่วโลก และใช้การกำหนดเส้นทาง Anycast เพื่อส่งผู้ใช้ไปยังศูนย์ข้อมูลที่อยู่ใกล้ที่สุด
นอกจากนี้ Google Public DNS ยังรองรับซับเน็ตไคลเอ็นต์ EDNS (ECS) ซึ่งเป็นส่วนขยายโปรโตคอล DNS สำหรับรีโซลเวอร์เพื่อส่งต่อตำแหน่งไคลเอ็นต์ไปยังเนมเซิร์ฟเวอร์ ซึ่งจะแสดงการตอบกลับที่อิงตามตำแหน่งซึ่งเพิ่มประสิทธิภาพสำหรับที่อยู่ IP ของไคลเอ็นต์จริง แทนที่จะเป็นที่อยู่ IP ของรีโซลเวอร์
โปรดอ่านรายละเอียดในคำถามที่พบบ่อยนี้
DNS สาธารณะของ Google ตรวจหาเนมเซิร์ฟเวอร์โดยอัตโนมัติ
ที่รองรับซับเน็ตไคลเอ็นต์ EDNS
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eDNS lookups significantly impact website loading speed, especially with resource-heavy pages referencing multiple domains.\u003c/p\u003e\n"],["\u003cp\u003eDNS latency stems from network factors between clients and resolvers and between resolvers and other name servers, with cache misses being a primary contributor.\u003c/p\u003e\n"],["\u003cp\u003eCache misses are difficult to avoid due to the Internet's vastness, short DNS record lifespans, and isolated caching systems across servers.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Public DNS employs strategies like global server distribution, load balancing, and security measures to mitigate DNS latency and enhance performance.\u003c/p\u003e\n"]]],["DNS latency, a significant factor in web browsing speed, is primarily caused by client-resolver latency and resolver-name server latency. Cache misses, due to internet growth, low TTL values, and cache isolation, are a dominant factor. Mitigations include adequately provisioning servers to handle traffic, preventing DoS attacks, load-balancing for shared caching, and ensuring global server coverage. Google Public DNS uses techniques such as two-level caching and EDNS client subnet support to minimize lookup times.\n"],null,["# Performance Benefits\n\nIntroduction: causes and mitigations of DNS latency\n---------------------------------------------------\n\nAs web pages become more complex, referencing resources from numerous domains,\nDNS lookups can become a significant bottleneck in the browsing experience.\nWhenever a client needs to query a DNS resolver over the network, the latency\nintroduced can be significant, depending on the proximity and number of\nname servers the resolver has to query (more than 2 is rare, but it can happen).\nAs an example, the following screen shot shows the timings reported by the\n[Page Speed](/speed/pagespeed) web performance measurement tool.\nEach bar represents a resource referenced from the page; the black segments\nindicate DNS lookups.\nIn this page, 13 lookups are made in the first 11 seconds in which the page is\nloaded.\nAlthough several of the lookups are done in parallel, the screen shot shows that\n5 serial lookup times are required, accounting for several seconds of the total\n11 seconds page load time.\n\nThere are two components to DNS latency:\n\n- Latency between the client (user) and DNS resolving server. In most cases this is largely due to the usual round-trip time (RTT) constraints in networked systems: geographical distance between client and server machines; network congestion; packet loss and long retransmit delays (one second on average); overloaded servers, denial-of-service attacks and so on.\n- Latency between resolving servers and other name servers. This source of latency is caused primarily by the following factors:\n - Cache misses. If a response cannot be served from a resolver's cache, but requires recursively querying other name servers, the added network latency is considerable, especially if the authoritative servers are geographically remote.\n - Underprovisioning. If DNS resolvers are overloaded, they must queue DNS resolution requests and responses, and may begin dropping and retransmitting packets.\n - Malicious traffic. Even if a DNS service is overprovisioned, DoS traffic can place undue load on the servers. Similarly, Kaminsky-style attacks can involve flooding resolvers with queries that are guaranteed to bypass the cache and require outgoing requests for resolution.\n\nWe believe that the cache miss factor is the most dominant cause of DNS latency,\nand discuss it further below.\n\n### Cache misses\n\nEven if a resolver has abundant local resources, the fundamental delays\nassociated with talking to remote name servers are hard to avoid.\nIn other words, assuming the resolver is provisioned well enough so that cache\nhits take zero time on the server-side, cache misses remain very expensive in\nterms of latency.\nTo handle a miss, a resolver has to talk to at least one, but often two or more\nexternal name servers.\nOperating the Googlebot web crawler, we have observed an average resolution time\nof 130 ms for name servers that respond.\nHowever, a full 4-6% of requests simply time out, due to UDP packet loss and\nservers being unreachable.\nIf we take into account failures such as packet loss, dead name servers, DNS\nconfiguration errors, etc., the **actual** average end-to-end resolution time is\n300-400 ms.\nHowever, there is high variance and a long tail.\n\nThough the cache miss rate may vary among DNS servers, cache misses are\nfundamentally difficult to avoid, for the following reasons:\n\n- Internet size and growth. Quite simply, as the Internet grows, both through the addition of new users and of new sites, most content is of marginal interest. While a few sites (and consequently DNS names) are very popular, most are of interest to only a few users and are accessed rarely; so the majority of requests result in cache misses.\n- Low time-to-live (TTL) values. The trend towards lower DNS TTL values means that resolutions need more frequent lookups.\n- Cache isolation. DNS servers are typically deployed behind load balancers which assign queries to different machines at random. This results in each individual server maintaining a separate cache rather than being able to reuse cached resolutions from a shared pool.\n\n### Mitigations\n\nIn Google Public DNS, we have implemented several approaches to speeding up DNS\nlookup times.\nSome of these approaches are fairly standard; others are experimental:\n\n- [Provisioning servers adequately](#provision) to handle the load from client traffic, including malicious traffic.\n- Preventing DoS and amplification attacks. Although this is mostly a security issue, and affects closed resolvers less than open ones, preventing DoS attacks also has a benefit for performance by eliminating the extra traffic burden placed on DNS servers. For information on the approaches we are using to minimize the chance of attacks, see the page on [security benefits](/speed/public-dns/docs/security).\n- [Load-balancing for shared caching](#loadbalance), to improve the aggregated cache hit rate across the serving cluster.\n- [Providing global coverage](#geography) for proximity to all users.\n\nProvisioning serving clusters adequately\n----------------------------------------\n\nCaching DNS resolvers have to perform more expensive operations than\nauthoritative name servers, since many responses cannot be served from memory;\ninstead, they require communication with other name servers and thus demand a\nlot of network input/output.\nFurthermore, open resolvers are highly vulnerable to cache poisoning attempts,\nwhich increase the cache miss rate (such attacks specifically send requests for\nbogus names that can't be resolved from cache), and to DoS attacks, which add to\nthe traffic load.\nIf resolvers are not provisioned adequately and cannot keep up with the load,\nthis can have a very negative impact on performance.\nPackets get dropped and need to be retransmitted, name server requests have to\nbe queued, and so on.\nAll of these factors add to delays.\n\nTherefore, it's important for DNS resolvers to be provisioned for high-volume\ninput/output.\nThis includes handling possible DDoS attacks, for which the only effective\nsolution is to over-provision with many machines.\nAt the same time, however, it's important not to reduce the cache hit rate when\nyou add machines; this requires implementing an effective load-balancing policy,\nwhich we discuss below.\n\nLoad-balancing for shared caching\n---------------------------------\n\nScaling resolver infrastructure by adding machines can actually backfire and\n**reduce** the cache hit rate if load balancing is not done properly.\nIn a typical deployment, multiple machines sit behind a load balancer that\nequally distributes traffic to each machine, using a simple algorithm such as\nround robin.\nThe result of this is that each machine maintains its own independent cache,\nso that the cached content is isolated across machines.\nIf each incoming query is distributed to a random machine, depending on the\nnature of the traffic, the effective cache miss rate can be increased\nproportionally.\nFor example, for names with long TTLs that are queried repeatedly, the cache\nmiss rate can be increased by the number of machines in the cluster.\n(For names with very short TTLs, that are queried very infrequently, or that\nresult in uncacheable responses (0 TTL and errors), the cache miss rate is not\nreally affected by adding machines.)\n\nTo boost the hit rate for cacheable names, it's important to load-balance\nservers so that the cache is not fragmented.\nIn Google Public DNS, we have two levels of caching.\nIn one pool of machines, very close to the user, a small per-machine cache\ncontains the most popular names.\nIf a query cannot be satisfied from this cache, it is sent to another pool of\nmachines that partition the cache by names.\nFor this second level cache, all queries for the same name are sent to the same\nmachine, where the name is either cached or it isn't.\n\nDistributing serving clusters for wide geographical coverage\n------------------------------------------------------------\n\nFor closed resolvers, this is not really an issue.\nFor open resolvers, the closer your servers are located to your users,\nthe less latency they will see at the client end.\nIn addition, having sufficient geographical coverage can indirectly improve\nend-to-end latency, as name servers typically return results optimized for the\nDNS resolver's location.\nThat is, if a content provider hosts mirrored sites around the world, that\nprovider's name servers will return the IP address in closest proximity to the\nDNS resolver.\n\nGoogle Public DNS is hosted in data centers worldwide, and uses anycast routing\nto send users to the geographically closest data center.\n\nIn addition, Google Public DNS supports [EDNS client subnet (ECS)](https://tools.ietf.org/html/rfc7871), a DNS\nprotocol extension for resolvers to forward client location to name servers,\nwhich can return location-sensitive responses optimized for the actual client\nIP address, rather than the resolver's IP address.\nPlease read [this FAQ](/speed/public-dns/faq#cdn) for details.\nGoogle Public DNS [automatically detects name servers](//groups.google.com/forum/#!topic/public-dns-announce/67oxFjSLeUM)\nthat support EDNS Client Subnet."]]