SlideShare a Scribd company logo
From Elixir to Akka
(and back)
Agustín Ramos

@MachinesAreUs
Why?
Actors?
The Actor Model
Hewitt, Meijer and Szyperski, 2012
Actor Model
Actor A Actor B
• Asynchronous messaging

• Concurrent execution

• No shared state (memory)
Message
Mailbox
Image from “Learn you some Erlang for a Great Good”
From Elixir to Akka (and back) - ElixirConf Mx 2017
hello_process = spawn fn ->
receive do
"hello" -> IO.puts "hello back at you"
_ -> IO.puts "huh?"
end
end
send hello_process, "hello"
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
class HelloActor extends Actor {
def receive = {
case "hello" => println("hello back at you")
case _ => println("huh?")
}
}
object Main extends App {
val system = ActorSystem("HelloSystem")
val helloActor = system.actorOf(Props[HelloActor],
name="helloactor")
helloActor ! "hello"
helloActor ! "buenos dias"
}
1
Classes, objects.. and actors1
2
Overrides and all the Java/Scala stuff2
3
Must explicitly create actor system3
4
Actor creation4
Language
Mailboxes
• Message passing is done by copying.

• There’s only one type of mailbox, and it’s part of the actor.

• No mailbox size limit.

• Only physical limitations.

• A process receives a message when it extracts it from the
mailbox.

• Order or reception is imposed by the receiving process.
• Message passing is done by reference.

• You can change the message once it has been sent!

• The mailbox is a different entity from the actor.

• There are several out-of-the-box implementations of a
mailbox.

• Order of reception is determined by the semantics of the
mailbox implementation.
• Builtin mailbox implementations

• UnboundedMailbox (default)

• SingleConsumerOnlyUnboundedMailbox 

• NonBlockingBoundedMailbox

• UnboundedControlAwareMailbox

• UnboundedPriorityMailbox

• UnboundedStablePriorityMailbox

• BoundedMailbox

• BoundedPriorityMailbox

• BoundedStablePriorityMailbox

• BoundedControlAwareMailbox
From Elixir to Akka (and back) - ElixirConf Mx 2017
Why?
Scheduling
• Erlang is a soft real time platform.

• This means:

• Preemptive scheduling.

• No process can block other processes.

• There are several schedulers (usually 1/processor).

• Criteria for scheduling/preempting a process:

• Priority

• Reductions
class PrintActor extends Actor {
def receive = {
case i: Int =>
println(s"PrintActor: ${i}")
}
}
Blocking
class BlockingFutureActor extends Actor {
implicit val executionContext: ExecutionContext = context.dispatcher
def receive = {
case i: Int =>
println(s"Calling blocking Future: ${i}")
Future {
Thread.sleep(5000) //block for 5 seconds
println(s"Blocking future finished ${i}")
}
}
}
val actor1 = system.actorOf(Props(new BlockingFutureActor))
val actor2 = system.actorOf(Props(new PrintActor))
for (i <- 1 to 100) {
actor1 ! i
actor2 ! i
}
Blocking
When you run this code, it get’s stuck around
PrintActor: 44
PrintActor: 45
• Every actor runs within ‘Dispatcher’ threads.

• If you block a dispatcher thread, you risk blocking the
whole system.
From Elixir to Akka (and back) - ElixirConf Mx 2017
Esas ambigüedades, redundancias y deficiencias recuerdan las que
el doctor Franz Kuhn atribuye a cierta enciclopedia china que se
titula Emporio celestial de conocimientos benévolos. En sus remotas
páginas está escrito que los animales se dividen en (a)
pertenecientes al Emperador, (b) embalsamados, (c) amaestrados,
(d) lechones, (e) sirenas, (f) fabulosos, (g) perros sueltos, (h)
incluidos en esta clasificación, (i) que se agitan como locos, (j)
innumerables, (k) dibujados con un pincel finísimo de pelo de
camello, (1) etcétera, (m) que acaban de romper el jarrón, (n) que de
lejos parecen moscas.
El idioma analítico de John Wilkins
Jorge Luis Borges, 1952
Why?
Tooling
Build Tool
Mix
• Bundled with Elixir

