SlideShare uma empresa Scribd logo
1 de 136
Baixar para ler offline
Konrad `@ktosopl` Malawski @ Tokyo, Scala Matsuri 2016
の zen
Konrad `ktoso` Malawski
(we’re renaming soon!)
Akka Team,
Reactive Streams TCK,
Maintaining Akka Http
Konrad `@ktosopl` Malawski
akka.io
typesafe.com
geecon.org
Java.pl / KrakowScala.pl
sckrk.com / meetup.com/Paper-Cup @ London
GDGKrakow.pl
lambdakrk.pl
(we’re renaming soon!)
はじめまして!
Who are you guys?
Why such talk?
1番: One actor is no Actor
2番: Structure your Actors
3番: Name your Actors
4番: ”Matrix of mutability (Pain)”
5番: Blocking needs careful management
6番: Never Await, for/flatMap instead!
7番: Avoid Java Serialization
7.5番: Trust no-one, benchmark everything!
Agenda
8番: Let it Crash!
9番: Backoff Supervision
10番: Design using State Machines
11番: Cluster Convergence and Joining
12番: Cluster Partitions and “Down”
13番: Akka is a Toolkit.
14番: Happy Hakking, Community!
Questions?
“The Tao / Zen of Programming”
Talk title loosely based on
the “Tao of Programming” book
by Goeffrey James (1987).
「プログラミングの Tao (道)」
“The Tao / Zen of Programming”
And the follow-up book
“Zen of Programming”.
「プログラミングの Zen (禅)」の 2冊に影響を受けたトーク
“The Tao / Zen of Programming”
Available here: http://www.mit.edu/~xela/tao.html
Series of nine “books”,
stories about an apprentice programmer and his sensei.
Thus spake the Master Programmer:
“Without the wind, the grass does not move.
Without software hardware is useless.”
師が弟子に語る形式の 9冊シリーズの一部
「風無くば草は揺れず。ソフト無くばハードは無用の長物。」
The Akka landscape
The Akka landscape
Akka
Actor
IO
Cluster
Cluster Tools (PubSub, Sharding, …)
Persistence & Persistence Query
Streams
HTTP
Typed
1番: One actor is no Actor
1つのアクターは、0個のアクター
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
If you have only one actor then it can only…
1. Reply
2. Drop the message (“ignore”
3. Schedule another message to self
So we’re not really making any use of its
parallelism or concurrency capabilities.
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
アクターは他のアクターと協調するためにある
アクターは一つの責務に特化するべき
1番: One actor is no Actor
- Actors are meant to work together.
- An Actor should do one thing and do it very well
- then talk to other Actors to do other things for it.

- Child Actors usually used for workers or “tasks” etc.

- Avoid using `actorSelection`,

introduce Actors to each other.
アクターはエンティティーを表す
それぞれが「一貫性の島」であるべき
2番: Structure your Actors
2番: Structure your Actors
Different types…
but no structure!
2番: Structure your Actors
Parent / child relationships
also allow for Actor supervision.
2番: Structure your Actors
3番: Name your Actors
3番: Name your Actors
// default
context.actorOf(childProps) // "$a", "$b", "$c"
Default names are: BASE64(sequence_nr++)
Here’s why:
- cheap to generate
- guarantees uniqueness
- less chars than plain numbers
3番: Name your Actors
// default: naming is BASE64(sequential numbers)
context.actorOf(childProps) // "$a", "$b", "$c"
// better: but not very informative...
context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2"
private var _fetchWorkers: Int = 0
private def nextFetchWorkerName: String = {
_fetchWorkers += 1
s”fetch-worker-${_fetchWorkers}”
}
Sequential names are a bit better sometimes.
3番: Name your Actors
// default: naming is BASE64(sequential numbers)
context.actorOf(childProps) // "$a", "$b", "$c"
// better: but not much informative...
context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2"
private var _fetchWorkers: Int = 0
private def nextFetchWorkerName: String = {
_fetchWorkers += 1
s”fetch-worker-${_fetchWorkers}”
}
abstract class SeqActorName {
def next(): String
def copy(name: String): SeqActorName
}
object SeqActorName {
def apply(prefix: String) = new SeqActorNameImpl(prefix, new AtomicLong(0))
}
final class SeqActorNameImpl(val prefix: String, counter: AtomicLong)
extends SeqActorName {
def next(): String = prefix + '-' + counter.getAndIncrement()
def copy(newPrefix: String): SeqActorName = new SeqActorNameImpl(newPrefix, counter)
}
If you use this pattern a lot, here’s a simple encapsulation of it:
3番: Name your Actors
// default: naming is BASE64(sequential numbers)
context.actorOf(childProps) // "$a", "$b", "$c"
// better: but not much informative...
context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2"
private var fetchWorkers: Int = 0
private def nextFetchWorkerName: String = {
fetchWorkers += 1
s"fetch-worker-$fetchWorkers"
}
// BEST: proper names, based on useful information
context.actorOf(childProps, fetcherName(videoUrl)) // "fetch-yt-MRCWy2E_Ts", ...
def fetcherName(link: Link) = link match {
case YoutubeLink(id, metadata) => s"fetch-yt-$id"
case DailyMotionLink(id, metadata) => s"fetch-dm-$id"
case VimeoLink(id, metadata) => s"fetch-vim-$id"
}
Meaningful names are the best!
アクターが適切に命名すべき
アクターの名前は一意で、内容と構造を表す
3番: Name your Actors
Meaningful names are the best!
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import scala.concurrent.duration._
// ... extends Actor with ActorLogging {
override def supervisorStrategy: SupervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) {
case ex: Exception ⇒
log.warning("Child {} failed with {}, attempting restart...",
sender().path.name,
ex.getMessage)
Restart
}
The name of the failed child Actor!
3番: Name your Actors
Meaningful names are the best!
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import scala.concurrent.duration._
// ... extends Actor with ActorLogging {
override def supervisorStrategy: SupervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) {
case ex: Exception ⇒
log.warning("Child {} failed with {}, attempting restart...",
sender().path.name,
ex.getMessage)
Restart
}
The name of the failed child Actor!
// BAD –– String ALWAYS built
log.debug(s"Something heavy $generateId from $physicalAddress")
// GOOD! –– String built only when DEBUG level is ON
log.debug("Something heavy {} from {}", generateId, physicalAddress)
Side note: always use {} log formatting (or macros), not s””
4番: ”Matrix of mutability (Pain)”
4番: ”Matrix of mutability (Pain)”
See Jamie Allen’s talk on the subject.
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
4番: ”Matrix of mutability (Pain)”
See Jamie Allen’s talk on the subject.
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
4番: ”Matrix of mutability (Pain)”
See Jamie Allen’s talk on the subject.
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
4番: ”Matrix of mutability (Pain)”
See Jamie Allen’s talk on the subject.
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
4番: ”Matrix of mutability (Pain)”
See Jamie Allen’s talk on the subject.
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
4番: ”Matrix of mutability (Pain)”
さまざまな可変性
ミュータブル+値よりも、イミュータブル+変数
5番: Blocking needs careful management
正しくは「ブロッキングは注意深く管理すべき」
バルクヘッド(防水隔壁)パターンが有効
5番: Blocking needs careful management
Blocking operations are really bad.
Actors are all about resource sharing, and if someone is “behaving
badly” it hurts everyone.
Here is an example how blocking can grind an app to a halt.
Next we’ll see how to avoid that… even if we have to live with the
blocking code.
ブロック操作を使ってはいけない
アクター同士が共有するリソースを独り占めすると皆が困る
5番: Blocking needs careful management
In simple terms:
Blocking is bad because instead of doing something else,
we just wait and do nothing (wasting CPU time)…
ブロック操作を使ってはいけない
アクター同士が共有するリソースを独り占めすると皆が困る
5番: Blocking needs careful management
Future でブロックしている悪い例
デフォルトのディスパッチャーが枯渇する
5番: Blocking needs careful management
Having that said, it’s not a bad question. Let’s investigate.
Future でブロックしている悪い例
デフォルトのディスパッチャーが枯渇する
5番: Blocking needs careful management
// BAD! (due to the blocking in Future):
implicit val defaultDispatcher = system.dispatcher
val routes: Route = post {
complete {
Future { // uses defaultDispatcher
Thread.sleep(5000) // will block on the default dispatcher,
System.currentTimeMillis().toString // starving the routing infra
}
}
}
Future でブロックしている悪い例
デフォルトのディスパッチャーが枯渇する
5番: Blocking needs careful management
// BAD! (due to the blocking in Future):
implicit val defaultDispatcher = system.dispatcher
val routes: Route = post {
complete {
Future { // uses defaultDispatcher
Thread.sleep(5000) // will block on the default dispatcher,
System.currentTimeMillis().toString // starving the routing infra
}
}
}
Future でブロックしている悪い例
デフォルトのディスパッチャーが枯渇する
5番: Blocking needs careful management
// application.conf
my-blocking-dispatcher {
type = Dispatcher
executor = “thread-pool-executor"
thread-pool-executor {
// in Akka previous to 2.4.2:
core-pool-size-min = 16
core-pool-size-max = 16
max-pool-size-min = 16
max-pool-size-max = 16
// or in Akka 2.4.2+
fixed-pool-size = 16
}
throughput = 100
}
5番: Blocking needs careful management
// GOOD (due to the blocking on a dedicated dispatcher):
implicit val blockingDispatcher = system.dispatchers.lookup("my-blocking-dispatcher")
val routes: Route = post {
complete {
Future { // uses the good "blocking dispatcher" that we configured,
// instead of the default dispatcher – the blocking is isolated.
Thread.sleep(5000)
System.currentTimeMillis().toString
}
}
}
Future でブロックしている良い例
別のディスパッチャーに隔離
5番: Blocking needs careful management
The “Never block!” mantra sounds cool,
but actually what we mean by it is “blocking needs careful management”.
We use the “bulkhead” pattern separate out potentially blocking
behaviours to their independent dispatchers (and should always do so).
http://stackoverflow.com/questions/34641861/akka-http-blocking-in-a-future-blocks-the-server/34645097#34645097
6番: Never Await, for/flatMap instead!
6番: Never Await, for/flatMap instead!
// ... extends Actor {
import context.dispatcher
import scala.concurrent.duration._
import scala.concurrent.Await // bad sign!
// BAD!!!
val fThings: Future[Things] = computeThings()
val t: Things = Await.result(fThings, atMost = 3.seconds)
val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds)
Await してはいけない
代わりに map 関数を使う
6番: Never Await, for/flatMap instead!
// ... extends Actor {
import context.dispatcher
import scala.concurrent.duration._
import scala.concurrent.Await // bad sign!
// BAD!!!
val fThings: Future[Things] = computeThings()
val t: Things = Await.result(fThings, atMost = 3.seconds)
val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds)
// Good:
val fThingsWithDetails = for {
t <- computeThings()
d <- moreDetailsFor(t)
} yield t -> d
fThingsWithDetails foreach {
case (things, details) => // case (things: Things, details: Details) =>
println(s"$things with $details")
}
Await してはいけない
代わりに map 関数を使う
6番: Never Await, for/flatMap instead!
// ... extends Actor {
import context.dispatcher
import scala.concurrent.duration._
import scala.concurrent.Await // bad sign!
// BAD!!!
val fThings: Future[Things] = computeThings()
val t: Things = Await.result(fThings, atMost = 3.seconds)
val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds)
// Good:
val fThingsWithDetails = for {
t <- computeThings()
d <- moreDetailsFor(t)
} yield t -> d
fThingsWithDetails foreach {
case (things, details) => // case (things: Things, details: Details) =>
println(s"$things with $details")
}
// adding timeout:
val timeoutFuture = akka.pattern.after(3.seconds, context.system.scheduler) {
Future.failed(new TimeoutException("My timeout details..."))
}
Future.firstCompletedOf(fThingsWithDetails :: timeoutFuture :: Nil) foreach {
case (things, details) => // case (things: Things, details: Details) =>
println(s"$things with $details")
}
Await してはいけない
代わりに map 関数を使う
7番: Avoid Java Serialization
7番: Avoid Java Serialization
Java Serialization is the default one in Akka, since it’s easy to
get started with it – no configuration needed.
If you need performance and are running on multiple nodes,
you must change the serialization.
Popular formats are ProtoBuf or Kryo.
Kryo is easier, but harder to evolve schema with.
ProtoBuf is harder to maintain but great schema evolution.
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
Benchmarking serialization impact on “ping pong” case.
(Two actors sending a message between them.)
in-process messaging, super fast.

