Top Banner
Adaptively Parallelizing Distributed Range Queries Ymir Vigfusson Adam Silberstein Brian Cooper Rodrigo Fonseca
42

Adaptively Parallelizing Distributed Range Queries

Feb 24, 2016

Download

Documents

Selina

Adaptively Parallelizing Distributed Range Queries. Ymir Vigfusson Adam Silberstein Brian Cooper Rodrigo Fonseca. Introduction. Well understood database tasks are challenging again at web- scale Millions of users Terabytes of data Low latency essential - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Adaptively Parallelizing Distributed  Range  Queries

Adaptively Parallelizing Distributed Range Queries

Ymir Vigfusson

Adam Silberstein

Brian Cooper

Rodrigo Fonseca

Page 2: Adaptively Parallelizing Distributed  Range  Queries

• Well understood database tasks are challenging again at web-scale– Millions of users– Terabytes of data– Low latency essential

• Shared-nothing databases

– Scale by adding servers with local disks

Introduction

Page 3: Adaptively Parallelizing Distributed  Range  Queries

• PNUTS

• Workload:– Analogous to OLTP– Random reads and updates of

individual records– Online applications

Introduction

Page 4: Adaptively Parallelizing Distributed  Range  Queries

• Important for web workloads– Time ordered data

Range Queries

Listing date Item for sale07-24-2009 Used cowbell08-10-2009 2003 Toyota 08-15-2009 Red Snuggie08-18-2009 1930 Ford08-22-2009 Harpsicord

Listing date Item for sale07-24-2009 Used cowbell08-10-2009 2003 Toyota 08-15-2009 Red Snuggie08-18-2009 1930 Ford08-22-2009 Harpsicord

New items

Page 5: Adaptively Parallelizing Distributed  Range  Queries

• Important for web workloads– Time ordered data– Secondary indexes

Range Queries

Price Item ID$20 1727$100 971$1,500 251$5,000 5578$10,000 4921

Item ID Item1727 Used cowbell4921 2003 Toyota 971 Red Snuggie5578 Harpsicord251 1930 Ford

Item ID Item1727 Used cowbell4921 2003 Toyota 971 Red Snuggie5578 Harpsicord251 1930 Ford

Price Item ID$20 1727$100 971$1,500 251$5,000 5578$10,000 4921

Index Base Table

Page 6: Adaptively Parallelizing Distributed  Range  Queries

• Important for web workloads– Time ordered data– Secondary indexes– etc.

• Could scan large fraction of the table– Short time to first result is crucial– Possibly a large number of results– Predicate might be selective

Range Queries

FIND ITEMS UNDER $100 WHERE Category =‘Cars’ AND Quantity>0FIND ITEMS OVER $100

Page 7: Adaptively Parallelizing Distributed  Range  Queries

• Makes sense to parallelize queries– Tables are partitioned over many

servers

• How parallel should a query be?– Too sequential: Slow rate of results– Too parallel: Client overloaded, wasting

server resources

Executing Range Queries

Page 8: Adaptively Parallelizing Distributed  Range  Queries

• Makes sense to parallelize queries– Tables are partitioned over many

servers

• How parallel should a query be?– Too sequential: Slow rate of results– Too parallel: Client overloaded, wasting

server resources

Executing Range Queries

Page 9: Adaptively Parallelizing Distributed  Range  Queries

PNUTS 101

Routers

StorageUnits

Partition map

Load balancer

Server monitor

PartitionController

AB

T

LE

Clients

getset

delete

Page 10: Adaptively Parallelizing Distributed  Range  Queries

Routers

PNUTS + Range scans

Clients

StorageUnits

SCAN

q= query

= ideal parallelism levelsL

s

= ideal server concurrency

getset

deletegetrange

Page 11: Adaptively Parallelizing Distributed  Range  Queries

– Equals number of disks (experimentally)– In our testbed,

– When does parallelism help?• range size: longer = more benefit• query selectivity: fewer results = more benefit• client speed: faster = more benefit

– Diminishing returns

Range query parameters

= ideal parallelism levelsL = ideal server concurrency

1sL

Page 12: Adaptively Parallelizing Distributed  Range  Queries

Determining

• As shown, many influential factors• End-to-end insight: match rate of

new results to client’s uptake rate

% Client Capacity

4qK

Page 13: Adaptively Parallelizing Distributed  Range  Queries

Determining

% Client Capacity

8qK

• As shown, many influential factors• End-to-end insight: match rate of

new results to client’s uptake rate• Hard to measure client rate directly

Page 14: Adaptively Parallelizing Distributed  Range  Queries

On Heads• Increase K by 1• Improvement?

Keep increasing K • No? Revert to old K

On Tails • Decrease K by 1• Performance same?

Keep decreasing K• No? Revert to old K

Adaptive server allocation (ASA)

Time

Optimal

K = 1

• Measure client uptake speed• If higher, increase K by 1 and

repeat

Client saturated, enter next phase

Periodically, flip a coin

Page 15: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

Time

Real

K = 1

• Measure client uptake speed• If higher, increase K by 1 and

repeat

Client saturated, enter next phase

Periodically, flip a biased coin w.p. 2/3• On heads, increase or decrease K by 1• If no improvement, revert to old K• Otherwise, keep K and go in the same direction next time we change it.

