Layers - O'Reilly

71
Layers

Transcript of Layers - O'Reilly

Page 1: Layers - O'Reilly

Layers

Page 2: Layers - O'Reilly

Yelp’s MissionConnecting people with great

local businesses.

Page 3: Layers - O'Reilly
Page 4: Layers - O'Reilly

(Abstraction) Layers(related: separation of concerns)

Page 5: Layers - O'Reilly

Abstractions?

"Being abstract is something profoundly different from being vague … The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise." - Edsger Dijkstra

All non-trivial abstractions, to some degree, are leaky. - Joel Spolsky

Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem - David Wheeler

Page 6: Layers - O'Reilly

Danger: I don’t know as much as Rich Hickey

Page 7: Layers - O'Reilly

Identify the Author’s Purpose

A. Persuade the audience that his/her design recommendations are better than the current status quo

B. Inform others about the history of architecture decisions in computer science

C. Inspire engineers to think outside the box when designing systems

D. Entertain the audience with historic anecdotes

E. None of the above

Page 8: Layers - O'Reilly

DevOps

Page 9: Layers - O'Reilly

DevOpsEst. 2009

Page 10: Layers - O'Reilly

Let’s Talk About Devops Features

Wireframes

Tasks

Code / Unit Tests

Build + Release

Deployment | Monitoring | Alerting

QA | Acceptance Tests

PM

UX

Lead Dev

Devs

QA

Release Engineering

Operations

Page 11: Layers - O'Reilly

“What if we got rid of some of the layers?”

Page 12: Layers - O'Reilly

?

Page 13: Layers - O'Reilly
Page 14: Layers - O'Reilly

Let’s Talk About Devops (no-ops?)

Features

Wireframes

Tasks

Code / Unit Tests

QA | Acceptance Tests

Build + Release

Deployment | Monitoring | Alerting

PM

UX

DevsSeparation

OfConcerns

Page 15: Layers - O'Reilly

Why?

● Increased “Performance” (deploys per day)● Better ownership of issues● Harder to hire● Massive increase in developer complexity● Large inter-team communication overhead

Page 16: Layers - O'Reilly

Filesystems

Page 17: Layers - O'Reilly

Let’s talk about filesystems

files

ext4

dm-crypt

Software Raid

Raw Block Devices

LVM

/mnt/stuff/foo

/mnt/stuff

/dev/mapper/luks-17c8...

/dev/mapper/lv0

/dev/md0

/dev/sd{a,b}

Page 18: Layers - O'Reilly

“What if we got rid of some of the layers?”

Page 19: Layers - O'Reilly

Let’s talk about zfs

files

zfs

(zraid)(encryption)(checksums)

(pools)(vdevs)

Raw Block Devices

/mnt/stuff/foo

/mnt/stuff

/dev/sd{a,b}

SeparationOf

Concerns

Page 20: Layers - O'Reilly

Now What?

● Better error detection/recovery● We can deduplicate things● More efficient snapshots / Repair● All new tooling is not interoperable

Page 21: Layers - O'Reilly

New Concept: “Sympathetic Abstraction”

● “Opposite” of “Leaky”?● https://mechanical-sympathy.blogspot.com/

Page 22: Layers - O'Reilly

~ $ ssh -vv leb1.xkyle.com -- trueOpenSSH_7.7p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017debug1: Reading configuration data /home/kyle/.ssh/configdebug1: /home/kyle/.ssh/config line 1: Applying options for leb1.xkyle.comdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug2: resolving "leb1.xkyle.com" port 4242debug2: ssh_connect_direct: needpriv 0debug1: Connecting to leb1.xkyle.com [2607:8b00:0:96::d0eb:ec0a] port 4242....debug1: Entering interactive session.debug1: pledge: networkdebug2: channel_input_open_confirmation: channel 0: callback startdebug2: fd 3 setting TCP_NODELAYdebug2: client_session2_setup: id 0debug1: Sending environment.debug1: Sending env LANG = en_US.UTF-8debug2: channel 0: request env confirm 0debug1: Sending command: true...Transferred: sent 2696, received 2516 bytes, in 0.1 secondsBytes per second: sent 23959.5, received 22359.8debug1: Exit status 0

Page 23: Layers - O'Reilly

https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html?hl=commitlog_sync

commit_failure_policy

(Default: stop) Policy for commit disk failures:

● die● Shut down gossip and Thrift and kill the JVM, so the node can be replaced.● stop● Shut down gossip and Thrift, leaving the node effectively dead, available for inspection using JMX.● stop_commit● Shut down the commit log, letting writes collect but continuing to service reads (as in pre-2.0.5 Cassandra).● ignore● Ignore fatal errors and let the batches fail.

disk_optimization_strategy

(Default: ssd) The strategy for optimizing disk reads. Possible values: ssd or spinning.