• Easy setup

• Fast

• Doesn’t get in your way
• Super slow

• It’s not only because of the Scala compiler.

• You can run it as a server.

• But, once you run an application runs, the only way to stop it is
to kill the whole JVM.

• Multi-projects: 

• I don’t recommend using it. 

• Slows the build way further.
Why?
Monitoring
From Elixir to Akka (and back) - ElixirConf Mx 2017
• Lightbend monitoring (paid service).

• Couldn’t get even a screenshot without engaging with
sales department.

• No money? Visual VM.

• Not enough for peeking into an actor system.
Versions
What’s my ultimate
thought about Akka?
It’s a trap!
A (very dark)
Software Trend…
From Elixir to Akka (and back) - ElixirConf Mx 2017
Common Practice (Almost) Non-Existent
Practice
Dependency Injection
Dependency Injection
“Ignoring the imbecilic name, I think that if you’re stuck with a
mainstream language, that may be a reasonable work around.
It requires a significant degree of preplanning, and makes your
application dependent on one more piece of machinery that
has NOTHING to do with the actual problem the application is
trying to solve. On the positive side, it helps guarantee
employment for software engineers. That said, it’s
important to understand that DIFs are just a work
around for a deficiency in the underlying language.”
Constructors Considered Harmful
Gilad Bracha
http://j.mp/ccharmful
• C: It’s too slow!

• A: Run it as a server!

• C: It’s still very slow

• Here you are some plugins to profile your build!
• Na concurrent, yo? Na’ problem!

• Na scale, yo? Na’ problem!

• Ya’ idiot, yo?…
The Mess We’re In
Joe Armstrong, 2014
Is it really "Complex"? Or did we just make it "Complicated"?
Alan Kay, 2013
Standard Akka Application Stack
JVM
Standard
Libraries
3rd Party
Java Libraries
Scala
Scala Standard
Libraries
Akka Core Akka Extensions
Your Application Code
Complex
Complex
Super
Complex
???
The trend is to try to alleviate technology
deficiencies by means of adding complexity.
… Instead of stepping back and fixing them
from first principles.
Let it go…
From Elixir to Akka (and back) - ElixirConf Mx 2017
Thank you!
Agustín Ramos

@MachinesAreUs

More Related Content

PPTX
Elixirと他言語の比較的紹介 ver.2
PDF
AWS で Presto を徹底的に使いこなすワザ
PPTX
S3 整合性モデルと Hadoop/Spark の話
PDF
KafkaとAWS Kinesisの比較
PDF
Deep Dive into Spark SQL with Advanced Performance Tuning
PDF
Amazon ECS/ECR을 활용하여 마이크로서비스 구성하기 - 김기완 (AWS 솔루션즈아키텍트)
PPTX
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
PDF
爆速クエリエンジン”Presto”を使いたくなる話
Elixirと他言語の比較的紹介 ver.2
AWS で Presto を徹底的に使いこなすワザ
S3 整合性モデルと Hadoop/Spark の話
KafkaとAWS Kinesisの比較
Deep Dive into Spark SQL with Advanced Performance Tuning
Amazon ECS/ECR을 활용하여 마이크로서비스 구성하기 - 김기완 (AWS 솔루션즈아키텍트)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
爆速クエリエンジン”Presto”を使いたくなる話

What's hot (20)

