Sharding & CDNs. CS 475, Spring 2018 Concurrent & Distributed Systems

Similar documents
Overview Computer Networking Lecture 16: Delivering Content: Peer to Peer and CDNs Peter Steenkiste

416 Distributed Systems. March 23, 2018 CDNs

Today s class. CSE 123b Communications Software. Telnet. Network File System (NFS) Quick descriptions of some other sample applications

CSE 123b Communications Software

Distributed Architectures & Microservices. CS 475, Spring 2018 Concurrent & Distributed Systems

Web, HTTP, Caching, CDNs

Horizontal or vertical scalability? Horizontal scaling is challenging. Today. Scaling Out Key-Value Storage

Scaling Out Key-Value Storage

Remote Procedure Call. Tom Anderson

Distributed Systems. 17. Distributed Lookup. Paul Krzyzanowski. Rutgers University. Fall 2016

Large-Scale Web Applications

CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Scaling KVS. CS6450: Distributed Systems Lecture 14. Ryan Stutsman

15-440/15-640: Homework 3 Due: November 8, :59pm

CS 43: Computer Networks BitTorrent & Content Distribution. Kevin Webb Swarthmore College September 28, 2017

Send me up to 5 good questions in your opinion, I ll use top ones Via direct message at slack. Can be a group effort. Try to add some explanation.

CS5112: Algorithms and Data Structures for Applications

CS 43: Computer Networks. 14: DHTs and CDNs October 3, 2018

Outline Computer Networking. HTTP Basics (Review) How to Mark End of Message? (Review)

Mul$media Networking. #9 CDN Solu$ons Semester Ganjil 2012 PTIIK Universitas Brawijaya

Last Time. CSE 486/586 Distributed Systems Distributed Hash Tables. What We Want. Today s Question. What We Want. What We Don t Want C 1

Distributed Systems. 21. Content Delivery Networks (CDN) Paul Krzyzanowski. Rutgers University. Fall 2018

Scalability of web applications

CSE 124: CONTENT-DISTRIBUTION NETWORKS. George Porter December 4, 2017

Map-Reduce. Marco Mura 2010 March, 31th

CS 347 Parallel and Distributed Data Processing

Computer Security. 14. Blockchain & Bitcoin. Paul Krzyzanowski. Rutgers University. Spring 2019

CS 347 Parallel and Distributed Data Processing

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems

Memory hierarchy review. ECE 154B Dmitri Strukov

Distributed Systems. 16. Distributed Lookup. Paul Krzyzanowski. Rutgers University. Fall 2017

Introduction to Distributed Data Systems

CS 61C: Great Ideas in Computer Architecture. MapReduce

Content Distribution Networks

C 1. Last Time. CSE 486/586 Distributed Systems Distributed Hash Tables. Today s Question. What We Want. What We Want. What We Don t Want

Finding a needle in Haystack: Facebook's photo storage

IMPORTANT: Circle the last two letters of your class account:

CS5112: Algorithms and Data Structures for Applications

RAID in Practice, Overview of Indexing

HDFS Architecture. Gregory Kesden, CSE-291 (Storage Systems) Fall 2017

CS November 2018

Architekturen für die Cloud

15-440/15-640: Homework 3 Due: November 8, :59pm

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective

Data Centers. Tom Anderson

FLAT DATACENTER STORAGE. Paper-3 Presenter-Pratik Bhatt fx6568

Cloud Computing CS

CS /29/17. Paul Krzyzanowski 1. Fall 2016: Question 2. Distributed Systems. Fall 2016: Question 2 (cont.) Fall 2016: Question 3

What is a file system

Document Sub Title. Yotpo. Technical Overview 07/18/ Yotpo

DEMYSTIFYING BIG DATA WITH RIAK USE CASES. Martin Schneider Basho Technologies!

PRESENTATION TITLE GOES HERE. Understanding Architectural Trade-offs in Object Storage Technologies

Engineering Goals. Scalability Availability. Transactional behavior Security EAI... CS530 S05

EECS 498 Introduction to Distributed Systems

CONTENT-DISTRIBUTION NETWORKS

Advanced Computer Networks Exercise Session 7. Qin Yin Spring Semester 2013

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

CS 470 Spring Distributed Web and File Systems. Mike Lam, Professor. Content taken from the following:

CS5112: Algorithms and Data Structures for Applications

Hashing for searching

CS307 Operating Systems Main Memory

416 Distributed Systems. Distributed File Systems 2 Jan 20, 2016

CIT 668: System Architecture. Amazon Web Services

Caches II CSE 351 Spring #include <yoda.h> int is_try(int do_flag) { return!(do_flag!do_flag); }

Distributed File Systems. CS 537 Lecture 15. Distributed File Systems. Transfer Model. Naming transparency 3/27/09

