Massive Multitenancy with V8 Isolates Kenton Varda - Tech Lead, - - PowerPoint PPT Presentation

massive multitenancy with v8 isolates
SMART_READER_LITE
LIVE PREVIEW

Massive Multitenancy with V8 Isolates Kenton Varda - Tech Lead, - - PowerPoint PPT Presentation

Massive Multitenancy with V8 Isolates Kenton Varda - Tech Lead, Cloudflare Workers The Challenge 165 Locations and growing Scalability can mean... Traffic (requests) Easy: More locations = more capacity. Tenants (apps) Hard: Every tenant in


slide-1
SLIDE 1

Massive Multitenancy with V8 Isolates

Kenton Varda - Tech Lead, Cloudflare Workers

slide-2
SLIDE 2

The Challenge

slide-3
SLIDE 3

165 Locations and growing

slide-4
SLIDE 4

Scalability can mean...

Tenants (apps)

Hard: Every tenant in every location. Some locations are small!

Traffic (requests)

Easy: More locations = more capacity.

slide-5
SLIDE 5

Needed: Efficiency

slide-6
SLIDE 6

I, , made or led:

  • Protobufs v2
  • Cap'n Proto
  • Sandstorm.io
  • Cloudflare Workers

Warning - I am :

  • An experienced speaker
  • A graphics designer
slide-7
SLIDE 7

Efficiency...

App Code Footprint VM: 10GB Container: 100MB Needed: < 1MB Context Switching VM: low Container: medium Needed: extreme Baseline Memory Usage VM: 1GB Container: 100MB Needed: < 5MB Startup Time VM: 10s Container: 500ms Needed: < 5ms

slide-8
SLIDE 8

Other use cases

APIs

Run client code directly on API server.

Big Data Processing

Run code where the data lives.

Web Browsers

Run code from visited sites.

slide-9
SLIDE 9

We built this already!

slide-10
SLIDE 10

Browsers are optimized for...

slide-11
SLIDE 11

V8 JavaScript Runtime: An Extreme Multitenancy Engine

slide-12
SLIDE 12

Isolates and APIs

slide-13
SLIDE 13
slide-14
SLIDE 14

Hardware (virtualized) Operating System Libraries Application Provided by host Provided by guest Hardware Operating System Application Hardware Operating System Uncommon libraries Application Web Platform APIs

VMs Containers Isolates

JS Runtime Language Runtime Libraries Language Runtime

slide-15
SLIDE 15

HTTP client: HTTP server:

slide-16
SLIDE 16

Language Libraries Application Hardware Operating System Uncommon libraries Application

WASM Isolates

Language Runtime API Bindings

WebAssembly?

Missing a way to share common runtimes...

Web Platform APIs JS Runtime Hardware Operating System Web Platform APIs JS Runtime

slide-17
SLIDE 17

Resource Management

slide-18
SLIDE 18

OOM Killing

as a First Resort

Isolate Isolate Isolate Isolate Isolate Isolate Isolate Isolate Isolate Isolate Isolate

OOM priority

Desired total memory usage. Evict these. Prioritize: LRU, high memory usage

slide-19
SLIDE 19

Resource limits

CPU

Isolates run on separate threads. timer_create(CLOCK_THREAD_CPUTIME_ID) isolate.TerminateExecution()

RAM

Monitor with isolate.GetHeapStatistics() Evict isolates that go over limit.

slide-20
SLIDE 20

Code Distribution

slide-21
SLIDE 21

Security

slide-22
SLIDE 22

Is V8 secure enough for servers?

slide-23
SLIDE 23

Deep in v8/src/compiler/typer.cc… Optimizer: "Math.expm1() can return real number or NaN." Forgot: -0 (negative zero) Full sandbox breakout!

Awesome writeup: Google "Andrea Biondo V8 bug"

Link: https://abiondo.me/2019/01/02/exploiting-math-expm1-v8/

V8 bugs...

slide-24
SLIDE 24

NOTHING IS "SECURE"

Security is Risk Management

slide-25
SLIDE 25

Relatively more bugs than VMs. Reasons:

  • Larger attack surface (Bad)
  • More research (Good)

○ Bug Bounty ○ Fuzzing ○ Important target

slide-26
SLIDE 26

Risk Management

Browser Server

VS

slide-27
SLIDE 27

Risk Management

Browser Server

Install updates fast.

VS

slide-28
SLIDE 28

Risk Management

Browser Server

Install updates fast. Install updates faster.

VS

slide-29
SLIDE 29

Risk Management

Browser Server

Install updates fast. Use separate profiles for trusted vs "suspicious" sites. Install updates faster.

VS

slide-30
SLIDE 30

Risk Management

Browser Server

Install updates fast. Use separate profiles for trusted vs "suspicious" sites. Install updates faster. Use separate processes for trusted vs. "suspicious" tenants.

VS

slide-31
SLIDE 31

Risk Management

Server

VS

Browser

slide-32
SLIDE 32

Risk Management

Server

Store all scripts ever uploaded for forensic purposes. No eval().

VS

Browser

slide-33
SLIDE 33

Risk Management

Server

Store all scripts ever uploaded for forensic purposes. No eval(). Watch for segfaults, inspect scripts that cause them.

VS

Browser

slide-34
SLIDE 34

Risk Management

Server

Store all scripts ever uploaded for forensic purposes. No eval(). Watch for segfaults, inspect scripts that cause them.

VS

Browser

… can't, privacy violation.

slide-35
SLIDE 35

What about Spectre?

slide-36
SLIDE 36
slide-37
SLIDE 37

We have no solution except process isolation. We can neither confirm nor deny that process isolation is enough.

slide-38
SLIDE 38

Thread 1 Thread 2

No (local) timers (at all!) No (local) concurrency Freedom to reschedule

slide-39
SLIDE 39

Big Picture

slide-40
SLIDE 40

Mainframe Commodity Server Virtual Machine Container Isolate Units of Compute

Granularity

slide-41
SLIDE 41

Questions?