disk_failure_policy

(Default: stop) Sets how Cassandra responds to disk failure. Recommend settings: stop or best_effort. Valid values:

● die● Shut down gossip and Thrift and kill the JVM for any file system errors or single SSTable errors, so the node can be

replaced.● stop_paranoid

Page 24: Layers - O'Reilly

Kyle’s Abstraction Law:

“Over time, layers tend toward becoming more sympathetic (or merged) in the pursuit of performance.”

Page 25: Layers - O'Reilly

HTTP(S)

Page 26: Layers - O'Reilly
Page 27: Layers - O'Reilly

OSI Layer Model History

● Published in 1984 under ISO7498 (35 years ago)● Mostly by Charles Bachman from his experience with ARPANET, etc● Written with the purpose of giving protocol designers a Map to follow

Page 28: Layers - O'Reilly
Page 29: Layers - O'Reilly

Layer 6: Presentation

Layer 5: Session

Layer 4: Transport

Layer 2: Data link

Layer 1: Physical

Layer 3: Network

SSL

N/A (Right? HTTP is “stateless”)

TCP (Transmission Control Protocol)

IP (Internet Protocol)

802.11 (Wi-Fi?)

802.11 (Wi-Fi?)

Layer 7: ApplicationHTTP (Hypertext Transfer Protocol)HTTPS in the OSI Network Model

Page 30: Layers - O'Reilly

https://en.wikipedia.org/wiki/Internet_protocol_suite#Comparison_of_TCP/IP_and_OSI_layering

The IETF protocol development effort is not concerned with strict layering. Some of its protocols may not fit cleanly into the OSI model, although RFCs sometimes refer to it and often use the old OSI layer numbers.

The IETF has repeatedly stated that Internet protocol and architecture development is not intended to be OSI-compliant. RFC 3439, addressing Internet architecture, contains a section entitled: "Layering Considered Harmful".

Page 31: Layers - O'Reilly

RFC 1122, Internet STD 3

(1989)

Cisco Academy[28]

Kurose,[29] Forouzan[30]

Comer,[31] Kozierok[32]

Stallings[33] Arpanet Reference Model (RFC 871)

OSI model

Four layers Four layers Five layers Four+one layers Five layers Three layers Seven layers

"Internet model" "Internet model" "Five-layer Internet model" or "TCP/IP protocol suite"

"TCP/IP 5-layer reference model"

"TCP/IP model" "Arpanet reference model"

OSI model

Application Application Application Application Application Application/Process Application

Presentation

Session

Transport Transport Transport Transport Host-to-host or transport

Host-to-host Transport

Internet Internetwork Network Internet Internet Network

Link Network interface Data link Data link (Network interface)

Network access Network interface Data link

Physical (Hardware) Physical Physical

Page 32: Layers - O'Reilly

Layer 6: Presentation

Layer 5: Session

Layer 4: Transport

Layer 2: Data link

Layer 1: Physical

Layer 3: Network

SSL

N/A (Right? HTTP is “stateless”)

TCP (Transmission Control Protocol)

IP (Internet Protocol)

802.11 (Wi-Fi?)

802.11 (Wi-Fi?)

Layer 7: ApplicationHTTP (Hypertext Transfer Protocol)HTTP in the OSI Network Model

Page 33: Layers - O'Reilly

“What if we got rid of some of the layers?”

Page 34: Layers - O'Reilly

Transport Layer (OSI 4)

Link Layer (OSI 1,2)

Internet Layer (OSI 3)

UDP (User Datagram Protocol)

IP (Internet Protocol)

802.11 (Wi-Fi)

Application Layer (OSI 5,6,7)

EncryptionSessions

MultiplexingError Correction

QUIC(Quick UDP Internet Connections)

QUIC in the IP Model

SeparationOf

Concerns

Page 35: Layers - O'Reilly
Page 36: Layers - O'Reilly

Now What?

● Roaming sessions● 0-RRT Handshakes● Better throughput● Better loss recovery● You can’t debug via tcpdump anymore!● Only a few companies has dared to ship this!● Very poor tooling / ecosystems around it!● Must have faith in QUIC-crypto!

Page 37: Layers - O'Reilly

(Micro) Services

Page 38: Layers - O'Reilly

Rails App

Model View

Controller

Users

Mysql

Page 39: Layers - O'Reilly

“What if we ADDED some more layers?”

Page 40: Layers - O'Reilly

Users

API Gateway

Users Service SearchTweetsAds Moments

Ads Mysql User

MysqlSearch

Infra MomentsSQLTweets

NoSQL

Followers

Graph DB

Timeline

Page 41: Layers - O'Reilly
Page 42: Layers - O'Reilly
Page 43: Layers - O'Reilly

Now What?