CS 138: Google. CS 138 XVII 1 Copyright 2016 Thomas W. Doeppner. All rights reserved.

CS 470 Spring Distributed Web and File Systems. Mike Lam, Professor. Content taken from the following:

Lecture 8: Internet and Online Services. CS 598: Advanced Internetworking Matthew Caesar March 3, 2011

Distributed Data Infrastructures, Fall 2017, Chapter 2. Jussi Kangasharju

File Systems. What do we need to know?

Handling Big Data an overview of mass storage technologies

Scaling Internet TV Content Delivery ALEX GUTARIN DIRECTOR OF ENGINEERING, NETFLIX

CSE380 - Operating Systems

Chapter 6 Objectives

CS603: Distributed Systems

Distributed Systems. Fall 2017 Exam 3 Review. Paul Krzyzanowski. Rutgers University. Fall 2017

Goals. Facebook s Scaling Problem. Scaling Strategy. Facebook Three Layer Architecture. Workload. Memcache as a Service.

Cloudflare CDN. A global content delivery network with unique performance optimization capabilities

File Structures and Indexing

CS 138: Google. CS 138 XVI 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

The Google File System (GFS)

Workshop Report: ElaStraS - An Elastic Transactional Datastore in the Cloud

Application-Layer Protocols Peer-to-Peer Systems, Media Streaming & Content Delivery Networks

File System Internals. Jo, Heeseung

Bigtable. A Distributed Storage System for Structured Data. Presenter: Yunming Zhang Conglong Li. Saturday, September 21, 13

Peer-to-Peer Systems and Distributed Hash Tables

High Performance Computing Lecture 26. Matthew Jacob Indian Institute of Science

Dynamo: Key-Value Cloud Storage

Scaling with mongodb

Mo Money, No Problems: Caches #2...

CSC 401 Data and Computer Communications Networks

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Scaling Data Center Application Infrastructure. Gary Orenstein, Gear6

Caches II. CSE 351 Autumn Instructor: Justin Hsia

Dept. Of Computer Science, Colorado State University

Distributed Systems. 05r. Case study: Google Cluster Architecture. Paul Krzyzanowski. Rutgers University. Fall 2016

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2008 Quiz II

Today: World Wide Web! Traditional Web-Based Systems!

big picture parallel db (one data center) mix of OLTP and batch analysis lots of data, high r/w rates, 1000s of cheap boxes thus many failures

Transcription:

Sharding & CDNs CS 475, Spring 2018 Concurrent & Distributed Systems

Review: Distributed File Systems Challenges: Heterogeneity (different kinds of computers with different kinds of network links) Scale (maybe lots of users) Security (access control) Failures Concurrency 2

Review: NFS Cache file blocks, file headers, etc., at both clients and servers. Advantage: No network traffic if open/read/write/ close can be done locally. But: failures and cache consistency. NFS trades some consistency for increased performance... let s look at the protocol. 3

Review: NFS + Server crash? Data in memory but not disk lost So... what if client does seek() ; /* SERVER CRASH */; read() If server maintains file position, this will fail. Ditto for open(), read() Stateless protocol: requests specify exact state. read() -> read( [position]). no seek on server. 4

Review: NFS Caching - Close-to-open Implemented by most NFS clients Contract: if client A write()s a file, then close()s it, then client B open()s the file, and read()s it, client B s reads will reflect client A s writes Benefit: clients need only contact server during open() and close() not on every read() and write() 5

Announcements HW3 is out! http://www.jonbell.net/gmu-cs-475-spring-2018/ homework-3/ Midterm: Wednesday Today: Sharding and CDNs How do we find out where to find data? Additional reading: OS TEP Ch 49 6

Partitioning (Sharding) + Replication Students [A N] Students [A N] Students [A N] Students [O Z] Students [O Z] Students [O Z] 7

Partitioning (Sharding) + Replication We can solve our discovery problem if we can define a consistent way to store our data and share those rules Create "buckets," and use a "hash function" to map from a key to a bucket Example: All files starting with the letter "A" are stored on servers 1,2,3; all files starting with the letter "B" are stored on severs 4,5,6, etc. 8

Strawman Sharding Scheme In this class: 40 students Students [A N] Students [A N] Students [A N] 16 students Students [O Z] Students [O Z] Students [O Z] 9

Partitioning + Replication If input is structured, can possibly leverage that structure to build these buckets (name spaces) Example: File system Map from: /home/bellj/teaching/cs475 to file contents Could have different machines responsible for each tier? Example: DNS system Maps from: www.jonbell.net TO: 104.24.122.171 Different machines for each tier? 10

DNS: Example home.cs.gmu.edu 129.174.126.40 Local DNS Server home.cs.gmu.edu ns.edu home.cs.gmu.edu ns1.gmu.edu Root.edu 129.174.126.40 home.cs.gmu.edu ns1.cs.gmu.edu home.cs.gmu.edu 129.174.126.40 gmu.edu cs.gmu.edu 11

