SlideShare una empresa de Scribd logo
1 de 62
Descargar para leer sin conexión
Reactive Software Systems 
Behrad Zari 
b.zari@adpdigital.com 
Fall 2014
Today Software 
● Cluster of multi-core machines 
● Fast networks 
● Lots of concurrent users 
● Large data sets 
● Latency in milliseconds
Our Needs 
● Cope to Enterprise Software Complexity 
● Scalability / Performance
Reactive Manifesto 
Responsive 
Resilient 
Message Driven 
Elastic 
http://www.reactivemanifesto.org/
Code Complexity
Complexity 
● Programming paradigms 
– Imperative → OOP, Statements, … 
– Functional → HOF, Immutability, Expressions,...
Programming Paradigms 
● Imperative: how to solve 
– procedural, object-oriented, statements 
● Declarative: what to solve 
– functional, immutability, expressions
Imperative 
● Sequence of statements 
● Contents of memory as state 
● Statements update variables (mutation) 
● Assignment, control structures
Example
OOP 
● Encapsulation 
● Inheritance 
– Reuse → Composition 
– Extension 
● Polymorphism 
– Ad-hoc 
– Parametric 
– Dynamic
Functional 
● Based on Lambda calculus 
● Functions form programs 
● Same input → same output 
● Avoids mutation 
● Higher order functions
Example
Side Effects 
● Global Variables
Side Effects 
● Function State, Object State
Side Effects Matter 
● Harder to reason about program 
● Harder to test 
● Harder to extend, parallelize, … 
How to avoid them?
Statements vs Expressions 
→
Functions as 1st-class Members 
Functions as values
Lambda Expressions 
● block of code with parameters executed later
Clojures
Immutability
Statelessness 
● should perform every task as if for the first time 
– ignorant of the past
Thinking in Functions 
● All of your functions must accept at least one 
argument 
● All of your functions must return data or another 
function 
● No loops!
Multi paradigm Implementations 
● Imperative with functional features 
– Java, C#, Python, Ruby 
● Functional with OO features 
– Scala 
– Ocaml, f# 
What makes difference? 
– Higher order functions 
– Immutable data structures 
– Recommended functional style idioms
Scala :D
wwwwwwwww...tttoooppptttaaalll...cccooommm 
www.toptal.com
Why Scala 
● Nice functional support 
– Basically functional + immutable data structures + ... 
● Type inference system 
– Less program code, more type checks 
● Designed for scalability 
● Stick with JVM echo system
Scala Features 
● Lambda expressions, closures and currying 
naturally 
● Pattern matching 
● Multiple inheritance through Traits 
● Comprehensive collections library
Collections
Immutability 
● Variables 
– val VS var 
● Collections 
● Value objects (case classes)
Case classes
Pattern Matching
Functional Programing Issues 
● Input/output difficult to deal with 
– Monadic operations 
● Requires garbage collection 
● Sometimes slower (but usually not by much) 
● Stateful operations are cumbersome
Learn more 
● http://www.scala-lang.org/old/node/8610
Concurrency Models
Thread based Model 
● Shared mutable state 
● Threads concurrently execute code sections 
– Synchronization 
– Locking mechanism 
– Not scalable 
– Edward A. Lee, The Problem with Threads
Always Blocking 
● Latency 
– CPU → 1ns (=> 1 second) 
– RAM → 250,000ns (=> 3 days) 
– TCP →150,000,000ns (=> 5 years)
Non blocking Code
Future
Future
Futures in Scala
Event Loop Model 
● Implemented in Node.js
Message Passing Model 
● 1973, paper by Carl Hewitt 
● Avoid the problems caused by threading and 
locking 
● Implemented in Erlang, Scala
Actor Model 
● Actors instead of objects 
● No shared state between actors 
● Asynchronous message-passing 
– Immutable messages 
● Mailboxes
Actor Benefits 
● Higher abstraction level 
– Easier to reason about 
● Easier to avoid 
– Race conditions 
– Deadlocks 
– Starvation 
– Live locks 
● Distributed computing
Example in Erlang
Erlang Actors in Real 
● Ericson AXD 301 switch 
– millions of calls per ,99.9999999 percent uptime 
● Facebook chat application 
– 70 million concurrent users 
● RabbitMQ 
– high-performance AMQP, 400,000 messages per second. 
● Apache CouchDB 
– distributed, fault-tolerant document-oriented database 
● Ejabberd XMPP server – jabber.org
JVM implementations 
● Java 
– Kilim, Jetlang, ActorFoundry, Actors Guild 
● Scala (FP + actor model) 
– Akka 
● Groovy 
– GParallelizer
Akka :x
Akka 
● Concurrency 
– mailboxes 
– dispatchers 
● Scalability 
– Remote actors, clustering 
● Fault tolerance 
– Actor supervision
Akka Actors 
● Define messages 
● Create new actors 
● Send messages to others 
– Fire & forget 
– Send & receive eventually 
– Send & receive with future 
● Become 
● Supervise
Akka Actor in Java
Akka actor in Scala
Talk to Actors
Actor Hierarchies 
● Name resolution: file system like
Supervision & Resilience 
● OneForOneStrategy VS AllForOneStrategy 
● Monitor through Death Watch 
● Every single actor has a default supervisor 
strategy. Which is usually sufficient. But it can 
be overridden
Scalability & Elasticity 
● Scale Up VS Scale Out 
– Essentially are same thing 
● Minimize Contention 
● Maximize Locality of Reference 
– Share Nothing Design
Akka Routers 
● RoundRobinRoutingLogic 
● RandomRoutingLogic 
● SmallestMailboxRoutingLogic 
● BroadcastRoutingLogic 
● ScatterGatherFirstCompleted 
● TailChoppingRoutingLogic 
● ConsistentHashingRoutingLogic
Akka Clustering
Simple Bulk Aggregator
Better Bulk Aggregator
Akka Adoption
.End() 
bacheHa thank { qList => 
qList forEach (_.answer) 
}