PDF
dbt Cloud intro 日本語 202206
PDF
DevOps with Database on AWS
PDF
Hadoop/Spark で Amazon S3 を徹底的に使いこなすワザ (Hadoop / Spark Conference Japan 2019)
PDF
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
PDF
20190514 AWS Black Belt Online Seminar Amazon API Gateway
PDF
AWS Lambda / Amazon API Gateway Deep Dive
PDF
3分でわかるAzureでのService Principal
PDF
Amazon SNS+SQSによる Fanoutシナリオの話
PDF
ここが良かったDatadog
PDF
Serverless時代のJavaについて
PDF
Dep005 azure ネットワーク設計
PDF
受託開発でテストファーストしたらXXXを早期発見できてハイアジリティになったはなし
PPTX
ContainerとName Space Isolation
PPTX
Kinesis Firehoseを使ってみた
PDF
カンタン画像サムネイル作成「Smalllight」
PPTX
Webアプリケーション負荷試験実践入門
PPTX
REST API 설계
PPTX
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
PPTX
データ収集の基本と「JapanTaxi」アプリにおける実践例
PPTX
Amazon Redshiftの開発者がこれだけは知っておきたい10のTIPS / 第18回 AWS User Group - Japan
dbt Cloud intro 日本語 202206
DevOps with Database on AWS
Hadoop/Spark で Amazon S3 を徹底的に使いこなすワザ (Hadoop / Spark Conference Japan 2019)
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
20190514 AWS Black Belt Online Seminar Amazon API Gateway
AWS Lambda / Amazon API Gateway Deep Dive
3分でわかるAzureでのService Principal
Amazon SNS+SQSによる Fanoutシナリオの話
ここが良かったDatadog
Serverless時代のJavaについて
Dep005 azure ネットワーク設計
受託開発でテストファーストしたらXXXを早期発見できてハイアジリティになったはなし
ContainerとName Space Isolation
Kinesis Firehoseを使ってみた
カンタン画像サムネイル作成「Smalllight」
Webアプリケーション負荷試験実践入門
REST API 설계
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
データ収集の基本と「JapanTaxi」アプリにおける実践例
Amazon Redshiftの開発者がこれだけは知っておきたい10のTIPS / 第18回 AWS User Group - Japan
Ad

Similar to From Elixir to Akka (and back) - ElixirConf Mx 2017 (20)

PPTX
Scale up your thinking
KEY
Akka london scala_user_group
PDF
Building Hermetic Systems (without Docker)
PDF
Writing Asynchronous Programs with Scala & Akka
PDF
What Going All-Remote Taught Us About Appsec and Testing Shortfalls
PDF
Backday Xebia : Akka, the reactive toolkit
PDF
Why scala is not my ideal language and what I can do with this
PDF
Tasks: you gotta know how to run them
PDF
The Proxy Fairy, and The Magic of Spring Framework
PDF
Continuous Delivery: The Dirty Details
PPT
Understanding Framework Architecture using Eclipse
PDF
Smart Client Development
PDF
Back to the futures, actors and pipes: using Akka for large-scale data migration
PDF
Akka Testkit Patterns
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
Operationalizing Clojure Confidently
PPTX
Arquitetura Orientada a Atores
ODP
EuRuKo JRuby Talk 2008
PDF
Bowtie: Interactive Dashboards
PDF
Actor Model Akka Framework
Scale up your thinking
Akka london scala_user_group
Building Hermetic Systems (without Docker)
Writing Asynchronous Programs with Scala & Akka
What Going All-Remote Taught Us About Appsec and Testing Shortfalls
Backday Xebia : Akka, the reactive toolkit
Why scala is not my ideal language and what I can do with this
Tasks: you gotta know how to run them
The Proxy Fairy, and The Magic of Spring Framework
Continuous Delivery: The Dirty Details
Understanding Framework Architecture using Eclipse
Smart Client Development
Back to the futures, actors and pipes: using Akka for large-scale data migration
Akka Testkit Patterns
Large-scaled Deploy Over 100 Servers in 3 Minutes
Operationalizing Clojure Confidently
Arquitetura Orientada a Atores
EuRuKo JRuby Talk 2008
Bowtie: Interactive Dashboards
Actor Model Akka Framework
Ad

More from Agustin Ramos (15)

