Top Banner
Deploying Akka in Production Do’s and Don’ts when Mike Nash
32

Do's and don'ts when deploying akka in production

Sep 05, 2014

Download

Software

jglobal

Do's and Dont's when Deploying Akka in Production
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: Do's and don'ts when deploying akka in production

Deploying Akka in Production

Do’s and Don’ts when

Mike Nash

Page 2: Do's and don'ts when deploying akka in production

Introduction

We’ve deployed dozens of Akka-based services and apps to production in the past 5 years

We’ve scaled up to tens of millions of events per hour, day after day

Our team has learned where the potholes are

Page 3: Do's and don'ts when deploying akka in production

Architecting for Performance

Going reactive before the first line of code is written

Page 4: Do's and don'ts when deploying akka in production

Code Quality and ArchitectureQuality = lower cost of future changes

Correct architecture = longevity, e.g the system lives on even if parts are replaced in flight

Many small pieces usually work better than a few big ones

Find out about Ports and Adapters/Onion Architecture: Keep domain and infrastructure distinct

Page 5: Do's and don'ts when deploying akka in production

Delivery Guarantees

Understand what guarantees Akka provides - and what it doesn’t

The best design is often the one that doesn’t need many guarantees

Most “guarantees” are imaginary in any case

Page 6: Do's and don'ts when deploying akka in production

Single Points of ContentionDatabase?

Page 7: Do's and don'ts when deploying akka in production

Blocking OperationsLook for blocking operations

Page 8: Do's and don'ts when deploying akka in production

ImmutabilityEncapsulate state in Actors (or Agents)

Messages must be immutable

Page 9: Do's and don'ts when deploying akka in production

Keep it Simple

Just because you can doesn’t mean you should

Simple, independent pieces are best

Keep your code out of other people’s databases

Distinguish between Commands and Events

Page 10: Do's and don'ts when deploying akka in production

Think about back-pressureThink about back pressure: Look for any situations where mailboxes might be allowed to grow without limits

Slow producer is not a big problem

Slow consumer can be a big problem

Akka streams

Think about dispatchers and routers: The defaults are not always what you want.

Page 11: Do's and don'ts when deploying akka in production

SerializationThink about for remote actors

Default requires some class path magic

Choices include text, json, protobuf, many others, all with tradeoffs

Benchmark your serializer/deserializer!

Page 12: Do's and don'ts when deploying akka in production

Actor? Future? Agent?Actors encapsulate State or Behaviour, they have a mailbox and a name

Futures contain and retrieve the result of a concurrent operation

Agents encapsulate a value (at a single location) - immediate read, async writes

Page 13: Do's and don'ts when deploying akka in production

TestingCommon performance blockers under heavy load

Page 14: Do's and don'ts when deploying akka in production

Testing

Beyond the Obvious

Unit and Functional are the Foundation

Akka TestKit: Test actors as if they were synchronous

“Negative” tests are essential

Page 15: Do's and don'ts when deploying akka in production
Page 16: Do's and don'ts when deploying akka in production

JVM Tuning

Page 17: Do's and don'ts when deploying akka in production

MemoryYou need more than you think you need

Page 18: Do's and don'ts when deploying akka in production

Know your Garbage CollectorsMust run under load to see characteristics

Defaults are probably not what you want

Takes more memory to free up more memory…

-verbosegc is your friend

Page 19: Do's and don'ts when deploying akka in production

Production DeploymentsTips for a rock-solid deployment pipeline

Page 20: Do's and don'ts when deploying akka in production

Deployment Pipeline

Not just about getting to production

How will you deploy new versions without downtime?

How will you revert if you have to?

It’s 2 am - Do you know where your dependencies are?

Page 21: Do's and don'ts when deploying akka in production

Deployment PackagingHow will you get your app to production? Onejar?

In our experience, external containers are not helpful

How will you tell if its the right version and revision?

Rolling Restarts?

Page 22: Do's and don'ts when deploying akka in production

Dependencies

Your application or service sits atop a tall stack of dependencies

Is the stack in the same order on production?

Is it the same stack?

Page 23: Do's and don'ts when deploying akka in production

Configuration

Akka’s configuration works great - don’t fix it!

Discovery beats hard-wiring

Procrastinate

Page 24: Do's and don'ts when deploying akka in production

MonitoringBeyond Testing

Page 25: Do's and don'ts when deploying akka in production

MonitMore than monitoring

Page 26: Do's and don'ts when deploying akka in production

Statsd, GraphiteCustom timing and counts

Page 27: Do's and don'ts when deploying akka in production

KamonSpecifically for Reactive Applications

Page 28: Do's and don'ts when deploying akka in production

What happens when….?

Boundary Conditions

Page 29: Do's and don'ts when deploying akka in production

LoggingRelated to monitoring, but very different Surprisingly expensive - consider async, macros (like ScalaLogging) to omit when level disabled Line numbers are *very* expensive, check your formats Log rolling strategy is critical Consider Graylog or similar to view logs across multiple nodes, filter, route and alert on log contents Consider ssh server or remote message to change log level on the fly for a running system Logback’s Mapped Diagnostic Context can be handy

Page 30: Do's and don'ts when deploying akka in production

Security

Beyond the usual security concerns any application has

How will you prevent “fake” messages from being handled?

There is such a thing as too much of a good thing

Page 31: Do's and don'ts when deploying akka in production

Summary

Page 32: Do's and don'ts when deploying akka in production