Más contenido relacionado

La actualidad más candente

Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Igalia
 

La actualidad más candente (20)

Making Scala Faster: 3 Expert Tips For Busy Development Teams
Making Scala Faster: 3 Expert Tips For Busy Development TeamsMaking Scala Faster: 3 Expert Tips For Busy Development Teams
Making Scala Faster: 3 Expert Tips For Busy Development Teams
 
Slick eventsourcing
Slick eventsourcingSlick eventsourcing
Slick eventsourcing
 
Building stateful systems with akka cluster sharding
Building stateful systems with akka cluster shardingBuilding stateful systems with akka cluster sharding
Building stateful systems with akka cluster sharding
 
NoSQL, no SQL injections?
NoSQL, no SQL injections?NoSQL, no SQL injections?
NoSQL, no SQL injections?
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster
 
10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison
 
What's New In Rails 4.2
What's New In Rails 4.2What's New In Rails 4.2
What's New In Rails 4.2
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
The Future of Real-Time in Spark
The Future of Real-Time in SparkThe Future of Real-Time in Spark
The Future of Real-Time in Spark
 
S3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using sparkS3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using spark
 
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
 
Sneaking Scala through the Back Door
Sneaking Scala through the Back DoorSneaking Scala through the Back Door
Sneaking Scala through the Back Door
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
Stream Collections - Scala Days
Stream Collections - Scala DaysStream Collections - Scala Days
Stream Collections - Scala Days
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Ractor's speed is not light-speed
Ractor's speed is not light-speedRactor's speed is not light-speed
Ractor's speed is not light-speed
 
Exploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeExploiting NoSQL Like Never Before
Exploiting NoSQL Like Never Before
 
Java programming and security
Java programming and securityJava programming and security
Java programming and security
 

Destacado

Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
GR8Conf
 

Destacado (13)

The Reactive Manifesto: Message-driven, Resilient, Elastic, Responsive - Stef...
The Reactive Manifesto: Message-driven, Resilient, Elastic, Responsive - Stef...The Reactive Manifesto: Message-driven, Resilient, Elastic, Responsive - Stef...
The Reactive Manifesto: Message-driven, Resilient, Elastic, Responsive - Stef...
 
Reactive Systems And Vertx
Reactive Systems And VertxReactive Systems And Vertx
Reactive Systems And Vertx
 
Map Reduce in Hazelcast - Hazelcast User Group London Version
Map Reduce in Hazelcast - Hazelcast User Group London VersionMap Reduce in Hazelcast - Hazelcast User Group London Version
Map Reduce in Hazelcast - Hazelcast User Group London Version
 
Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
 
Functional Reactive Programming in Javascript
Functional Reactive Programming in JavascriptFunctional Reactive Programming in Javascript
Functional Reactive Programming in Javascript
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
 
Reactive Web Applications
Reactive Web ApplicationsReactive Web Applications
Reactive Web Applications
 
Rxjs ppt
Rxjs pptRxjs ppt
Rxjs ppt
 
Reactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringReactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and Spring
 
Micro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factorsMicro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factors
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Benefits of developing a Single Page Web Applications using AngularJS
Benefits of developing a Single Page Web Applications using AngularJSBenefits of developing a Single Page Web Applications using AngularJS
Benefits of developing a Single Page Web Applications using AngularJS
 

Similar a Reactive Software Systems

Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Java
koji lin
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!
benfante
 

Similar a Reactive Software Systems (20)

Scala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadiusScala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadius
 
The Rise of Functional Programming
The Rise of Functional ProgrammingThe Rise of Functional Programming
The Rise of Functional Programming
 
Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Java
 
Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actors
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 
Elixir otp-basics
Elixir otp-basicsElixir otp-basics
Elixir otp-basics
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
 
Introdução à Elixir
Introdução à ElixirIntrodução à Elixir
Introdução à Elixir
 
Stairway to scala flyer
Stairway to scala flyerStairway to scala flyer
Stairway to scala flyer
 
JPoint'15 Mom, I so wish Hibernate for my NoSQL database...
JPoint'15 Mom, I so wish Hibernate for my NoSQL database...JPoint'15 Mom, I so wish Hibernate for my NoSQL database...
JPoint'15 Mom, I so wish Hibernate for my NoSQL database...
 
Stateful stream processing with kafka and samza
Stateful stream processing with kafka and samzaStateful stream processing with kafka and samza
Stateful stream processing with kafka and samza
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Reactive Software Systems