PDF
Exploring Elixir Codebases with Archeometer
PDF
Pairwise and property based testing
PDF
Sistemas Tolerantes a Fallas
PDF
¿En qué la estamos regando en pruebas de software?
PDF
Programación funcional con haskell
PDF
Técnicas basadas en matriz de estructura de diseño
KEY
Acercándose a la entrega continua
KEY
Modelos de paralelismo y concurrencia
PPTX
Arquitecturas que crecen y arquitecturas que no
PDF
Arqueología de software
PPTX
Hola OSGi
PPTX
Desarrollo Dirigido por Comportamiento (con Cucumber y Groovy)
PPTX
BDD - Desarrollo dirigido por comportamiento
PPTX
La nueva imagen del gurú - El maestro artesano dentro del ingeniero
PPTX
Modularización efectiva - domando a la hidra
Exploring Elixir Codebases with Archeometer
Pairwise and property based testing
Sistemas Tolerantes a Fallas
¿En qué la estamos regando en pruebas de software?
Programación funcional con haskell
Técnicas basadas en matriz de estructura de diseño
Acercándose a la entrega continua
Modelos de paralelismo y concurrencia
Arquitecturas que crecen y arquitecturas que no
Arqueología de software
Hola OSGi
Desarrollo Dirigido por Comportamiento (con Cucumber y Groovy)
BDD - Desarrollo dirigido por comportamiento
La nueva imagen del gurú - El maestro artesano dentro del ingeniero
Modularización efectiva - domando a la hidra

Recently uploaded (20)

PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
KodekX | Application Modernization Development
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Chapter 2 Digital Image Fundamentals.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PDF
REPORT: Heating appliances market in Poland 2024
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Enable Enterprise-Ready Security on IBM i Systems.pdf
A Day in the Life of Location Data - Turning Where into How.pdf
Dell Pro 14 Plus: Be better prepared for what’s coming
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KodekX | Application Modernization Development
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Chapter 2 Digital Image Fundamentals.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Belt and Road Supply Chain Finance Blockchain Solution
madgavkar20181017ppt McKinsey Presentation.pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
REPORT: Heating appliances market in Poland 2024
Transforming Manufacturing operations through Intelligent Integrations
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

