+ All Categories
Home > Technology > System Design & Scalability

System Design & Scalability

Date post: 13-Apr-2017
Category:
Upload: john-difini
View: 83 times
Download: 2 times
Share this document with a friend
28
System Design & Scalability A quick reference guide By John DiFini
Transcript
Page 1: System Design & Scalability

System Design & ScalabilityA quick reference guide

By John DiFini

Page 2: System Design & Scalability

Overview• Types of Scaling & Load Balancing• Data Storage Design• Message-oriented Middleware (MOM)• Fault Handling• Networking• MapReduce

Page 3: System Design & Scalability

Types of Scaling & Load Balancing

Page 4: System Design & Scalability

Horizontal vs. Vertical ScalingType Scaling

ProcessExample Complexit

yLimited

Vertical Add more resources to a single node

Add more memory to a single server

Easy Yes (e.g. can only add so much memory)

Horizontal

Add more nodes

Add more servers

Hard Practically unlimited

Page 5: System Design & Scalability

Load Balancing• Round Robin• Source IP Hash - a given client IP address will

always go to the same server• Request Hash - a given request type will always go

to the same server/cache; avoids cache duplication

• Least Connections• Least Traffic• Least Latency

Reference

Page 6: System Design & Scalability

Data Storage Design

Page 7: System Design & Scalability

Database - Read vs. Write Performance• Normalize vs. Denormalize

Normalize - ↓duplicate data ⇨ ↑write perf but ↓read perf

Denormalize - ↑duplicate data ⇨ ↑read perf but ↓write perf

• Have your cake and… - Use an append-only structure for writes; then asynchronously restructure data into a read-optimized format[*]

Page 8: System Design & Scalability

Database - Structure• Relational - general purpose for tabular/table-

based data• Specialized - for data structures that don't easily

fit the tabular format (e.g. multi-level nesting & hierarchies) NoSQL Others

Page 9: System Design & Scalability

Not to be confused with...Cache• DB reads are expensive; i.e. hold as

much of it in memory as possible• Cache Hit - data were found in cache;

Cache Miss - data not found, so retrieve it from DB[*]

• Local vs. Distributed Rule of Thumb - use local cache for small data sets, with predictable number of immutable records[*]

• Cache Warming - anticipate queries and "prime" the cache not only on startup but also in real-time (e.g. load surrounding tiles of a recently-requested map)

Page 10: System Design & Scalability

Cache - Replacement Policy• Replacement Policy - algorithm used to maximize

cache performance by choosing which data to eject & which data to add in its place[*]

LRU - ejects the most Least Recently Used data advanced - considers access frequency, size of

items, latency & throughput

LRUMRUCache:

Page 11: System Design & Scalability

Data Store ShardingSharding - partition data across multiple nodes

Not to be confused with...

Type Scaling Process Drawback

Table-based Put Table A on Node 1, Table B on Node 2, etc.

What if a table gets too large for its node?

Hash-based Primary key is hashed, and every node is responsible for a range of hashed keys

What happens if the # of nodes changes? -> need to reallocate all the data

Directory-based lookup service keeps track of which data are stored in which shard

What if directory service is down (i.e. single point of failure)?What if directory service has to process to many requests (i.e. a bottleneck)?

Page 12: System Design & Scalability

Message-oriented Middleware(MOM)

Page 13: System Design & Scalability

MOM Considerations• Used by distributed systems to communicate

amongst nodes[*]

• Abstracts OS & network intricacies (e.g. endian format, sockets, etc.)

Page 14: System Design & Scalability

MOM TypesType Use Case Examples Underlying

ProtocolCast

Request/Response

1 sender; 1 receiver (point-to-point)

e.g. Stock Trade Order[*]

Synchronous - JSON Web Services

Asynchronous - message queues like ActiveMQ, IBM MQ

TCP ("guaranteed" delivery)

Unicast

Publish/Subscribe

1 sender; many receivers/listeners

e.g. Stock Tick

Kafka[*], TIBCO Rendezvous/RV

UDP Broadcast (all nodes) or Multicast (node groups)

Page 15: System Design & Scalability

Fault Handling

Page 16: System Design & Scalability

Fault Handling• High Availability (HA) - delayed recovery to

secondary • Fault Tolerant - immediate recovery

Active/Passive - primary fails over to secondary

Active/Active - no primary vs. secondary; when 1 fails, the other(s) takes the additional load

What is deadshould never die

• Great YouTube video on the subject!• @todo - explain no-special-node, ring topologies

Page 17: System Design & Scalability

Networking

Page 18: System Design & Scalability

Network Metrics• Bandwidth - The maximum amount of data that

can be transferred in a unit of time (e.g. 100Mbps)[*]

• Throughput - The actual amount of data that is transferred in a unit of time (e.g. 88MBps)

• Latency - The time it takes to send & receive (round-trip) a packet of data (e.g. 20ms)[*]

Page 19: System Design & Scalability

Network Metrics - AnalogyGiven a water pipe, its diameter determines its throughput, and its length determines its latency. Therefore, to improve:• Throughput - Get a fatter pipe• Latency - Colocate to reduce distance or reduce

network hops (point-to-point), which also reduces distance that data have to travel

Page 20: System Design & Scalability

MapReduce

Page 22: System Design & Scalability

MapReduce - StepsFundamentally, consists of two steps, Map & Reduce, but Shuffle step is also prevalent:• Map - Organizes/filters/sorts. Think of putting elements

into a typical Map Interface with key-value pairs (e.g. <key, value>)

• Shuffle - Redistributes data so that all data pertaining to a given key reside on reside on the same node

• Reduce - Summary/aggregation (e.g. sum all values for a given key)

Page 23: System Design & Scalability

Coming Soon

Page 24: System Design & Scalability

Coming SoonDefine P9s

Page 25: System Design & Scalability

templates

Page 26: System Design & Scalability

color palette

Page 27: System Design & Scalability

section template

Page 28: System Design & Scalability

bullet templateasdfasdf

asdfasdf

asdfasdf


Recommended