no serialization overhead.
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
more work => increased latency => decreased throughput.
over-the-network messaging,
slower due to network and serialization.
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
Java Serialization is known to be:
very slow & footprint heavy
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
It is on by default in Akka… Why?
a) zero setup => simple to “play around”
b) historical reasons - hard to remove the default
Since 2.4 a warning is logged:

WARNING: Using the default Java serializer for class [{}] which is not recommended
because of performance implications. Use another serializer or disable this warning
using the setting 'akka.actor.warn-about-java-serializer-usage'
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
sbt> jmh:run 

-f 1
-tu us 

-wi 20
-i 10
-jvm /home/ktoso/opt/jdk1.8.0_65/bin/java
-jvmArgsAppend -XX:+PreserveFramePointer
-bm avgt
.*pingPong.*
[info] # JMH 1.10.3 (released 184 days ago, please consider updating!)
[info] # VM version: JDK 1.8.0_65, VM 25.65-b01
[info] # VM invoker: /home/ktoso/opt/jdk1.8.0_65/bin/java
[info] # VM options: -XX:+PreserveFramePointer
[info] # Warmup: 20 iterations, 5 s each
[info] # Measurement: 10 iterations, 1 s each
[info] # Timeout: 10 min per iteration
[info] # Threads: 1 thread, will synchronize iterations
[info] # Benchmark mode: Average time, time/op
[info] # Benchmark: akka.actor.ForkJoinActorBenchmark.pingPong
[info] # Parameters: (serializer = java)
github.com/ktoso/sbt-jmh
openjdk.java.net/projects/code-tools/jmh/
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
[info] # Warmup Iteration 1: 35.717 us/op
. . .
[info] # Warmup Iteration 19: 25.164 us/op
[info] # Warmup Iteration 20: 23.862 us/op
[info] Iteration 1: 25.790 us/op
. . .
[info] Iteration 10: 26.168 us/op