AB

TAB

T

LE

20M records1024 partitions

100MB/partition100 partitions/server

Experimental Testbed

x 4Clients

Routers

StorageUnits

x 1

x 10

Page 16: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 1

Page 17: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 4

Page 18: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 4

Page 19: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 2

K=5 K=5 K=2 K=8

Page 20: Adaptively Parallelizing Distributed  Range  Queries

Single Client

Routers

Clients

StorageUnits

SCAN

Page 21: Adaptively Parallelizing Distributed  Range  Queries

Multiple Clients

Clients

Routers

StorageUnits

SCAN SCAN

Page 22: Adaptively Parallelizing Distributed  Range  Queries

Multiple Clients

Clients

Routers

StorageUnits

SCAN SCAN Scheduler

Page 23: Adaptively Parallelizing Distributed  Range  Queries

Scheduler Service

• Scan engine shares query information with central scheduler– Servers which hold needed partitions– Parallelism level

• Scheduler decides on who-should-go-where-when to minimize contention

• How do we schedule multiple queries?

qK

Page 24: Adaptively Parallelizing Distributed  Range  Queries

Scheduler Service

• Scan engine shares query information with central scheduler– Servers which hold needed partitions– Parallelism level

• Scheduler decides on who-should-go-where-when to minimize contention

• How do we schedule multiple queries?

qK

Page 25: Adaptively Parallelizing Distributed  Range  Queries

Scheduling Wishlist

a) All queries should finish quicklyb) Give preference to higher priority queriesc) Prefer steady rate of results over bursts

Page 26: Adaptively Parallelizing Distributed  Range  Queries

Scheduling Wishlist

a) All queries should finish quicklyb) Give preference to higher priority queriesc) Prefer steady rate of results over bursts

Thm: The makespan of any greedy heuristic is at most 2∙OPT

= Minimize makespan

Page 27: Adaptively Parallelizing Distributed  Range  Queries

Scheduling Heuristic

a) All queries should finish quicklyb) Give preference to higher priority queriesc) Prefer steady rate of results over bursts

Greedily schedule queries in order by

Current idle period

Priority preference parameter

Page 28: Adaptively Parallelizing Distributed  Range  Queries

Scheduler - Priority

Priority=1

Priority=2

Priority=4

Page 29: Adaptively Parallelizing Distributed  Range  Queries

Scheduler – Result stream

Priority=1

Priority=4

Page 30: Adaptively Parallelizing Distributed  Range  Queries

Scheduler

All queries should finish quicklyGive preference to higher priority queriesPrefer steady rate of results over bursts

Page 31: Adaptively Parallelizing Distributed  Range  Queries

ConclusionSupporting range queries at web-scale is challenging

Too little: client suffers, too much: servers suffer

Adaptive server allocation algorithm

Greedy algorithm run by central schedulerProvably short makespanRespects priorities and provides a steady stream of results

Our solution is entering production soon.

How parallel should a query be?

How do we schedule multiple queries?

Page 32: Adaptively Parallelizing Distributed  Range  Queries
Page 33: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 1

K=2

K=3

K=5

K=8

Page 34: Adaptively Parallelizing Distributed  Range  Queries

Scheduling Wishlist

a) All queries should finish quicklyb) Give preference to higher priority queriesc) Prefer steady rate of results over bursts

Thm: The makespan of any greedy heuristic is at most 2∙OPT

Thm: OPT is exactly

= Minimize makespan

Page 35: Adaptively Parallelizing Distributed  Range  Queries

Scheduling Wishlist

E.g., gold/silver/bronze customersOr minimum completion time = OPT

Priority bias parameterGreater penalty

for long idle time

Set of idle time periods

a) All queries should finish quicklyb) Give preference to higher priority queriesc) Prefer steady rate of results over bursts

Page 36: Adaptively Parallelizing Distributed  Range  Queries

Impact of parallelism

• Range size: Longer queries = more benefit from parallelism.– Diminishing returns

• Query Selectivity: Fewer results = more benefit from parallelism• Client Rate: Faster clients = more benefit from parallelism

– Saturated clients do not benefit from extra servers

Page 37: Adaptively Parallelizing Distributed  Range  Queries

Scheduler - Priority

Greedily schedule queries in order by

Current idle period

Query lengths 1,2,4,8%

Max. completion time

Avg. completion time

Time of first result

Page 38: Adaptively Parallelizing Distributed  Range  Queries

Scheduler - Priority

Greedily schedule queries in order by

Query lengths 1,2,4,8% Different priorities

Page 39: Adaptively Parallelizing Distributed  Range  Queries

Road map

• System and problem overview• Adaptive server allocation• Multi-query scheduling• Conclusion

Page 40: Adaptively Parallelizing Distributed  Range  Queries

Experimental test bed

Clients

AB

T

LE

Clients

Routers

StorageUnits

x 1

x 10

x 420M records1024 partitions

100MB/partition100 partitions/server

Page 41: Adaptively Parallelizing Distributed  Range  Queries

Adaptive server allocation (ASA)

x 4

Page 42: Adaptively Parallelizing Distributed  Range  Queries

PNUTS 101

Clients

Routers

StorageUnits

Partition map

Load balancer

Server monitor

TabletController

TABLE

AB

T LE