Download presentation
Presentation is loading. Please wait.
1
Distributed Systems Naming and Hashing
2
Overview Spanner DNS DNS today Naming with hashes
3
Multiple Datacenters User posts Friend lists Friend1 post x1000 US
Spain … Generate my page User posts Friend lists x1000 Friend999 post Brazil User posts Friend lists x1000 Friend1000 post Russia OSDI 2012
4
Spanner Concurrency Control
Key aspect of differentiating Spanner – using globally meaningful timestamps for distributed transactions in achieving external consistency start commit The timestamp can let us know whether transaction T1 happened before transaction T2. Essentially we can be external observers and just by looking at the timestamp speculate an ordering that happens to be consistent with Spanner's ordering t T1: s1 s1: Timestamp
5
Version Management Transactions that write use strict 2PL
Each transaction T is assigned a timestamp s Data written by T is timestamped with s Time <8 8 15 My friends [X] [] My posts [P] X’s friends [me] [] OSDI 2012
6
Synchronizing Snapshots
Global wall-clock time == External Consistency: Commit order respects global wall-time order == Timestamp order respects global wall-time order given timestamp order == commit order OSDI 2012
7
Timestamps, Global Clock
Strict two-phase locking for write transactions Assign timestamp while locks are held Single machine view Acquired locks Release locks T Pick s = now() OSDI 2012
8
Spanner TrueTime API TT.now() – TTInterval: [earliest, latest]
(Why is time an interval and not a specific instant?) TT.after(t) – true if t has definitely passed TT.before(t) – true if t has definitely not arrived TT.after(t) = true TT.now() TT.before(t) = true Answer: local clock drift, communication delay ~ typically 10 ms after and before are convenience wrappers over TT.now() after is true because any t before earliest has already passed as viewed by the system as a whole before is true because any t after latest is yet to come as viewed by the system as a whole time earliest latest 2*ε “Global wall-clock time” with bounded uncertainty
9
Spanner Commit Wait Acquired locks Release locks T time s Pick s =
TT.now().latest Wait until TT.now().earliest > s Epsilon is about 5ms in 2012 Commit Wait average ε average ε Why do you need to wait for TT.now().earliest > s before releasing locks?
10
Spanner External Consistency
If a transaction T1 commits before another transaction T2 starts, then T1's commit timestamp is smaller than T2 Similar to how we reason with wall-clock time start commit start commit t t T1: s1 T1: s1 T2: s2 T2: s2 s1 < s2 s1 < s2
11
Summary GFS / HDFS Spanner Data-center customized API, optimizations
Append focused DFS Separate control (filesystem) and data (chunks) Replication and locality Rough consistency apps handle rest Spanner Globally consistent replicated database system Implements distributed transactions Lock-free reads and Paxos based writes Implements external consistency using TrueTime API Able to survive data center wipeouts
12
Overview Spanner DNS DNS today Naming with hashes
13
Names Names are associated with objects Examples
Enables passing of references to objects Indirection Deferring decision on meaning/binding Examples Registers R5 Memory 0xdeadbeef Host names srini.com User names sseshan File name /usr/srini/foo.txt URLs Ethernet f8:e4:fb:bf:3d:a6
14
Name Discovery Well-known name Broadcast Query Broadcast query
port 80… Broadcast Advertise name e.g Beacons Query Use google Broadcast query Ethernet ARP Use another naming system DNS returns IP addresses Introductions Web page hyperlinks Physical rendezvous Exchange info in the real world OTHER KEY DIFFERENCES AS WELL….
15
Overview Spanner DNS DNS today Naming with hashes
16
RR format: (class, name, value, type, ttl)
DNS Records RR format: (class, name, value, type, ttl) DB contains tuples called resource records (RRs) Classes = Internet (IN), Chaosnet (CH), etc. Each class defines value associated with type FOR IN class: Type=A name is hostname value is IP address Type=NS name is domain (e.g. foo.com) value is name of authoritative name server for this domain Type=CNAME name is an alias name for some “canonical” (the real) name value is canonical name Type=MX value is hostname of mailserver associated with name
17
DNS Design: Zone Definitions
Zone = contiguous section of name space E.g., Complete tree, single node or subtree A zone has an associated set of name servers Must store list of names and tree links root org ca net edu com uk gwu ucb cmu bu mit cs ece Subtree cmcl Single node Complete Tree
18
Typical Resolution root & edu DNS server ns1.cmu.edu DNS server Local
NS ns1.cmu.edu ns1.cmu.edu DNS server NS ns1.cs.cmu.edu A www=IPaddr Local DNS server Client ns1.cs.cmu.edu DNS server
19
Typical Resolution Steps for resolving www.cmu.edu
Application calls gethostbyname() (RESOLVER) Resolver contacts local name server (S1) S1 queries root server (S2) for ( S2 returns NS record for cmu.edu (S3) What about A record for S3? This is what the additional information section is for (PREFETCHING) S1 queries S3 for S3 returns A record for
20
Lookup Methods Recursive query: Iterative query:
Server goes out and searches for more info (recursive) Only returns final answer or “not found” Iterative query: Server responds with as much as it knows (iterative) “I don’t know this name, but ask this server” Workload impact on choice? Local server typically does recursive Root/distant server does iterative root name server 2 iterated query 3 4 7 local name server dns.eurecom.fr intermediate name server dns.umass.edu 5 6 1 authoritative name server dns.cs.umass.edu 8 requesting host surf.eurecom.fr gaia.cs.umass.edu
21
Workload and Caching Are all servers/names likely to be equally popular? Why might this be a problem? How can we solve this problem? DNS responses are cached Quick response for repeated translations Other queries may reuse some parts of lookup NS records for domains DNS negative queries are cached Don’t have to repeat past mistakes E.g. misspellings, search strings in resolv.conf Cached data periodically times out Lifetime (TTL) of data controlled by owner of data TTL passed with every record
22
Typical Resolution root & edu DNS server ns1.cmu.edu DNS server Local
NS ns1.cmu.edu ns1.cmu.edu DNS server NS ns1.cs.cmu.edu A www=IPaddr Local DNS server Client ns1.cs.cmu.edu DNS server
23
Subsequent Lookup Example
root & edu DNS server ftp.cs.cmu.edu cmu.edu DNS server Local DNS server Client ftp.cs.cmu.edu cs.cmu.edu DNS server ftp=IPaddr
24
Tracing Hierarchy (1) Dig Program Use flags to find name server (NS)
Disable recursion so that operates one step at a time All .edu names handled by set of servers unix> dig NS four.cmcl.cs.cmu.edu ;; ADDITIONAL SECTION: a.edu-servers.net IN A c.edu-servers.net IN A d.edu-servers.net IN A f.edu-servers.net IN A g.edu-servers.net IN A g.edu-servers.net IN AAAA :503:cc2c::2:36 l.edu-servers.net IN A IP v6 address
25
Prefetching Name servers can add additional data to response
Typically used for prefetching CNAME/MX/NS typically point to another host name Responses include address of host referred to in “additional section”
26
Tracing Hierarchy (2) 3 servers handle CMU names
unix> dig NS four.cmcl.cs.cmu.edu ;; AUTHORITY SECTION: cmu.edu IN NS ny-server-03.net.cmu.edu. cmu.edu IN NS nsauth1.net.cmu.edu. cmu.edu IN NS nsauth2.net.cmu.edu.
27
Tracing Hierarchy (3 & 4) 3 servers handle CMU CS names
Server within CS is “start of authority” (SOA) for this name unix> dig NS four.cmcl.cs.cmu.edu ;; AUTHORITY SECTION: cs.cmu.edu IN NS AC-DDNS-2.NET.cs.cmu.edu. cs.cmu.edu IN NS AC-DDNS-1.NET.cs.cmu.edu. cs.cmu.edu IN NS AC-DDNS-3.NET.cs.cmu.edu. unix>dig NS four.cmcl.cs.cmu.edu ;; AUTHORITY SECTION: cs.cmu.edu IN SOA PLANISPHERE.FAC.cs.cmu.edu.
28
Tracing Hierarchy (3 & 4) Any will return the A record
unix> dig four.cmcl.cs.cmu.edu ;; ANSWER SECTION:FOUR.CMCL.CS.CMU.EDU IN A
29
DNS Hack #1 Can return multiple A records what does this mean?
Load Balance Server sends out multiple A records Order of these records changes per-client
30
Server Balancing Example
DNS Tricks Different responses to different servers, short TTL’s unix1> dig ;; ANSWER SECTION: IN CNAME atsv2-fp.wg1.b.yahoo.com. atsv2-fp.wg1.b.yahoo.com. 49 IN A atsv2-fp.wg1.b.yahoo.com. 49 IN A atsv2-fp.wg1.b.yahoo.com. 49 IN A atsv2-fp.wg1.b.yahoo.com. 49 IN A unix2> dig ;; ANSWER SECTION: IN CNAME atsv2-fp.wg1.b.yahoo.com. atsv2-fp.wg1.b.yahoo.com. 30 IN A atsv2-fp.wg1.b.yahoo.com. 30 IN A atsv2-fp.wg1.b.yahoo.com. 30 IN A atsv2-fp.wg1.b.yahoo.com. 30 IN A
31
Overview Spanner DNS DNS today Naming with hashes
32
Protecting the Root Nameservers
Sophisticated? Why did nobody notice? seshan.org NS October 21, 2002[edit] On October 21, 2002 an attack lasting for approximately one hour was targeted at all 13 DNS root name servers.[1] The attackers sent many ICMP ping packets using a botnet to each of the servers. However, because the servers were protected by packet filters which were configured to block all incoming ICMP ping packets, they did not sustain much damage and there was little to no impact on Internet users.[2] February 6, 2007[edit] On February 6, 2007 an attack began at 10:00 UTC and lasted twenty-four hours. At least two of the root servers (G-ROOT and L-ROOT) reportedly "suffered badly" while two others (F-ROOT and M-ROOT) "experienced heavy traffic". The latter two servers largely contained the damage by distributing requests to other root server instances with anycast addressing. ICANN published a formal analysis shortly after the event.[3] Due to a lack of detail, speculation about the incident proliferated in the press until details were released.[4] November 30, 2015[edit] During two intervals on November 30, 2015 and December 1, 2015, several of the root name servers received up to 5 million queries per second each, receiving valid queries for a single undisclosed domain name, and then a different domain the next day. Source addresses were spread throughout IPv4 space, however these may have been spoofed. Some root server networks became saturated, resulting in timeouts, however redundancy among the root servers prevented downstream issues from occurring during this incident.[5][6] Defense Mechanisms Redundancy: 13 root nameservers IP Anycast for root DNS servers {c,f,i,j,k}.root-servers.net RFC 3258 Most physical nameservers lie outside of the US
33
Defense: Replication and Caching
source: wikipedia
34
What Happened on Oct 21st 2016? DDoS attack on Dyn
Dyn provides core Internet services for Twitter, SoundCloud, Spotify, Reddit and a host of other sites Why didn’t DNS defense mechanisms work in this case? Let’s take a look at the DNS records…
35
What was the source of attack?
Mirai botnet Used in 620Gbps attack last month Source: bad IoT devices, e.g., White-labeled DVR and IP camera electronics username: root and password: xc3511 password is hardcoded into the device firmware
36
Attack Waves DNS lookups are routed to the nearest data center
First wave On three Dyn data centers – Chicago, Washington, D.C., and New York Second wave, Hit 20 Dyn data centers around the world. Required extensive planning. Since DNS request go to the closest DNS server, the attacker had to plan a successful attack for each of the 20 data centers with enough bots in each region to be able to take down the local Dyn services Drew says the attack consisted mainly of TCP SYN floods aimed directly at against port 53 of Dyn’s DNS servers, but also a prepend attack, which is also called a subdomain attack. That’s when attackers send DNS requests to a server for a domain for which they know the target is authoritative. But they tack onto the front of the domain name random prepends or subnet designations. The server won’t have these in its cache so will have to look them up, sapping computational resources and effectively preventing the server from handling legitimate traffic, he says.
37
Solutions? Dyn customers
Going to backup DNS providers Signing up with an alternative today after the attacks, as PayPal did Lowering their time-to-life settings on their DNS servers Redirect traffic faster to another DNS service that is still available
38
Root Zone Generic Top Level Domains (gTLD) = .com, .net, .org, etc…
Country Code Top Level Domain (ccTLD) = .us, .ca, .fi, .uk, etc… Root server ({a-m}.root-servers.net) also used to cover gTLD domains Load on root servers was growing quickly! Moving .com, .net, .org off root servers was clearly necessary to reduce load done Aug 2000
39
gTLDs Unsponsored Sponsored (controlled by a particular association)
.com, .edu, .gov, .mil, .net, .org .biz businesses .info general info .name individuals Sponsored (controlled by a particular association) .aero air-transport industry .cat catalan related .coop business cooperatives .jobs job announcements .museum museums .pro accountants, lawyers, and physicians .travel travel industry Starting up .mobi mobile phone targeted domains .post postal .tel telephone related Proposed .asia, .cym, .geo, .kid, .mail, .sco, .web, .xxx
40
New Registrars Network Solutions (NSI) used to handle all registrations, root servers, etc… Clearly not the democratic (Internet) way Large number of registrars that can create new domains However NSI still handles A root server
41
Do you trust the TLD operators?
Wildcard DNS record for all .com and .net domain names not yet registered by others September 15 – October 4, 2003 February 2004: Verisign sues ICANN Redirection for these domain names to Verisign web portal (SiteFinder) What services might this break?
42
DNS (Summary) Motivations large distributed database
Scalability Independent update Robustness Hierarchical database structure Zones How is a lookup done Caching/prefetching and TTLs Reverse name lookup What are the steps to creating your own domain?
43
DNS Dist Sys Lessons Availability and reliability
Caching and consistency Federated design Security Scalability Coordination/standardization
44
Overview Spanner DNS DNS today Naming with hashes
45
Hashing Two uses of hashing that are becoming wildly popular in distributed systems: Content-based naming Consistent Hashing of various forms
46
Example systems that use them
BitTorrent & many other modern p2p systems use content-based naming Content distribution networks such as Akamai use consistent hashing to place content on servers Amazon, Linkedin, etc., all have built very large-scale key-value storage systems (databases--) using consistent hashing
47
Problem: Dividing items onto storage servers
Option 1: Static partition (items a-c go there, d-f go there, ...) If you used the server name, what if “cowpatties.com” had pages, but “zebras.com” had only 10? Load imbalance Could fill up the bins as they arrive Requires tracking the location of every object at the front-end.
48
Hashing Let nodes be numbered 1..m
Client uses a good hash function to map a URL to 1..m Say hash (url) = x, so, client fetches content from node x No duplication – not being fault tolerant. Any other problems? What happens if a node goes down? What happens if a node comes back up? What if different nodes have different views?
49
Option 2: Conventional Hashing
bucket = hash(item) / num_buckets Sweet! Now the server we use is a deterministic function of the item, e.g., sha1(URL) 160 bit ID / 20 a server ID But what happens if we want to add or remove a server?
50
Option 2: Conventional Hashing
90 documents, node 1..9, node 10 which was dead is alive again Simple assignment: ID/9 (for 9 servers) vs. ID/10 (for 10 servers) % of documents in the wrong node? 10, 19-20, 28-30, 37-40, 46-50, 55-60, 64-70, 73-80, 82-90 Disruption coefficient = ½
51
Consistent Hash “view” = subset of all hash buckets that are visible
Desired features Balanced – in any one view, load is equal across buckets Smoothness – little impact on hash bucket contents when buckets are added/removed Spread – small set of hash buckets that may hold an object regardless of views Load – across all views # of objects assigned to hash bucket is small
52
Consistent Hash – Example
Construction Assign each of C hash buckets to random points on mod 2n circle, where, hash key size = n. Map object to random position on circle Hash of object = closest clockwise bucket 4 12 Bucket 14 8 Smoothness addition of bucket does not cause much movement between existing buckets Spread & Load small set of buckets that lie near object Balance no bucket is responsible for large number of objects
53
Hashing 2: For naming Many file systems split files into blocks and store each block on a disk. Several levels of naming: Pathname to list of blocks Block #s are addresses where you can find the data stored therein. (But in practice, they’re logical block #s – the disk can change the location at which it stores a particular block... so they’re actually more like names and need a lookup to location :)
54
Another problem to solve...
Imagine you’re creating a backup server It stores the full data for 1000 CMU users’ laptops Each user has a 100GB disk. That’s 100TB and lots of $$$ How can we reduce the storage requirements?
55
“Deduplication” A common goal in big archival storage systems. Those 1000 users probably have a lot of data in common -- the OS, copies of binaries, maybe even the same music or movies How can we detect those duplicates and coalesce them? One way: Content-based naming, also called content-addressable foo (storage, memory, networks, etc.) A fancy name for...
56
Name items by their hash
Imagine that your filesystem had a layer of indirection: pathname hash(data) hash(data) list of blocks For example: /src/foo.c -> 0xfff32f2fa11d00f0 0xfff32f2fa11d00f0 -> [5623, 5624, 5625, 8993] If there were two identical copies of foo.c on disk ... We’d only have to store it once! Name of second copy can be different
57
A second example Several p2p systems operate something like:
Search for “national anthem”, find a particular file name (starspangled.mp3). Identify the files by the hash of their content (0x2fab4f001...) Request to download a file whose hash matches the one you want Advantage? You can verify what you got, even if you got it from an untrusted source (like some dude on a p2p network)
58
P2P-enabled Applications: Self-Certifying Names
Name = Hash(pubkey, salt) Value = <pubkey, salt, data, signature> can verify name related to pubkey and pubkey signed data Can receive data from caches, peers or other 3rd parties without worry
59
Desirable Properties of Hashes
Compression: Maps a variable-length input to a fixed-length output Ease of computation: A relative metric... Pre-image resistance: For all outputs, computationally infeasible to find input that produces output. 2nd pre-image resistance: For all inputs, computationally infeasible to find second input that produces same output as a given input. collision resistance: For all outputs, computationally infeasible to find two inputs that produce the same output.
60
Hash functions Given a universe of possible objects U, map N objects from U to an M-bit hash. Typically, |U| >>> 2M. This means that there can be collisions: Multiple objects map to the same M-bit representation. Likelihood of collision depends on hash function, M, and N. Birthday paradox roughly 50% collision with 2M/2 objects for a well designed hash function
61
Longevity “Computationally infeasible” means different things in 1970 and 2012. Moore’s law Some day, maybe, perhaps, sorta, kinda: Quantum computing. Hash functions are not an exact science yet. They get broken by advances in crypto.
62
Real hash functions Name Introduced Weakened Broken Lifetime
Replacement MD4 1990 1991 1995 1-5y MD5 1992 1994 2004 8-10y SHA-1 MD2 abandoned 3y RIPEMD 1997 5-12y RIPEMD-160 HAVAL-128 - 12y SHA-0 1993 1998 5-11y not quite yet 9+ SHA-2 & 3 SHA-2 (256, 384, 512) 2001 still good SHA-3 2012 brand new
63
Using them How long does the hash need to have the desired properties (preimage resistance, etc)? rsync: For the duration of the sync; dedup: Until a (probably major) software update; store-by-hash: Until you replace the storage system What is the adversarial model? Protecting against bit flips vs. an adversary who can try 1B hashes/second?
64
Final pointer Hashing forms the basis for MACs - message authentication codes Basically, a hash function with a secret key. H(key, data) - can only create or verify the hash given the key. Very, very useful building block
65
Final pointer 2: Rabin Fingerprinting
Hash 1 Hash 2 Natural Boundary Natural Boundary File Data Rabin Fingerprints 4 7 8 2 8 Given Value - 8
66
Summary Hashes used for: Key applications Many types of naming
Splitting up work/storage in a distributed fashion Naming objects with self-certifying properties Key applications Key-value storage P2P content lookup Deduplication MAC Many types of naming DNS names, IP addresses, Ethernet addresses, content-based addresses Make sure you understand differences
67
Feedback Issues Due dates Slide details Writeup clarity Record lecture
More OH Readings Positives Go/proj Lectures TAs Piazza (more + than -) Midterm review
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.