+ All Categories
Home > Data & Analytics > Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East...

Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East...

Date post: 22-Jan-2018
Category:
Upload: spark-summit
View: 425 times
Download: 0 times
Share this document with a friend
74
OPTIMIZING SPARK DEPLOYMENTS FOR CONTAINERS: ISOLATION, SAFETY, AND PERFORMANCE William Benton @willb Red Hat, Inc.
Transcript
Page 1: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

OPTIMIZING SPARK DEPLOYMENTS FOR CONTAINERS: ISOLATION, SAFETY, AND PERFORMANCE

William Benton • @willb Red Hat, Inc.

Page 2: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

OPTIMIZING SPARK DEPLOYMENTS FOR CONTAINERS: ISOLATION, SAFETY, AND PERFORMANCE

William Benton • @willb Red Hat, Inc.

Page 3: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

ForecastBackground and definitions

Architectural concerns

Security concerns

Performance concerns

Conclusions and takeaways

Background and definitions

Page 4: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

ForecastBackground and definitions

Architectural concerns

Security concerns

Performance concerns

Conclusions and takeaways

Background and definitions

Architectural concerns

Page 5: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

ForecastBackground and definitions

Architectural concerns

Security concerns

Performance concerns

Conclusions and takeaways

Background and definitions

Architectural concerns

Security concerns

Page 6: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

ForecastBackground and definitions

Architectural concerns

Security concerns

Performance concerns

Conclusions and takeaways

Page 7: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Preliminaries

Page 8: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

What is a container?…a lightweight VM?

…a way to totally isolate applications?

…a packaging format for a container runtime or orchestration platform?

Page 9: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

Page 10: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

Page 11: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root /

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

Page 12: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root /

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

Page 13: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root /tmp/foo

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

container runtime

Page 14: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root /tmp/foo

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

container runtimeSPEED LIMIT

55

Page 15: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

/

Page 16: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

pid

root

net

$SPARK_HOME/bin/spark-class \ org.apache.spark.deploy.worker.Worker \ master:7077

/

Page 17: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

What is a container?…a lightweight VM?

…a way to totally isolate applications?

…a packaging format for a container runtime or orchestration platform?

Page 18: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

What is a container?…a lightweight VM?

…a way to totally isolate applications?

…a packaging format for a container runtime or orchestration platform?

…a lightweight means to address some of the same use cases as VMs.

Page 19: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

What is a container?…a lightweight VM?

…a way to totally isolate applications?

…a packaging format for a container runtime or orchestration platform?

…a lightweight means to address some of the same use cases as VMs.

…a way to provide reasonable, not exhaustive application isolation.

Page 20: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

What is a container?…a lightweight VM?

…a way to totally isolate applications?

…a packaging format for a container runtime or orchestration platform?

…a lightweight means to address some of the same use cases as VMs.

…a way to provide reasonable, not exhaustive application isolation.

…yes, but really just any Linux process with some special settings!

Page 21: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Architectural considerations

Page 22: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Microservice architectures

Page 23: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Microservice architectures

Page 24: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Microservice architectures

Page 25: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Microservice architectures

Page 26: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

events

databases

file, object storage

transform

transform

transform

archive

Page 27: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

events

databases

file, object storage

transform

transform

transform

archive

Page 28: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

events

databases

file, object storage

management

web and mobile

reporting

developer UItransform

transform

transform

archive

Page 29: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

events

databases

file, object storage

management

web and mobile

reporting

developer UItransform

transform

transform

archive

Page 30: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

archive

events

databases

file, object storage

management

web and mobile

reporting

developer UItransform

transform

transform

Page 31: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

archive

events

databases

file, object storage

management

web and mobile

reporting

developer UItransform

transform

transform

Page 32: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

High-level app architecture

federate

trainmodels

archive

events

databases

file, object storage

management

web and mobile

reporting

developer UItransform

transform

transform

Spark is a natural fit for microservice architectures, since executors are microservices!

Page 33: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Monolithic Spark clustersCluster scheduler

Shared FS / object store

Spark executor

Spark executor

Spark executor

Spark executor

Spark executor

Spark executor

Resource manager

app 1 app 2

app 4app 3

Databases

Page 34: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Monolithic Spark clustersCluster scheduler

Shared FS / object store

Spark executor

Spark executor

Spark executor

Spark executor

Spark executor

Spark executor

Resource manager

app 1 app 2

app 4app 3

Databases

Page 35: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

