Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | indicthreads |
View: | 217 times |
Download: | 0 times |
of 33
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
1/33
Typesafe Stack Software
Development On The JVM
Sushanta Pradhan
Talentica Software (I) Pvt. Ltd.
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
2/33
History of Hardware Architecture
Single core era moore's law achieved by increasing clock cycles
Multi core era moore's law achieved by increasing # of cores
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
3/33
Moores Law
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
4/33
PPP Grand Challenge
Parallel programming as easy as sequential
programming Mooress law of performance speed up 2 times yearon year
Eliminate concurrency bugs
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
5/33
History of software applications
pre .com era
standalone desktop apps .com era
web sites - static web pages, automated businessprocesses
data controlled by software vendor
deployed on data centers
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
6/33
contd ..
web2.0/semantic web era
web/networked applications
Smart apps
data not controlled by vendor but by the users
deployed on cloud
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
7/33
Properties of modern day App
Scalability
Distributed Parallel & Concurrent
Dynamic
Agile & Swift
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
8/33
Parallelism & Concurrency
Parallel Programming
parallel execution of programs
can't be performed without parallel hardware
programs get faster
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
9/33
Parallelism & Concurrency
Concurrent Programming
simultaneous execution of programs can be performed without parallel hardware
programs get more responsive
Both are too hard !!
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
10/33
Why Hard?
non-determinism due to shared mutable state byconcurrent threads
encapsulate state in actors or transactors but fundamental
problems still remains
non-determinism = parallel processing + mutable state
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
11/33
Remedy?
PREVENTION IS BETTER THAN CURE !!
Avoid mutable state and get deterministic processing
Which means program functionally
S
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
12/33
Space vs Time
Space(functional/parallel)
Time(imperative/concurrent)
S l
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
13/33
Scala
Hybrid functional & object oriented (pure)
strong static typing Agile - concise & expressive
Parallel & Sequential
intermixes well with Java
S l td
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
14/33
Scala contd ..
Parallellism
parallel collections
distributed collections
Concurrency
Actors STM Akka
Futures
S l td
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
15/33
Scala contd ..
Concise Java
Immutability Val & Var
Tuples & Multiple Assignments
Sensible Defaults
Operator Overloading
S l l
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
16/33
Scala classes ..
Terse
Object keyword - Singleton Companion Objects
Type inference
Option[T] Some[T], None
Cl hi h
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
17/33
Class hierarchy
Scala Functional Aspects
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
18/33
Scala Functional Aspects
Functions too are objects
Higher Order Functions Partially applied Functions
Closures
Scala Inehritance
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
19/33
Scala Inehritance
Traits
Mixins Type inference - implicit keyword
Scala collections
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
20/33
Scala collections
Mutable & immutable
filter() Map()
foldLeft()
foldRight()
Scala Pattern Matching
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
21/33
Scala Pattern Matching
Advanced switch case
Literals and constants WildCards
Tuples & Lists
Guards
Regular Expressions
Scala Concurrency
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
22/33
Scala - Concurrency
actor()
Actor Class
receive() & recieveWithin()
react() & reachWithin()
loop() & loopwhile()
Akka Middleware
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
23/33
Akka - Middleware
Concurrent, Scalable & fault-tolerant
based on actor model highly performant
event driven
location transparency
Actor system
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
24/33
Actor system
ensemble of actors sharing common configuration
hierarchical structure heavyweight
has its own pool of resources threads
Supervision
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
25/33
Supervision
dependency relationship between actors
supervisor - subordinate model
supervisor monitors and reacts to any errors reported
by subordinates
configurable supervision strategy
lifecycle monitoring
Supervision hierarchy
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
26/33
Supervision hierarchy
root guardian
guardianshutdown system
guardianorder
Remoting
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
27/33
Remoting
ActorPath
purely local - "akka://my-sys/user/service-a/worker1" local or remote - "akka://[email protected]:5678
/user/service-b"
Seamlessly send messages to actors on remote nodes
Routing
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
28/33
Routing
route messages to actors(routees)
ideal for load balancing
Examples
RoundRobinRouter
RandomRouter
SmallestMailboxRouter BroadcastRouter
Dispatchers
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
29/33
Dispatchers
make akka actors tick
manages the resources(threads) used by actors configure mailboxes of actors
Examples
fork-join-executor
thread-pool-executor
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
30/33
Play contd ..
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
31/33
y
an easy, out-of-the-box setup for unit and functional testing
asynchronous HTTP request handling
WebSocket support
cache support (e.g. memcached)
integrated JSON and XML handling
Progressive Stream Processing
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
32/33
g g
Iteratees
Enumerators Enumeratees
7/30/2019 IndicThreads-Pune12-Typesafe Stack Software Development on the JVM
33/33
Q/A