● No more atomic cross-cutting changes● Simplified deploy process? (Simple for who?)● Polyglot stack (easy to hire for)● No more unified tooling● You scale out components (scale to millions of rps)● You scale out development (1000 engineers)

Page 44: Layers - O'Reilly
Page 45: Layers - O'Reilly

k8s

Page 46: Layers - O'Reilly

Layer 3: Application Code

Layer 1: IaaS VM

Layer 0: IaaS Provider Bare Metal

Layer 2: OS

Java Jar

Ubuntu x86_64

c5.xlarge

N/A

Traditional Cloud

Deployment

Page 47: Layers - O'Reilly

“What if we ADDED EVEN MORE layers?”

Page 48: Layers - O'Reilly

Layer 4: Pod

Layer 3: Container Orchestration

Layer 1: IaaS VM

Layer 0: IaaS Provider Bare Metal

Layer 2: OS

pod-foo

kublet

Ubuntu x86_64

c5.xlarge

N/A

Layers of a k8s Infra

Layer 5: Containerdocker

Layer 6: Processjava -jar

Page 49: Layers - O'Reilly

Layer 5: k8s federation

Layer 4: k8s cluster

Layer 3: Deployment / ReplicaSet

Layer 1: Docker Container

Layer 0: Process

Layer 2: Pod

Prod k8s federation

uswest1-prod

Frontend replicaset

myapp-pod

FROM apache2

httpd

K8s Layers

Page 50: Layers - O'Reilly

“What if we got rid of some of the layers?”

Page 51: Layers - O'Reilly

AWS Metal Instances

Page 52: Layers - O'Reilly

Layer 0/1: IaaS Provider Bare MetalHardware

Future Layers

Page 53: Layers - O'Reilly

Layer 0/1: IaaS Provider Bare MetalHardware

Future Layers Extreme Example -

Unikernels?

Layer 2-7: Unikernel(No OS, just a directly booting

application)MirageOS, etc

Page 54: Layers - O'Reilly

Layer 0/1: IaaS Provider Bare MetalHardware

Future Layers - AWS Lambda / FaaS?

Layer 2-5: Amazon / k8s StuffSame Stuff As Before

Layer 7: Your ProcessYour Code

Layer 6: ContainerFirecracker / Docker

Page 55: Layers - O'Reilly

What? We Are Back To Where We Started?

● Where is the mechanical sympathy?● What happened to Layer-Smashing, Kyle?● Three Reasons why we are moving this direction...

Page 56: Layers - O'Reilly

Layer 0/1: IaaS Provider Bare MetalHardware

Reason 1:You have a layer for just the stuff you care about

Layer 2-5: Amazon / k8s StuffSame Stuff As Before

Layer 7: Your ProcessYour Code

Layer 6: ContainerFirecracker / Docker

Page 57: Layers - O'Reilly

k8s pods

Apache

API Gateway + FaaS Controller(Request Routing)(Compute Dispatch)

Reason 2: Sympathetic routing and dispatchOr “Functions as a Service (Serverless)” Layer Smashing

Autoscaling Group(Compute Dispatch)

Apache

Elastic Load Balancer(Request Routing)

Apache

Page 58: Layers - O'Reilly

Reason 3:Sympathetic Compute Scheduling Layers(k8s operators)

Autoscaling Group

MySQL

MySQL

?

K8s MySQL Operator

MySQL

MySQL

I know what I

must do

Page 59: Layers - O'Reilly
Page 60: Layers - O'Reilly

Conclusions?

1. “Sympathetic Layers” are the best layers!

2. k8s operators and FaaS as re-slicing where the layers are (for the greater good!)

3. You should watch “Simple Made Easy” before changing your mindhttps://www.infoq.com/presentations/Simple-Made-Easy

Page 61: Layers - O'Reilly

Hold for (shameless) applause,

Then

Questions?

SEPARATION OF

CONCERNS

IS OVERRATED

Page 62: Layers - O'Reilly
Page 63: Layers - O'Reilly
Page 64: Layers - O'Reilly

Attribution● OSI Layers - http://www.gargasz.info/osi-model-how-internet-works/● Simple Made Easy - The Art of Unix Programming (2003) - Eric S. Raymond

Page 65: Layers - O'Reilly

X

Page 66: Layers - O'Reilly

Linux Kernel

GPU

X Server

X Client (GUI App)

X11 Protocol over Socket /tmp/.X11-unix/X0

Ioctl via libdrm/dev/dri/card0

3d Game

Ioctl via libdrm/dev/dri/card0

Window Manager

Page 67: Layers - O'Reilly

“Mechanism, not policy”

Page 68: Layers - O'Reilly
Page 69: Layers - O'Reilly

“What if we got rid of some of the layers?”

Page 70: Layers - O'Reilly
Page 71: Layers - O'Reilly

Now What?

● Lower latency GUI Interactions● NO TEARING