One cluster per applicationResource manager

Shared FS / object store

app 1 app 2

app 5app 4

app 3

app 6

Databases

Page 36: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

One cluster per applicationResource manager

Shared FS / object store

app 1 app 2

app 5app 4

app 3

app 6

app 2

app 4

Databases

Page 37: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Security

Page 38: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton
Page 39: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton
Page 40: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

systemd

qemu

qemu

qemu

Page 41: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

systemd

nginx

mongodb

spark-class /tmp/foo

/tmp/bar

/tmp/blah

Page 42: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

systemd

nginx

mongodb

spark-class

Page 43: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

spark-class /tmp/foo

systemd

nginx

Use SELinux

Page 44: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

spark-class /tmp/foo

systemd

nginx

Use SELinux

Page 45: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

spark-class /tmp/foo

systemd

nginxSELinux limits your exposure to an exploit in a container or a bug in a container runtime.

Use SELinux

Page 46: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Root is root

/tmp/foo

Page 47: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Root is root

/

Page 48: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Denials of service

/tmp/foo

Page 49: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Denials of service

/tmp/foo

Page 50: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Kernel panics

/tmp/foo

Page 51: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Kernel panics

/tmp/foo

Page 52: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secrets

/tmp/foo

Page 53: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secrets

/tmp/foo

Shared FS / object store

ACCESS_KEY=… SECRET_KEY=…

Page 54: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secrets

cat <<EOF > secret.txt ACCESS_KEY=… SECRET_KEY=… EOF git add secret.txt

Page 55: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secretscat <<EOF > secret.txt ACCESS_KEY=… SECRET_KEY=… EOF git add secret.txt

export ACCESS_KEY=… export SECRET_KEY=…

Page 56: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secretscat <<EOF > secret.txt ACCESS_KEY=… SECRET_KEY=… EOF git add secret.txt

export ACCESS_KEY=… export SECRET_KEY=…

kubectl create secret \ generic mysecrets \ --from-file=… \ --from-file=…

Page 57: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Keeping secretscat <<EOF > secret.txt ACCESS_KEY=… SECRET_KEY=… EOF git add secret.txt

export ACCESS_KEY=… export SECRET_KEY=…

kubectl create secret \ generic mysecrets \ --from-file=… \ --from-file=…

Page 58: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Performance

Page 59: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

Page 60: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

Hypervisors introduce overhead. Use more lightweight isolation mechanisms to preserve performance.

Page 61: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

Page 62: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

Page 63: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfallsVirtualized networking likely has minimal impact on overall application performance!

Page 64: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfallsVirtualized networking likely has minimal impact on overall application performance!

…but measure the performance of your I/O configuration!

Page 65: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

Page 66: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

SPEED LIMIT 55

Page 67: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

SPEED LIMIT 55

Quotas mean some ubiquitous techniques can have surprising performance impact. Consider in particular parallel GC and disk buffer cache use.

Page 68: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Potential performance pitfalls

SPEED LIMIT 55

Be sure you set your heap sizes based on your resource limits…or wait for OpenJDK 9!

Page 69: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Conclusions and takeaways

Page 70: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Architectural takeawaysSpark executors are already microservices.

Consider using a single Spark cluster per application for flexible scheduling and easy deployments.

Persistent storage lives outside of containers and is probably best accessed via service interfaces rather than through filesystem interfaces.

Page 71: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Security takeawaysIt isn’t safe to run arbitrary code just because you put it in a container.

Use SELinux to minimize your exposure to error and malice.

Don’t run as root unless you absolutely have to (and you probably don’t).

Ad hoc mechanisms for configuring secrets are likely to leak information and are almost always a bad idea.

Page 72: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Performance takeawaysAvoid hypervisor overhead by using different approaches to isolation.

Measure everything, but virtualized networking likely has a minimal performance impact on real applications.

Artificially throttled performance can be a real problem. Experiment with JVM settings, including serial GC, to reduce your chance of getting limited.

Page 73: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

Configuration takeawaysIf you consume logs from standard output and error, consider using an alternate stack trace formatter to get exceptions in a single log record.

If you use ephemeral user IDs, set SPARK_USER or use nss_wrapper so Hadoop file libraries won’t get confused.

Page 74: Optimizing Spark Deployments for Containers: Isolation, Safety, and Performance: Spark Summit East talk by William Benton

[email protected] • @willb http://radanalytics.io https://chapeau.freevariable.com


Recommended