DNS 12

Hashing The hierarchical structure can solve some problems, but not all What if we want to make a mechanism to track pages, not domain names Map from a single URL to a set of servers that have that document This is the problem attacked by content distribution networks, or CDNs (Akamai, Cloudflare, etc) 13

Hashing 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 largescale key-value storage systems (databases--) using consistent hashing 14

Hashing Idea: create a function hash(key), that for any key returns the server that stores key This is called a hash function Problems? No notion of duplication (what if a server goes down?) What if nodes go down/come up? 15

Hashing Input: Some arbitrarily large data (bytes, ints, letters, whatever) Output: A fixed size value Rule: Same input gives same output, always; "unlikely" to have multiple inputs map to the same output 16

Hashing Compresses data: maps a variable-length input to a fixed-length output Relatively easy to compute Example: Inputs Leo McGarry Josh Lyman Sam Seaborn Toby Ziegler Hash Function Hash 0 1 2 3 4 5 6 7 17

Hashing The last one mapped every input to a different hash Doesn't have to, could be collisions Inputs Leo McGarry Josh Lyman Sam Seaborn Toby Ziegler Hash Function Hash 0 1 2 3 4 5 6 7 18

Hashing Hashes have tons of other uses too: Verifying integrity of data Hash table Cryptography Merkle trees (git, blockchain) 19

Hashing for Partitioning Input Hash Result Server ID Some big long piece of text or database key hash()= 900405 % 20 = 5 20

Conventional Hashing + Sharding In practice, might use an off-the-shelf hash function, like sha1 sha1(url) -> 160 bit hash result % 20 -> server ID (assuming 20 servers) But what happens when we add or remove a server? Data is stored on what was the right server, but now that the number of servers changed, the right server changed too! 21

Conventional Hashing Assume we have 10 keys, all integers server 0 server 1 server 2 server 3 0, 3, 6, 9 1, 4, 7 2, 5, 8 Adding a new server 22

Conventional Hashing Assume we have 10 keys, all integers server 0 server 1 server 2 server 3 0, 4, 8 1, 5, 9 2, 6 3, 7 Adding a new server 8/10 keys had to be reshuffled! Expensive! 23

Consistent Hashing Problem with regular hashing: very sensitive to changes in the number of servers holding the data! Consistent hashing will require on average that only K/n keys need to be remapped for K keys with n different slots (in our case, that would have been 10/4 = 2.5 [compare to 8]) 24

Consistent Hashing Construction: Assign each of C hash buckets to random points on mod 2 n circle, where hash key size = n Map object to pseudo-random position on circle Hash of object is the closest clockwise bucket Example: hash key size is 16 0 Each is a value of hash % 16 Each is a bucket 12 9 4 Example: bucket with key 9? 8 25

Consistent Hashing It is relatively smooth: adding a new bucket doesn't change that much 0 Delete bucket: only changes location of keys 1,2,3 12 4 Add new bucket: only changes location of keys 7,8,9,10 8 26

Consistent Hashing in Practice (CDN) Goal: replicate content to many servers Reduces server load Reduces latency CDN server (Europe) Origin server CDN Gateway CDN server (Asia) CDN server (N America) 27

CDN Challenges How do we replicate the content? Assume: only static content Where do we replicate the content? Assume: infinite money How to choose amongst known replicas? Lowest load? Best performance? How to find the replicated content? Tricky 28

CDN Challenges Finding Content Desire super, super low latency Serving a single request is probably very very cheap (e.g. read a 1KB file from memory/ssd and return it) But we want to serve billions of these requests at once VERY important that we can route requests fast 29

CDN: How to find content? Problem: how the heck do we figure out what data should go where? 30

CDN: How to find content? apple.com jonbell.net Problem: How do we organize the tiers/shortcut from URLs to servers? 1 server per domain doesn t help balance load 31

CDN: How to find content? Master server directs all requests to appropriate cache server Big cluster of cache servers Problem: Master becomes a huge bottleneck Millions of requests, each request needs to be processed incredibly fast 32

Finding the replicas Maintain 1000 s of data centers across the internet, each with many servers Hash(URL s domain) maps to a server Akamai maintains their own DNS infrastructure, with two tiers (global and regional) Lookup apple.com -> akamai.net -> g.akamaitech.net -> actual cache server 33

Finding the replicas Lookup apple.com -> akamai.net -> g.akamaitech.net -> actual cache server The address returned for g.akamaitech.net is one that is near the client (geographically) The address returned by that regional server is determined by which local server has the content As determined by consistent hashing 34

CDN: Finding Content 1 2 3 4 5 6 7 8 9 10 11 12 Consistent hash( http://www.jonbell.net/gmu-cs-475-spring-2018/homework-3/ )=8 35