"Microservices" is one of the hottest buzzwords and, as usual, everyone wants them, but few know how to build them. In this talk we will offer our interpretation of microservice architecture, and show how we are implementing these ideas: using Scala, Akka, sbt and Docker, we modularized Akka applications, Spark jobs and Play servers.
In the talk we will discuss design trade-offs and challenges that we faced in the process, and how we have overcome them. The focus is not on particular features of Scala language or a library, but on building modern applications using the Typesafe stack and other open-source tools.
4. Problems with Monoliths
⢠Size
⢠Integration (Conwayâs law)
⢠Modules Change at Different Rates
⢠Dependencies Collisions
⢠Scalability requirements of modules
FEAR OF CHANGE
FEAR OF INNOVATION
9. What are micro-services?
A set of narrowly focused,
independently deployable services,
talking via uniform interfaces
10. What are micro-services?
A set of narrowly focused,
independently deployable services,
talking via uniform interfaces
11. Micro-services
⢠Each running in its own process
⢠Communicating with lightweight
mechanisms, often an HTTP
resource API
⢠Built around business capabilities
⢠Independently deployable
â fully automated deployment
⢠May be in a different programming language and use
different data storage technologies.
14. Threaded vs. Evented Servers
⢠Monolithic
â Most modules communicate in-process
⢠Micro-services
â communicate remotely, often over the network
â need to support cheap, lightweight remote communication
⢠Threaded servers use thread per connection
⢠Evented servers use non-blocking IO and callbacks
â Netty
â Node.js
â Play
â Spray
15. ďservices vs. ďseconds
http://www.eecs.berkeley.edu/~rcs/research/interactive_latency.html
https://www.youtube.com/watch?v=1-vcErOPofQ
19. Threaded servers
Service A Service B Service N
Thread Thread Thread
Thread Thread Thread
Thread Thread Thread
20. Thread
Service A Service B Service N
Thread
Thread
Threaded servers
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread Thread Thread
21. Thread
Service A Service B Service N
Thread
Thread
Threaded servers
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread Thread Thread
22. #NonBlocking â Evented servers
Service A Service B Service N
Thread Thread Thread
callback callback
23. #NonBlocking â Play/Spray
⢠Based on Akka using Netty
â Non-blocking programming much easier
⢠Easy deployment
â Embedded Server
⢠Rich JSON and HTTP support
⢠Plugins
â Secure Social
â Caching
â âŚ.
⢠SCALA!
30. What is ?
⢠Dockers are like lightweight VM for a single process
â Self contained
â No hypervisor
â Shared kernel, but Isolated and content agnostic
â No lib conflict
â No OS boot time
â Distributing a change is easy, using δ
⢠A Clean, Safe, Isolated and Portable Micro Service
31. Docker File
⢠Docker Image is Built From a DockerFile
⢠Consists of Descriptive Set of Instructions
â Start from a base image
â Run and command
â Add a file or directory
â Create an environment variable
â What process to run on launch
32. SBT
⢠Assemble âDockerizedâ micro services
⢠We started with sbt-native-packager
â Poor Docker functionality
⢠We ended up with sbt-docker plugin
â https://github.com/marcuslonnberg/sbt-docker
â Still Using sbt-native-packager to package
â Ends up with Docker file
36. #Containers â Using SBT
⢠Using Sequences to optimize
â Reduce build time
â Smaller Containers
37. #Containers â Orchestration
⢠CoreOS
â Linux for massive server deployments
â Cluster management with Fleet
â Service discovery with etcd
⢠Evaluating
â Kubernetes
â Flynn
â Consul
â Ambassadord
Messaging â Kafka
Resilience - Handles Failures with Supervision
We write unit files that tells the CoreOS fleet scheduler how to deploy our Docker containers.
We will use the etcd key-value store to communicate between our application containers.