[info] Result "pingPong":
[info] 25.464 ±(99.9%) 1.175 us/op [Average]
[info] (min, avg, max) = (24.383, 25.464, 26.888), stdev = 0.777
[info] CI (99.9%): [24.289, 26.639] (assumes normal distribution)
[info] ForkJoinActorBenchmark.pingPong java avgt 10 25.464 ± 1.175 us/op
[info] ForkJoinActorBenchmark.pingPong off avgt 10 0.967 ± 0.657 us/op
github.com/ktoso/sbt-jmh
openjdk.java.net/projects/code-tools/jmh/
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
Good serializers include (but are not limited to):
Kryo, Google Protocol Buffers, SBE,Thrift, JSON even (sic!)
// dependencies
"com.github.romix.akka" %% "akka-kryo-serialization" % "0.4.0"
// application.conf
extensions = [“com.romix.akka.serialization.kryo.KryoSerializationExtension$"]


serializers { 

java = "akka.serialization.JavaSerializer"
kryo = "com.romix.akka.serialization.kryo.KryoSerializer" 

}
akka.actor.serialization-bindings {
“com.mycompany.Example”: kryo
. . .
}
[info] ForkJoinActorBenchmark.pingPong java avgt 10 25.464 ± 1.175 us/op
[info] ForkJoinActorBenchmark.pingPong kryo avgt 10 4.348 ± 4.346 us/op
[info] ForkJoinActorBenchmark.pingPong off avgt 10 0.967 ± 0.657 us/op
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization
----sr--model.Order----h#-----J--idL--customert--Lmodel/Customer;L--descriptiont--Ljava/lang/String;L--
orderLinest--Ljava/util/List;L--totalCostt--Ljava/math/BigDecimal;xp--------ppsr--java.util.ArrayListx-----
a----I--sizexp----w-----sr--model.OrderLine--&-1-S----I--lineNumberL--costq-~--L--descriptionq-~--L--ordert--
Lmodel/Order;xp----sr--java.math.BigDecimalT--W--(O---I--scaleL--intValt--Ljava/math/BigInteger;xr--
java.lang.Number-----------xp----sr--java.math.BigInteger-----;-----I--bitCountI--bitLengthI--
firstNonzeroByteNumI--lowestSetBitI--signum[--magnitudet--[Bxq-~----------------------ur--[B------T----xp----
xxpq-~--xq-~--
Java Serialization
final case class Order(id: Long, description: String, totalCost: BigDecimal,
orderLines: ArrayList[OrderLines], customer: Customer)
<order id="0" totalCost="0"><orderLines lineNumber="1" cost="0"><order>0</order></orderLines></order>XML…!
{"order":{"id":0,"totalCost":0,"orderLines":[{"lineNumber":1,"cost":0,"order":0}]}}JSON…!
------java-util-ArrayLis-----model-OrderLin----java-math-BigDecima---------model-Orde-----Kryo…!
Excellent post by James Sutherland @
http://java-persistence-performance.blogspot.com/2013/08/optimizing-java-serialization-java-vs.html
Java Serialization は遅い
性能を出したければ、ProtoBuf か Kryo
7番: Avoid Java Serialization for Persistence!!!
Java Serialization is a horrible idea if you’re going to store the
messages for a long time.
For example, with Akka Persistence we store events “forever”.
Use a serialization format that can evolve over time in a
compatible way. It can be JSON or ProtocolBuffers (or Thrift
etc).
Java Serialization を永続化に使わない
スキーマの変更しやすいフォーマットを選ぶべき
7.5番: Trust no-one, benchmark everything!
Always measure and benchmark properly
before judging performance of a tool / library.
Benchmarking is often very hard,
use the right tools:
- JMH (for Scala via: ktoso/sbt-jmh)
-YourKit / JProfiler / …
- Linux perf_events
7.5番
推測するな、計測せよ
ベンチマークを書いてプロファイラでスレッドの挙動を診断
8番: Let it Crash! Supervision, Failures & Errors
http://www.reactivemanifesto.org/
8番: Let it Crash! Supervision, Failures & Errors
Error
… which is an expected and coded-for condition—for
example an error discovered during input validation, that
will be communicated to the client …
Failure
… is an unexpected event within a service that
prevents it from continuing to function normally. 

A failure will generally prevent responses to the current,
and possibly all following, client requests.
http://www.reactivemanifesto.org/
8番: Let it Crash! Supervision, Failures & 「エラー」はビジネスロジックの問題
「障害」はインフラの問題
「エラー」はビジネスロジックの問題
「障害」はインフラの問題
http://www.reactivemanifesto.org/
8番: Let it Crash! Supervision, Failures & Errors
「エラー」はビジネスロジックの問題
「障害」はインフラの問題
http://www.reactivemanifesto.org/
8番: Let it Crash! Supervision, Failures & Errors
Error: “Not enough cash.”
「エラー」はビジネスロジックの問題
「障害」はインフラの問題
http://www.reactivemanifesto.org/
8番: Let it Crash! Supervision, Failures & Errors
Error: “Unable to fulfil request”
Failure: “Row 3 is broken”
「エラー」はビジネスロジックの問題
「障害」はインフラの問題
9番: Backoff Supervision
9番: Backoff Supervision
9番: Backoff Supervision
9番: Backoff Supervision
9番: Backoff Supervision
Our goal is to “let things crash”
and “recover gracefully”
Not to hammer the DB while it tries to recover!
クラッシュさせた上で、しなやかな回復を目指す
9番: Backoff Supervision
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
IF we allowed immediate restarts…
we could end up in “infinite replay+fail hell”.
(we don’t. since Persistence went stable in 2.4.x)
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
Many PersistentActors Fail and Stop.
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
Backoff Supervisor counts failures
and starts “the same” entity after
exponential timeouts.
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
9番: Backoff Supervision
クラスタでは BackoffSupervisor
全アクターが同時に再起動し DB に殺到するのを防ぐ
10番: Design using State Machines
10番: Design using State Machines
def receive = {
case Thingy() =>
// ...
case AnotherThingy() =>
// ...
case DoOtherThings() =>
// ...
case PleaseGoAway() =>
// ...
case CarryOn() =>
// ...
case MakeSomething() =>
// ...
// ...
}
有限状態機械を作る
FSM トレイトか become メソッドを使う
10番: Design using State Machines
def receive = {
case Thingy() =>
// ...
case AnotherThingy() =>
// ...
case DoOtherThings() =>
// ...
case PleaseGoAway() =>
// ...
case CarryOn() =>
// ...
case MakeSomething() =>
// ...
// ...
}
Good:
Actors avoid the “pyramid of doom”.
Pyramid of doom in some
async programming styles.
有限状態機械を作る
FSM トレイトか become メソッドを使う
10番: Design using State Machines
def receive = {
case Thingy() =>
// ...
case AnotherThingy() =>
// ...
case DoOtherThings() =>
// ...
case PleaseGoAway() =>
// ...
case CarryOn() =>
// ...
case MakeSomething() =>
// ...
// ...
}
That well works because
“everything is a message”:
有限状態機械を作る
FSM トレイトか become メソッドを使う
10番: Design using State Machines
def receive = awaitingInstructions
def awaitingInstructions: Receive =
terminationHandling orElse {
case CarryOn() =>
// ...
case MakeSomething(metadata) =>
// ...
context become makeThings(meta)
}
def makeThings(metadata: Metadata): Receive =
terminationHandling orElse {
case Thingy() =>
// make a thingy ...
case AnotherThingy() =>
// make another thingy ...
case DoOtherThings(meta) =>
// ...
context become awaitingInstructions
}
def terminationHandling: Receive = {
case PleaseGoAway() =>
// ...
context stop self
}
有限状態機械を作る
FSM トレイトか become メソッドを使う
DoOtherThings
MakeSomething
10番: Design using State Machines
We also provide an FSM (Finite State Machine) helper trait.
You may enjoy it sometimes, give it a look.
DoOtherThings
MakeSomething
http://doc.akka.io/docs/akka/2.4.1/scala/fsm.html
class Buncher extends FSM[State, Data] {
startWith(Idle, Uninitialized)
when(Idle) {
case Event(SetTarget(ref), Uninitialized) =>
stay using Todo(ref, Vector.empty)
}
// transition elided ...
when(Active, stateTimeout = 1 second) {
case Event(Flush | StateTimeout, t: Todo) =>
goto(Idle) using t.copy(queue = Vector.empty)
}
// unhandled elided ...
initialize()
}
有限状態機械を作る
FSM トレイトか become メソッドを使う
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
Cluster Gossip Convergence
When a node can prove that the cluster state it is observing
has been observed by all other nodes in the cluster.
11番: Cluster Convergence and Joining
http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
Cluster Gossip Convergence
When a node can prove that the cluster state it is observing
has been observed by all other nodes in the cluster.
Convergence is required for “Leader actions”,
which include Join-ing and Remove-ing a node.
Down-ing can happen without convergence.
11番: Cluster Convergence and Joining
http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
11番: Cluster Convergence and Joining
http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
akka.cluster.allow-weakly-up-members=on
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
11番: Cluster Convergence and Joining
Everyone has ‘seen’
Kurt joining,
move him to Up.
11番: Cluster Convergence and Joining
Kurt is now with us
in the Cluster.
11番: Cluster Convergence and Joining
I can’t hear Kurt…
He’s unreachable…
11番: Cluster Convergence and Joining
Kurt does has not
seen Rei… I can not
mark him as Up!
allow-weakly-up-members=off // default
11番: Cluster Convergence and Joining
I’ll mark Rei as
“WeaklyUp” until Kurt
is back.
allow-weakly-up-members=on
allow-weakly-up-members
11番: Cluster Convergence and Joining
Kurt is back! Once he
has seen Rei I’ll mark
Rei as Up.
allow-weakly-up-members=on
allow-weakly-up-members
12番: Cluster Partitions and “Down”
12番: Cluster Partitions and “Down”
12番: Cluster Partitions and “Down”
I’m going
home…
12番: Cluster Partitions and “Down”
Make sure the others have heard you say goodbye before you leave.
Vanishes immediately.
12番: Cluster Partitions and “Down”
Make sure the others have heard you say goodbye before you leave.
“Where’s Bill?
I did not hear him say Goodbye!”
“Failure Detector” used to determine UNREACHABLE.
12番: Cluster Partitions and “Down”
Failure detection only triggers “UNREACHABLE”.
Nodes can come back from that state.
12番: Cluster Partitions and “Down”
Declaring DOWN is done by either timeouts (which is rather unsafe) [auto-downing].
Or by “voting” or “majority” among the members of the cluster [split-brain-resolver].
12番: Cluster Partitions and “Down”
12番: Cluster Partitions and “Down”
お
前
は
も
う
死
ん
で
い
る
.
.
.
.
Node declared “DOWN” comes back…
12番: Cluster Partitions and “Down”
お
前
は
も
う
死
ん
で
い
る
.
.
.
.
12番: Cluster Partitions and “Down”
お
前
は
も
う
死
ん
で
い
る
.
.
.
.
Why do we do that?
In order to guarantee consistency via
“single writer principle”.
Note:
Akka Distributed Data has no need for
“single writer”, it’s CRDT based. But it’s harder to
model things as CRDT, so it’s a trade off.
12番: Cluster Partitions and “Down”
Notice that we do not mention “Quarantined”.
That is a state in Akka Remoting, not Cluster.
It’s a terminal state from which one can never recover.
TL;DR;
use Akka Cluster instead of Remoting.
it’s pretty much always the thing you need (better than remoting).
13番: A fishing rod is a Tool. Akka is a Toolkit.
13番: A fishing rod is a Tool. Akka is a Toolkit.
Akka strives is Toolkit,
not a Framework.
“Give a man a fish and you feed him for a day
teach a man to fish and you feed him for a lifetime.”
13番: Akka is a Toolkit, pick the right tools for the job.
“Constraints Liberate,
Liberties Constrain”
Runar Bjarnason
Runar’s excellent talk @ Scala.World 2015
13番: Akka is a Toolkit, pick the right tools for the job.
Runar’s excellent talk @ Scala.World 2015
The less powerful abstraction
must be built on top of
more powerful abstractions.
13番: Akka is a Toolkit, pick the right tools for the job.
Runar’s excellent talk @ Scala.World 2015
Asynchronous processing toolbox:
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Runar’s excellent talk @ Scala.World 2015
Asynchronous processing toolbox:
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Asynchronous processing toolbox:
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Single value, no streaming by definition.
Local abstraction.

Execution contexts.
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Mostly static processing layouts.
Well typed and Back-pressured!
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Plain Actor’s younger brother, experimental.
Location transparent, well typed.
Technically unconstrained in actions performed
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Runar’s excellent talk @ Scala.World 2015
Location transparent.
Various resilience mechanisms.
(watching, persistent recovering, migration, pools)
Untyped and unconstrained in actions performed.
Akka は道具箱。正しい道具を選ぶべし。
レゴを組み合わせるようにしてアプリを作れる
13番: Akka is a Toolkit, pick the right tools for the job.
Akka it a Toolkit. Not a Framework.
Another example is persisting data.
Akka Persistence is specifically geared towards Event Sourcing.
If you know you you want a raw Key-Value Store and do not need
Event Sourcing’s capabilities, don’t use Akka Persistence –
it would be the wrong tool for the job.
If you use it for Event Sourcing though… it’ll work very well for you.
There it is the right tool for the job.
用途に合わない道具は使うべきではない
例えば CQRS が適切でない時は生 DB アクセスを使えば済む
14番: Happy hAkking, Community!
人にはやさしく
コミュニティーに積極的に参加する
14番: Happy hAkking, Community!
akka.io – website
github.com/akka/akka/issues – help out!
“community-contrib” or “small” for starters
groups.google.com/group/akka-user – mailing list
gitter.im/akka/akka – chat about using Akka
gitter.im/akka/dev – chat about developing Akka
Links
• http://stackoverflow.com/questions/34641861/akka-http-blocking-
in-a-future-blocks-the-server/34645097#34645097
• The wonderful Zen paintings to buy here:

http://paintingwholesalechina.com/products/chinese-culture-zen-
no-1-academic-chinese-painting
• http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
• http://www.mit.edu/~xela/tao.html
• http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
• http://doc.akka.io/docs/akka/2.4.1/scala/cluster-usage.html
• akka.io et al.
https://www.typesafe.com/products/typesafe-reactive-platform
Certified builds & Long Term Support
Advanced commercial features:
Monitoring, Split Brain Resolver, ConductR,
Play User Quotas, Play SOAP
Reactive Platform
ありがとう!
ktoso @ typesafe.com
twitter: ktosopl
github: ktoso
team blog: letitcrash.com
home: akka.io
Thus spake the Master Programmer:
“After three days without programming,
life becomes meaningless.”
Q/A
(Now’s the time to ask things!)
ktoso @ typesafe.com
twitter: ktosopl
github: ktoso
team blog: letitcrash.com
home: akka.io
©Typesafe 2016 – All Rights Reserved

Mais conteúdo relacionado

Mais procurados

SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)Takuto Wada
 
ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発Takafumi ONAKA
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011H Iseri
 
リッチなドメインモデル 名前探し
リッチなドメインモデル 名前探しリッチなドメインモデル 名前探し
リッチなドメインモデル 名前探し増田 亨
 
決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話Ryosuke Uchitate
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Scott Wlaschin
 
ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門増田 亨
 
できる!並列・並行プログラミング
できる!並列・並行プログラミングできる!並列・並行プログラミング
できる!並列・並行プログラミングPreferred Networks
 
会社でClojure使ってみて分かったこと
会社でClojure使ってみて分かったこと会社でClojure使ってみて分かったこと
会社でClojure使ってみて分かったことRecruit Technologies
 
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話Daichi Koike
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話Koichiro Matsuoka
 
すごい配列楽しく学ぼう
すごい配列楽しく学ぼうすごい配列楽しく学ぼう
すごい配列楽しく学ぼうxenophobia__
 
人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with Karate人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with KarateTakanori Suzuki
 
コルーチンでC++でも楽々ゲーム作成!
コルーチンでC++でも楽々ゲーム作成!コルーチンでC++でも楽々ゲーム作成!
コルーチンでC++でも楽々ゲーム作成!amusementcreators
 
オブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメオブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメYoji Kanno
 
40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていることonozaty
 
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~啓 杉本
 
SPAセキュリティ入門~PHP Conference Japan 2021
SPAセキュリティ入門~PHP Conference Japan 2021SPAセキュリティ入門~PHP Conference Japan 2021
SPAセキュリティ入門~PHP Conference Japan 2021Hiroshi Tokumaru
 

Mais procurados (20)

SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
 
ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発ふつうのRailsアプリケーション開発
ふつうのRailsアプリケーション開発
 
C# 9.0 / .NET 5.0
C# 9.0 / .NET 5.0C# 9.0 / .NET 5.0
C# 9.0 / .NET 5.0
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011ユニットテストの保守性を作りこむ, xpjugkansai2011
ユニットテストの保守性を作りこむ, xpjugkansai2011
 
リッチなドメインモデル 名前探し
リッチなドメインモデル 名前探しリッチなドメインモデル 名前探し
リッチなドメインモデル 名前探し
 
決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
 
ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門
 
WayOfNoTrouble.pptx
WayOfNoTrouble.pptxWayOfNoTrouble.pptx
WayOfNoTrouble.pptx
 
できる!並列・並行プログラミング
できる!並列・並行プログラミングできる!並列・並行プログラミング
できる!並列・並行プログラミング
 
会社でClojure使ってみて分かったこと
会社でClojure使ってみて分かったこと会社でClojure使ってみて分かったこと
会社でClojure使ってみて分かったこと
 
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
 
すごい配列楽しく学ぼう
すごい配列楽しく学ぼうすごい配列楽しく学ぼう
すごい配列楽しく学ぼう
 
人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with Karate人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with Karate
 
コルーチンでC++でも楽々ゲーム作成!
コルーチンでC++でも楽々ゲーム作成!コルーチンでC++でも楽々ゲーム作成!
コルーチンでC++でも楽々ゲーム作成!
 
オブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメオブジェクト指向エクササイズのススメ
オブジェクト指向エクササイズのススメ
 
40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること
 
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~
ドメイン駆動設計 ~ユーザー、モデル、エンジニアの新たな関係~
 
SPAセキュリティ入門~PHP Conference Japan 2021
SPAセキュリティ入門~PHP Conference Japan 2021SPAセキュリティ入門~PHP Conference Japan 2021
SPAセキュリティ入門~PHP Conference Japan 2021
 

Destaque

Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Jonas Bonér
 
Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsKonrad Malawski
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Evan Chan
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...Chris Fregly
 

Destaque (6)

Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka Streams
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
 

Semelhante a The Akka Zen: A Talk on Actor Model Best Practices

Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignLightbend
 
Rails and alternative ORMs
Rails and alternative ORMsRails and alternative ORMs
Rails and alternative ORMsJonathan Dahl
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsAjax Experience 2009
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersElena-Oana Tabaranu
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformanceAndrás Kovács
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionPaul Irish
 
Your 🧠 on Swift Concurrency
Your 🧠 on Swift ConcurrencyYour 🧠 on Swift Concurrency
Your 🧠 on Swift ConcurrencyDonny Wals
 
Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an IntroductionRoberto Casadei
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quoIvano Pagano
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-partsFuqiang Wang
 
CoffeeScript Design Patterns
CoffeeScript Design PatternsCoffeeScript Design Patterns
CoffeeScript Design PatternsTrevorBurnham
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Oky Firmansyah
 
Metaprogramming in JavaScript
Metaprogramming in JavaScriptMetaprogramming in JavaScript
Metaprogramming in JavaScriptMehdi Valikhani
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
Sql exception and class notfoundexception
Sql exception and class notfoundexceptionSql exception and class notfoundexception
Sql exception and class notfoundexceptionRohit Singh
 

Semelhante a The Akka Zen: A Talk on Actor Model Best Practices (20)

Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System Design
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Rails and alternative ORMs
Rails and alternative ORMsRails and alternative ORMs
Rails and alternative ORMs
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBusters
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for Performance
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
Your 🧠 on Swift Concurrency
Your 🧠 on Swift ConcurrencyYour 🧠 on Swift Concurrency
Your 🧠 on Swift Concurrency
 
Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an Introduction
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Goodparts
GoodpartsGoodparts
Goodparts
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
CoffeeScript Design Patterns
CoffeeScript Design PatternsCoffeeScript Design Patterns
CoffeeScript Design Patterns
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)
 
Metaprogramming in JavaScript
Metaprogramming in JavaScriptMetaprogramming in JavaScript
Metaprogramming in JavaScript
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
Sql exception and class notfoundexception
Sql exception and class notfoundexceptionSql exception and class notfoundexception
Sql exception and class notfoundexception
 

Mais de Konrad Malawski

Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Konrad Malawski
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Konrad Malawski
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tKonrad Malawski
 
State of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeState of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeKonrad Malawski
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCBuilding a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCKonrad Malawski
 
Akka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldAkka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldKonrad Malawski
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka StreamsKonrad Malawski
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsKonrad Malawski
 
Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Konrad Malawski
 
End to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketEnd to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketKonrad Malawski
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneKonrad Malawski
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Konrad Malawski
 
Krakow communities @ 2016
Krakow communities @ 2016Krakow communities @ 2016
Krakow communities @ 2016Konrad Malawski
 
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRKKonrad Malawski
 
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...Konrad Malawski
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemKonrad Malawski
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldKonrad Malawski
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsKonrad Malawski
 
Need for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applicationsNeed for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applicationsKonrad Malawski
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Konrad Malawski
 

Mais de Konrad Malawski (20)

Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
 
State of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeState of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to come
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCBuilding a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
 
Akka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldAkka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming World
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka Streams
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabs
 
Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!
 
End to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketEnd to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to Socket
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOne
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016
 
Krakow communities @ 2016
Krakow communities @ 2016Krakow communities @ 2016
Krakow communities @ 2016
 
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
 
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM Ecosystem
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorld
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
 
Need for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applicationsNeed for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applications
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014
 

Último

Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 

Último (9)

Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 

The Akka Zen: A Talk on Actor Model Best Practices

  • 1. Konrad `@ktosopl` Malawski @ Tokyo, Scala Matsuri 2016 の zen
  • 2. Konrad `ktoso` Malawski (we’re renaming soon!) Akka Team, Reactive Streams TCK, Maintaining Akka Http
  • 3. Konrad `@ktosopl` Malawski akka.io typesafe.com geecon.org Java.pl / KrakowScala.pl sckrk.com / meetup.com/Paper-Cup @ London GDGKrakow.pl lambdakrk.pl (we’re renaming soon!)
  • 4.
  • 6. Why such talk? 1番: One actor is no Actor 2番: Structure your Actors 3番: Name your Actors 4番: ”Matrix of mutability (Pain)” 5番: Blocking needs careful management 6番: Never Await, for/flatMap instead! 7番: Avoid Java Serialization 7.5番: Trust no-one, benchmark everything! Agenda 8番: Let it Crash! 9番: Backoff Supervision 10番: Design using State Machines 11番: Cluster Convergence and Joining 12番: Cluster Partitions and “Down” 13番: Akka is a Toolkit. 14番: Happy Hakking, Community! Questions?
  • 7. “The Tao / Zen of Programming” Talk title loosely based on the “Tao of Programming” book by Goeffrey James (1987). 「プログラミングの Tao (道)」
  • 8. “The Tao / Zen of Programming” And the follow-up book “Zen of Programming”. 「プログラミングの Zen (禅)」の 2冊に影響を受けたトーク
  • 9. “The Tao / Zen of Programming” Available here: http://www.mit.edu/~xela/tao.html Series of nine “books”, stories about an apprentice programmer and his sensei. Thus spake the Master Programmer: “Without the wind, the grass does not move. Without software hardware is useless.” 師が弟子に語る形式の 9冊シリーズの一部 「風無くば草は揺れず。ソフト無くばハードは無用の長物。」
  • 11. The Akka landscape Akka Actor IO Cluster Cluster Tools (PubSub, Sharding, …) Persistence & Persistence Query Streams HTTP Typed
  • 12. 1番: One actor is no Actor 1つのアクターは、0個のアクター
  • 13. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 14. 1番: One actor is no Actor If you have only one actor then it can only… 1. Reply 2. Drop the message (“ignore” 3. Schedule another message to self So we’re not really making any use of its parallelism or concurrency capabilities. アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 15. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 16. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 17. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 18. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 19. 1番: One actor is no Actor アクターは他のアクターと協調するためにある アクターは一つの責務に特化するべき
  • 20. 1番: One actor is no Actor - Actors are meant to work together. - An Actor should do one thing and do it very well - then talk to other Actors to do other things for it.
 - Child Actors usually used for workers or “tasks” etc.
 - Avoid using `actorSelection`,
 introduce Actors to each other. アクターはエンティティーを表す それぞれが「一貫性の島」であるべき
  • 22. 2番: Structure your Actors Different types… but no structure!
  • 23. 2番: Structure your Actors Parent / child relationships also allow for Actor supervision.
  • 25. 3番: Name your Actors
  • 26. 3番: Name your Actors // default context.actorOf(childProps) // "$a", "$b", "$c" Default names are: BASE64(sequence_nr++) Here’s why: - cheap to generate - guarantees uniqueness - less chars than plain numbers
  • 27. 3番: Name your Actors // default: naming is BASE64(sequential numbers) context.actorOf(childProps) // "$a", "$b", "$c" // better: but not very informative... context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2" private var _fetchWorkers: Int = 0 private def nextFetchWorkerName: String = { _fetchWorkers += 1 s”fetch-worker-${_fetchWorkers}” } Sequential names are a bit better sometimes.
  • 28. 3番: Name your Actors // default: naming is BASE64(sequential numbers) context.actorOf(childProps) // "$a", "$b", "$c" // better: but not much informative... context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2" private var _fetchWorkers: Int = 0 private def nextFetchWorkerName: String = { _fetchWorkers += 1 s”fetch-worker-${_fetchWorkers}” } abstract class SeqActorName { def next(): String def copy(name: String): SeqActorName } object SeqActorName { def apply(prefix: String) = new SeqActorNameImpl(prefix, new AtomicLong(0)) } final class SeqActorNameImpl(val prefix: String, counter: AtomicLong) extends SeqActorName { def next(): String = prefix + '-' + counter.getAndIncrement() def copy(newPrefix: String): SeqActorName = new SeqActorNameImpl(newPrefix, counter) } If you use this pattern a lot, here’s a simple encapsulation of it:
  • 29. 3番: Name your Actors // default: naming is BASE64(sequential numbers) context.actorOf(childProps) // "$a", "$b", "$c" // better: but not much informative... context.actorOf(childProps, nextFetchWorkerName) // "fetch-worker-1", "fetch-worker-2" private var fetchWorkers: Int = 0 private def nextFetchWorkerName: String = { fetchWorkers += 1 s"fetch-worker-$fetchWorkers" } // BEST: proper names, based on useful information context.actorOf(childProps, fetcherName(videoUrl)) // "fetch-yt-MRCWy2E_Ts", ... def fetcherName(link: Link) = link match { case YoutubeLink(id, metadata) => s"fetch-yt-$id" case DailyMotionLink(id, metadata) => s"fetch-dm-$id" case VimeoLink(id, metadata) => s"fetch-vim-$id" } Meaningful names are the best! アクターが適切に命名すべき アクターの名前は一意で、内容と構造を表す
  • 30. 3番: Name your Actors Meaningful names are the best! import akka.actor.OneForOneStrategy import akka.actor.SupervisorStrategy._ import scala.concurrent.duration._ // ... extends Actor with ActorLogging { override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) { case ex: Exception ⇒ log.warning("Child {} failed with {}, attempting restart...", sender().path.name, ex.getMessage) Restart } The name of the failed child Actor!
  • 31. 3番: Name your Actors Meaningful names are the best! import akka.actor.OneForOneStrategy import akka.actor.SupervisorStrategy._ import scala.concurrent.duration._ // ... extends Actor with ActorLogging { override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) { case ex: Exception ⇒ log.warning("Child {} failed with {}, attempting restart...", sender().path.name, ex.getMessage) Restart } The name of the failed child Actor! // BAD –– String ALWAYS built log.debug(s"Something heavy $generateId from $physicalAddress") // GOOD! –– String built only when DEBUG level is ON log.debug("Something heavy {} from {}", generateId, physicalAddress) Side note: always use {} log formatting (or macros), not s””
  • 32. 4番: ”Matrix of mutability (Pain)”
  • 33. 4番: ”Matrix of mutability (Pain)” See Jamie Allen’s talk on the subject. さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 34. 4番: ”Matrix of mutability (Pain)” See Jamie Allen’s talk on the subject. さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 35. 4番: ”Matrix of mutability (Pain)” See Jamie Allen’s talk on the subject. さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 36. 4番: ”Matrix of mutability (Pain)” See Jamie Allen’s talk on the subject. さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 37. 4番: ”Matrix of mutability (Pain)” See Jamie Allen’s talk on the subject. さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 38. 4番: ”Matrix of mutability (Pain)” さまざまな可変性 ミュータブル+値よりも、イミュータブル+変数
  • 39. 5番: Blocking needs careful management 正しくは「ブロッキングは注意深く管理すべき」 バルクヘッド(防水隔壁)パターンが有効
  • 40. 5番: Blocking needs careful management Blocking operations are really bad. Actors are all about resource sharing, and if someone is “behaving badly” it hurts everyone. Here is an example how blocking can grind an app to a halt. Next we’ll see how to avoid that… even if we have to live with the blocking code. ブロック操作を使ってはいけない アクター同士が共有するリソースを独り占めすると皆が困る
  • 41. 5番: Blocking needs careful management In simple terms: Blocking is bad because instead of doing something else, we just wait and do nothing (wasting CPU time)… ブロック操作を使ってはいけない アクター同士が共有するリソースを独り占めすると皆が困る
  • 42. 5番: Blocking needs careful management Future でブロックしている悪い例 デフォルトのディスパッチャーが枯渇する
  • 43. 5番: Blocking needs careful management Having that said, it’s not a bad question. Let’s investigate. Future でブロックしている悪い例 デフォルトのディスパッチャーが枯渇する
  • 44. 5番: Blocking needs careful management // BAD! (due to the blocking in Future): implicit val defaultDispatcher = system.dispatcher val routes: Route = post { complete { Future { // uses defaultDispatcher Thread.sleep(5000) // will block on the default dispatcher, System.currentTimeMillis().toString // starving the routing infra } } } Future でブロックしている悪い例 デフォルトのディスパッチャーが枯渇する
  • 45. 5番: Blocking needs careful management // BAD! (due to the blocking in Future): implicit val defaultDispatcher = system.dispatcher val routes: Route = post { complete { Future { // uses defaultDispatcher Thread.sleep(5000) // will block on the default dispatcher, System.currentTimeMillis().toString // starving the routing infra } } } Future でブロックしている悪い例 デフォルトのディスパッチャーが枯渇する
  • 46. 5番: Blocking needs careful management // application.conf my-blocking-dispatcher { type = Dispatcher executor = “thread-pool-executor" thread-pool-executor { // in Akka previous to 2.4.2: core-pool-size-min = 16 core-pool-size-max = 16 max-pool-size-min = 16 max-pool-size-max = 16 // or in Akka 2.4.2+ fixed-pool-size = 16 } throughput = 100 }
  • 47. 5番: Blocking needs careful management // GOOD (due to the blocking on a dedicated dispatcher): implicit val blockingDispatcher = system.dispatchers.lookup("my-blocking-dispatcher") val routes: Route = post { complete { Future { // uses the good "blocking dispatcher" that we configured, // instead of the default dispatcher – the blocking is isolated. Thread.sleep(5000) System.currentTimeMillis().toString } } } Future でブロックしている良い例 別のディスパッチャーに隔離
  • 48. 5番: Blocking needs careful management The “Never block!” mantra sounds cool, but actually what we mean by it is “blocking needs careful management”. We use the “bulkhead” pattern separate out potentially blocking behaviours to their independent dispatchers (and should always do so). http://stackoverflow.com/questions/34641861/akka-http-blocking-in-a-future-blocks-the-server/34645097#34645097
  • 49. 6番: Never Await, for/flatMap instead!
  • 50. 6番: Never Await, for/flatMap instead! // ... extends Actor { import context.dispatcher import scala.concurrent.duration._ import scala.concurrent.Await // bad sign! // BAD!!! val fThings: Future[Things] = computeThings() val t: Things = Await.result(fThings, atMost = 3.seconds) val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds) Await してはいけない 代わりに map 関数を使う
  • 51. 6番: Never Await, for/flatMap instead! // ... extends Actor { import context.dispatcher import scala.concurrent.duration._ import scala.concurrent.Await // bad sign! // BAD!!! val fThings: Future[Things] = computeThings() val t: Things = Await.result(fThings, atMost = 3.seconds) val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds) // Good: val fThingsWithDetails = for { t <- computeThings() d <- moreDetailsFor(t) } yield t -> d fThingsWithDetails foreach { case (things, details) => // case (things: Things, details: Details) => println(s"$things with $details") } Await してはいけない 代わりに map 関数を使う
  • 52. 6番: Never Await, for/flatMap instead! // ... extends Actor { import context.dispatcher import scala.concurrent.duration._ import scala.concurrent.Await // bad sign! // BAD!!! val fThings: Future[Things] = computeThings() val t: Things = Await.result(fThings, atMost = 3.seconds) val d: Details = Await.result(moreDetailsFor(t), atMost = 3.seconds) // Good: val fThingsWithDetails = for { t <- computeThings() d <- moreDetailsFor(t) } yield t -> d fThingsWithDetails foreach { case (things, details) => // case (things: Things, details: Details) => println(s"$things with $details") } // adding timeout: val timeoutFuture = akka.pattern.after(3.seconds, context.system.scheduler) { Future.failed(new TimeoutException("My timeout details...")) } Future.firstCompletedOf(fThingsWithDetails :: timeoutFuture :: Nil) foreach { case (things, details) => // case (things: Things, details: Details) => println(s"$things with $details") } Await してはいけない 代わりに map 関数を使う
  • 53. 7番: Avoid Java Serialization
  • 54. 7番: Avoid Java Serialization Java Serialization is the default one in Akka, since it’s easy to get started with it – no configuration needed. If you need performance and are running on multiple nodes, you must change the serialization. Popular formats are ProtoBuf or Kryo. Kryo is easier, but harder to evolve schema with. ProtoBuf is harder to maintain but great schema evolution. Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 55. 7番: Avoid Java Serialization Benchmarking serialization impact on “ping pong” case. (Two actors sending a message between them.) in-process messaging, super fast.
 no serialization overhead. Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 56. 7番: Avoid Java Serialization more work => increased latency => decreased throughput. over-the-network messaging, slower due to network and serialization. Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 57. 7番: Avoid Java Serialization Java Serialization is known to be: very slow & footprint heavy Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 58. 7番: Avoid Java Serialization It is on by default in Akka… Why? a) zero setup => simple to “play around” b) historical reasons - hard to remove the default Since 2.4 a warning is logged:
 WARNING: Using the default Java serializer for class [{}] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage' Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 59. 7番: Avoid Java Serialization sbt> jmh:run 
 -f 1 -tu us 
 -wi 20 -i 10 -jvm /home/ktoso/opt/jdk1.8.0_65/bin/java -jvmArgsAppend -XX:+PreserveFramePointer -bm avgt .*pingPong.* [info] # JMH 1.10.3 (released 184 days ago, please consider updating!) [info] # VM version: JDK 1.8.0_65, VM 25.65-b01 [info] # VM invoker: /home/ktoso/opt/jdk1.8.0_65/bin/java [info] # VM options: -XX:+PreserveFramePointer [info] # Warmup: 20 iterations, 5 s each [info] # Measurement: 10 iterations, 1 s each [info] # Timeout: 10 min per iteration [info] # Threads: 1 thread, will synchronize iterations [info] # Benchmark mode: Average time, time/op [info] # Benchmark: akka.actor.ForkJoinActorBenchmark.pingPong [info] # Parameters: (serializer = java) github.com/ktoso/sbt-jmh openjdk.java.net/projects/code-tools/jmh/ Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 60. 7番: Avoid Java Serialization [info] # Warmup Iteration 1: 35.717 us/op . . . [info] # Warmup Iteration 19: 25.164 us/op [info] # Warmup Iteration 20: 23.862 us/op [info] Iteration 1: 25.790 us/op . . . [info] Iteration 10: 26.168 us/op 
 [info] Result "pingPong": [info] 25.464 ±(99.9%) 1.175 us/op [Average] [info] (min, avg, max) = (24.383, 25.464, 26.888), stdev = 0.777 [info] CI (99.9%): [24.289, 26.639] (assumes normal distribution) [info] ForkJoinActorBenchmark.pingPong java avgt 10 25.464 ± 1.175 us/op [info] ForkJoinActorBenchmark.pingPong off avgt 10 0.967 ± 0.657 us/op github.com/ktoso/sbt-jmh openjdk.java.net/projects/code-tools/jmh/ Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 61. 7番: Avoid Java Serialization Good serializers include (but are not limited to): Kryo, Google Protocol Buffers, SBE,Thrift, JSON even (sic!) // dependencies "com.github.romix.akka" %% "akka-kryo-serialization" % "0.4.0" // application.conf extensions = [“com.romix.akka.serialization.kryo.KryoSerializationExtension$"] 
 serializers { 
 java = "akka.serialization.JavaSerializer" kryo = "com.romix.akka.serialization.kryo.KryoSerializer" 
 } akka.actor.serialization-bindings { “com.mycompany.Example”: kryo . . . } [info] ForkJoinActorBenchmark.pingPong java avgt 10 25.464 ± 1.175 us/op [info] ForkJoinActorBenchmark.pingPong kryo avgt 10 4.348 ± 4.346 us/op [info] ForkJoinActorBenchmark.pingPong off avgt 10 0.967 ± 0.657 us/op Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 62. 7番: Avoid Java Serialization ----sr--model.Order----h#-----J--idL--customert--Lmodel/Customer;L--descriptiont--Ljava/lang/String;L-- orderLinest--Ljava/util/List;L--totalCostt--Ljava/math/BigDecimal;xp--------ppsr--java.util.ArrayListx----- a----I--sizexp----w-----sr--model.OrderLine--&-1-S----I--lineNumberL--costq-~--L--descriptionq-~--L--ordert-- Lmodel/Order;xp----sr--java.math.BigDecimalT--W--(O---I--scaleL--intValt--Ljava/math/BigInteger;xr-- java.lang.Number-----------xp----sr--java.math.BigInteger-----;-----I--bitCountI--bitLengthI-- firstNonzeroByteNumI--lowestSetBitI--signum[--magnitudet--[Bxq-~----------------------ur--[B------T----xp---- xxpq-~--xq-~-- Java Serialization final case class Order(id: Long, description: String, totalCost: BigDecimal, orderLines: ArrayList[OrderLines], customer: Customer) <order id="0" totalCost="0"><orderLines lineNumber="1" cost="0"><order>0</order></orderLines></order>XML…! {"order":{"id":0,"totalCost":0,"orderLines":[{"lineNumber":1,"cost":0,"order":0}]}}JSON…! ------java-util-ArrayLis-----model-OrderLin----java-math-BigDecima---------model-Orde-----Kryo…! Excellent post by James Sutherland @ http://java-persistence-performance.blogspot.com/2013/08/optimizing-java-serialization-java-vs.html Java Serialization は遅い 性能を出したければ、ProtoBuf か Kryo
  • 63. 7番: Avoid Java Serialization for Persistence!!! Java Serialization is a horrible idea if you’re going to store the messages for a long time. For example, with Akka Persistence we store events “forever”. Use a serialization format that can evolve over time in a compatible way. It can be JSON or ProtocolBuffers (or Thrift etc). Java Serialization を永続化に使わない スキーマの変更しやすいフォーマットを選ぶべき
  • 64. 7.5番: Trust no-one, benchmark everything! Always measure and benchmark properly before judging performance of a tool / library. Benchmarking is often very hard, use the right tools: - JMH (for Scala via: ktoso/sbt-jmh) -YourKit / JProfiler / … - Linux perf_events 7.5番 推測するな、計測せよ ベンチマークを書いてプロファイラでスレッドの挙動を診断
  • 65. 8番: Let it Crash! Supervision, Failures & Errors
  • 66. http://www.reactivemanifesto.org/ 8番: Let it Crash! Supervision, Failures & Errors Error … which is an expected and coded-for condition—for example an error discovered during input validation, that will be communicated to the client … Failure … is an unexpected event within a service that prevents it from continuing to function normally. 
 A failure will generally prevent responses to the current, and possibly all following, client requests.
  • 67. http://www.reactivemanifesto.org/ 8番: Let it Crash! Supervision, Failures & 「エラー」はビジネスロジックの問題 「障害」はインフラの問題 「エラー」はビジネスロジックの問題 「障害」はインフラの問題
  • 68. http://www.reactivemanifesto.org/ 8番: Let it Crash! Supervision, Failures & Errors 「エラー」はビジネスロジックの問題 「障害」はインフラの問題
  • 69. http://www.reactivemanifesto.org/ 8番: Let it Crash! Supervision, Failures & Errors Error: “Not enough cash.” 「エラー」はビジネスロジックの問題 「障害」はインフラの問題
  • 70. http://www.reactivemanifesto.org/ 8番: Let it Crash! Supervision, Failures & Errors Error: “Unable to fulfil request” Failure: “Row 3 is broken” 「エラー」はビジネスロジックの問題 「障害」はインフラの問題
  • 75. 9番: Backoff Supervision Our goal is to “let things crash” and “recover gracefully” Not to hammer the DB while it tries to recover! クラッシュさせた上で、しなやかな回復を目指す
  • 76. 9番: Backoff Supervision クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 77. 9番: Backoff Supervision クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 78. 9番: Backoff Supervision IF we allowed immediate restarts… we could end up in “infinite replay+fail hell”. (we don’t. since Persistence went stable in 2.4.x) クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 79. 9番: Backoff Supervision クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 80. 9番: Backoff Supervision Many PersistentActors Fail and Stop. クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 81. 9番: Backoff Supervision クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 82. 9番: Backoff Supervision Backoff Supervisor counts failures and starts “the same” entity after exponential timeouts. クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 83. 9番: Backoff Supervision クラスタでは BackoffSupervisor 全アクターが同時に再起動し DB に殺到するのを防ぐ
  • 84. 10番: Design using State Machines
  • 85. 10番: Design using State Machines def receive = { case Thingy() => // ... case AnotherThingy() => // ... case DoOtherThings() => // ... case PleaseGoAway() => // ... case CarryOn() => // ... case MakeSomething() => // ... // ... } 有限状態機械を作る FSM トレイトか become メソッドを使う
  • 86. 10番: Design using State Machines def receive = { case Thingy() => // ... case AnotherThingy() => // ... case DoOtherThings() => // ... case PleaseGoAway() => // ... case CarryOn() => // ... case MakeSomething() => // ... // ... } Good: Actors avoid the “pyramid of doom”. Pyramid of doom in some async programming styles. 有限状態機械を作る FSM トレイトか become メソッドを使う
  • 87. 10番: Design using State Machines def receive = { case Thingy() => // ... case AnotherThingy() => // ... case DoOtherThings() => // ... case PleaseGoAway() => // ... case CarryOn() => // ... case MakeSomething() => // ... // ... } That well works because “everything is a message”: 有限状態機械を作る FSM トレイトか become メソッドを使う
  • 88. 10番: Design using State Machines def receive = awaitingInstructions def awaitingInstructions: Receive = terminationHandling orElse { case CarryOn() => // ... case MakeSomething(metadata) => // ... context become makeThings(meta) } def makeThings(metadata: Metadata): Receive = terminationHandling orElse { case Thingy() => // make a thingy ... case AnotherThingy() => // make another thingy ... case DoOtherThings(meta) => // ... context become awaitingInstructions } def terminationHandling: Receive = { case PleaseGoAway() => // ... context stop self } 有限状態機械を作る FSM トレイトか become メソッドを使う DoOtherThings MakeSomething
  • 89. 10番: Design using State Machines We also provide an FSM (Finite State Machine) helper trait. You may enjoy it sometimes, give it a look. DoOtherThings MakeSomething http://doc.akka.io/docs/akka/2.4.1/scala/fsm.html class Buncher extends FSM[State, Data] { startWith(Idle, Uninitialized) when(Idle) { case Event(SetTarget(ref), Uninitialized) => stay using Todo(ref, Vector.empty) } // transition elided ... when(Active, stateTimeout = 1 second) { case Event(Flush | StateTimeout, t: Todo) => goto(Idle) using t.copy(queue = Vector.empty) } // unhandled elided ... initialize() } 有限状態機械を作る FSM トレイトか become メソッドを使う
  • 91. 11番: Cluster Convergence and Joining http://doc.akka.io/docs/akka/2.4.1/common/cluster.html Cluster Gossip Convergence When a node can prove that the cluster state it is observing has been observed by all other nodes in the cluster.
  • 92. 11番: Cluster Convergence and Joining http://doc.akka.io/docs/akka/2.4.1/common/cluster.html Cluster Gossip Convergence When a node can prove that the cluster state it is observing has been observed by all other nodes in the cluster. Convergence is required for “Leader actions”, which include Join-ing and Remove-ing a node. Down-ing can happen without convergence.
  • 93. 11番: Cluster Convergence and Joining http://doc.akka.io/docs/akka/2.4.1/common/cluster.html
  • 94. 11番: Cluster Convergence and Joining http://doc.akka.io/docs/akka/2.4.1/common/cluster.html akka.cluster.allow-weakly-up-members=on
  • 100. 11番: Cluster Convergence and Joining Everyone has ‘seen’ Kurt joining, move him to Up.
  • 101. 11番: Cluster Convergence and Joining Kurt is now with us in the Cluster.
  • 102. 11番: Cluster Convergence and Joining I can’t hear Kurt… He’s unreachable…
  • 103. 11番: Cluster Convergence and Joining Kurt does has not seen Rei… I can not mark him as Up! allow-weakly-up-members=off // default
  • 104. 11番: Cluster Convergence and Joining I’ll mark Rei as “WeaklyUp” until Kurt is back. allow-weakly-up-members=on allow-weakly-up-members
  • 105. 11番: Cluster Convergence and Joining Kurt is back! Once he has seen Rei I’ll mark Rei as Up. allow-weakly-up-members=on allow-weakly-up-members
  • 106. 12番: Cluster Partitions and “Down”
  • 107. 12番: Cluster Partitions and “Down”
  • 108. 12番: Cluster Partitions and “Down” I’m going home…
  • 109. 12番: Cluster Partitions and “Down” Make sure the others have heard you say goodbye before you leave. Vanishes immediately.
  • 110. 12番: Cluster Partitions and “Down” Make sure the others have heard you say goodbye before you leave. “Where’s Bill? I did not hear him say Goodbye!” “Failure Detector” used to determine UNREACHABLE.
  • 111. 12番: Cluster Partitions and “Down” Failure detection only triggers “UNREACHABLE”. Nodes can come back from that state.
  • 112. 12番: Cluster Partitions and “Down” Declaring DOWN is done by either timeouts (which is rather unsafe) [auto-downing]. Or by “voting” or “majority” among the members of the cluster [split-brain-resolver].
  • 113. 12番: Cluster Partitions and “Down”
  • 114. 12番: Cluster Partitions and “Down” お 前 は も う 死 ん で い る . . . . Node declared “DOWN” comes back…
  • 115. 12番: Cluster Partitions and “Down” お 前 は も う 死 ん で い る . . . .
  • 116. 12番: Cluster Partitions and “Down” お 前 は も う 死 ん で い る . . . . Why do we do that? In order to guarantee consistency via “single writer principle”. Note: Akka Distributed Data has no need for “single writer”, it’s CRDT based. But it’s harder to model things as CRDT, so it’s a trade off.
  • 117. 12番: Cluster Partitions and “Down” Notice that we do not mention “Quarantined”. That is a state in Akka Remoting, not Cluster. It’s a terminal state from which one can never recover. TL;DR; use Akka Cluster instead of Remoting. it’s pretty much always the thing you need (better than remoting).
  • 118. 13番: A fishing rod is a Tool. Akka is a Toolkit.
  • 119. 13番: A fishing rod is a Tool. Akka is a Toolkit. Akka strives is Toolkit, not a Framework. “Give a man a fish and you feed him for a day teach a man to fish and you feed him for a lifetime.”
  • 120. 13番: Akka is a Toolkit, pick the right tools for the job. “Constraints Liberate, Liberties Constrain” Runar Bjarnason Runar’s excellent talk @ Scala.World 2015
  • 121. 13番: Akka is a Toolkit, pick the right tools for the job. Runar’s excellent talk @ Scala.World 2015 The less powerful abstraction must be built on top of more powerful abstractions.
  • 122. 13番: Akka is a Toolkit, pick the right tools for the job. Runar’s excellent talk @ Scala.World 2015 Asynchronous processing toolbox: Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 123. 13番: Akka is a Toolkit, pick the right tools for the job. Runar’s excellent talk @ Scala.World 2015 Asynchronous processing toolbox: Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 124. 13番: Akka is a Toolkit, pick the right tools for the job. Asynchronous processing toolbox: Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 125. 13番: Akka is a Toolkit, pick the right tools for the job. Single value, no streaming by definition. Local abstraction.
 Execution contexts. Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 126. 13番: Akka is a Toolkit, pick the right tools for the job. Mostly static processing layouts. Well typed and Back-pressured! Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 127. 13番: Akka is a Toolkit, pick the right tools for the job. Plain Actor’s younger brother, experimental. Location transparent, well typed. Technically unconstrained in actions performed Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 128. 13番: Akka is a Toolkit, pick the right tools for the job. Runar’s excellent talk @ Scala.World 2015 Location transparent. Various resilience mechanisms. (watching, persistent recovering, migration, pools) Untyped and unconstrained in actions performed. Akka は道具箱。正しい道具を選ぶべし。 レゴを組み合わせるようにしてアプリを作れる
  • 129. 13番: Akka is a Toolkit, pick the right tools for the job. Akka it a Toolkit. Not a Framework. Another example is persisting data. Akka Persistence is specifically geared towards Event Sourcing. If you know you you want a raw Key-Value Store and do not need Event Sourcing’s capabilities, don’t use Akka Persistence – it would be the wrong tool for the job. If you use it for Event Sourcing though… it’ll work very well for you. There it is the right tool for the job. 用途に合わない道具は使うべきではない 例えば CQRS が適切でない時は生 DB アクセスを使えば済む
  • 130. 14番: Happy hAkking, Community! 人にはやさしく コミュニティーに積極的に参加する
  • 131. 14番: Happy hAkking, Community! akka.io – website github.com/akka/akka/issues – help out! “community-contrib” or “small” for starters groups.google.com/group/akka-user – mailing list gitter.im/akka/akka – chat about using Akka gitter.im/akka/dev – chat about developing Akka
  • 132. Links • http://stackoverflow.com/questions/34641861/akka-http-blocking- in-a-future-blocks-the-server/34645097#34645097 • The wonderful Zen paintings to buy here:
 http://paintingwholesalechina.com/products/chinese-culture-zen- no-1-academic-chinese-painting • http://doc.akka.io/docs/akka/2.4.1/common/cluster.html • http://www.mit.edu/~xela/tao.html • http://doc.akka.io/docs/akka/2.4.1/common/cluster.html • http://doc.akka.io/docs/akka/2.4.1/scala/cluster-usage.html • akka.io et al.
  • 133. https://www.typesafe.com/products/typesafe-reactive-platform Certified builds & Long Term Support Advanced commercial features: Monitoring, Split Brain Resolver, ConductR, Play User Quotas, Play SOAP Reactive Platform
  • 134. ありがとう! ktoso @ typesafe.com twitter: ktosopl github: ktoso team blog: letitcrash.com home: akka.io Thus spake the Master Programmer: “After three days without programming, life becomes meaningless.”
  • 135. Q/A (Now’s the time to ask things!) ktoso @ typesafe.com twitter: ktosopl github: ktoso team blog: letitcrash.com home: akka.io
  • 136. ©Typesafe 2016 – All Rights Reserved

Notas do Editor

  1. The company soon to be previously known as Typesafe
  2. You need a fishing rod, sure. But to cook the fish you’ll want to use a knife and something to cook it in as well. So you’ll need different tools.