From Elixir to Akka (and back) - ElixirConf Mx 2017

  • 1. From Elixir to Akka (and back) Agustín Ramos @MachinesAreUs
  • 3. Actors? The Actor Model Hewitt, Meijer and Szyperski, 2012
  • 4. Actor Model Actor A Actor B • Asynchronous messaging • Concurrent execution • No shared state (memory) Message Mailbox
  • 5. Image from “Learn you some Erlang for a Great Good”
  • 7. hello_process = spawn fn -> receive do "hello" -> IO.puts "hello back at you" _ -> IO.puts "huh?" end end send hello_process, "hello"
  • 8. import akka.actor.Actor import akka.actor.ActorSystem import akka.actor.Props class HelloActor extends Actor { def receive = { case "hello" => println("hello back at you") case _ => println("huh?") } } object Main extends App { val system = ActorSystem("HelloSystem") val helloActor = system.actorOf(Props[HelloActor], name="helloactor") helloActor ! "hello" helloActor ! "buenos dias" } 1 Classes, objects.. and actors1 2 Overrides and all the Java/Scala stuff2 3 Must explicitly create actor system3 4 Actor creation4
  • 11. • Message passing is done by copying. • There’s only one type of mailbox, and it’s part of the actor. • No mailbox size limit. • Only physical limitations. • A process receives a message when it extracts it from the mailbox. • Order or reception is imposed by the receiving process.
  • 12. • Message passing is done by reference. • You can change the message once it has been sent! • The mailbox is a different entity from the actor. • There are several out-of-the-box implementations of a mailbox. • Order of reception is determined by the semantics of the mailbox implementation.
  • 13. • Builtin mailbox implementations • UnboundedMailbox (default) • SingleConsumerOnlyUnboundedMailbox • NonBlockingBoundedMailbox • UnboundedControlAwareMailbox • UnboundedPriorityMailbox • UnboundedStablePriorityMailbox • BoundedMailbox • BoundedPriorityMailbox • BoundedStablePriorityMailbox • BoundedControlAwareMailbox
  • 15. Why?
  • 17. • Erlang is a soft real time platform. • This means: • Preemptive scheduling. • No process can block other processes. • There are several schedulers (usually 1/processor). • Criteria for scheduling/preempting a process: • Priority • Reductions
  • 18. class PrintActor extends Actor { def receive = { case i: Int => println(s"PrintActor: ${i}") } } Blocking class BlockingFutureActor extends Actor { implicit val executionContext: ExecutionContext = context.dispatcher def receive = { case i: Int => println(s"Calling blocking Future: ${i}") Future { Thread.sleep(5000) //block for 5 seconds println(s"Blocking future finished ${i}") } } }
  • 19. val actor1 = system.actorOf(Props(new BlockingFutureActor)) val actor2 = system.actorOf(Props(new PrintActor)) for (i <- 1 to 100) { actor1 ! i actor2 ! i } Blocking When you run this code, it get’s stuck around PrintActor: 44 PrintActor: 45
  • 20. • Every actor runs within ‘Dispatcher’ threads. • If you block a dispatcher thread, you risk blocking the whole system.
  • 22. Esas ambigüedades, redundancias y deficiencias recuerdan las que el doctor Franz Kuhn atribuye a cierta enciclopedia china que se titula Emporio celestial de conocimientos benévolos. En sus remotas páginas está escrito que los animales se dividen en (a) pertenecientes al Emperador, (b) embalsamados, (c) amaestrados, (d) lechones, (e) sirenas, (f) fabulosos, (g) perros sueltos, (h) incluidos en esta clasificación, (i) que se agitan como locos, (j) innumerables, (k) dibujados con un pincel finísimo de pelo de camello, (1) etcétera, (m) que acaban de romper el jarrón, (n) que de lejos parecen moscas. El idioma analítico de John Wilkins Jorge Luis Borges, 1952
  • 23. Why?
  • 26. Mix • Bundled with Elixir • Easy setup • Fast • Doesn’t get in your way
  • 27. • Super slow • It’s not only because of the Scala compiler. • You can run it as a server. • But, once you run an application runs, the only way to stop it is to kill the whole JVM. • Multi-projects: • I don’t recommend using it. • Slows the build way further.
  • 28. Why?
  • 31. • Lightbend monitoring (paid service). • Couldn’t get even a screenshot without engaging with sales department. • No money? Visual VM. • Not enough for peeking into an actor system.
  • 37. Common Practice (Almost) Non-Existent Practice Dependency Injection
  • 38. Dependency Injection “Ignoring the imbecilic name, I think that if you’re stuck with a mainstream language, that may be a reasonable work around. It requires a significant degree of preplanning, and makes your application dependent on one more piece of machinery that has NOTHING to do with the actual problem the application is trying to solve. On the positive side, it helps guarantee employment for software engineers. That said, it’s important to understand that DIFs are just a work around for a deficiency in the underlying language.” Constructors Considered Harmful Gilad Bracha http://j.mp/ccharmful
  • 39. • C: It’s too slow! • A: Run it as a server! • C: It’s still very slow • Here you are some plugins to profile your build!
  • 40. • Na concurrent, yo? Na’ problem! • Na scale, yo? Na’ problem! • Ya’ idiot, yo?…
  • 41. The Mess We’re In Joe Armstrong, 2014
  • 42. Is it really "Complex"? Or did we just make it "Complicated"? Alan Kay, 2013
  • 43. Standard Akka Application Stack JVM Standard Libraries 3rd Party Java Libraries Scala Scala Standard Libraries Akka Core Akka Extensions Your Application Code Complex Complex Super Complex ???
  • 44. The trend is to try to alleviate technology deficiencies by means of adding complexity.
  • 45. … Instead of stepping back and fixing them from first principles.