Building Microservices

with Scala and Akka

Agenda

  • Microservices trade-offs
  • What does it mean to be Reactive?
  • Building microservices with Akka
  • Live coding!

Microservices trade-offs

+ Strong modularity

+ Development scalability

+ Freedom in technology choices (Scala, Go, Node, Rust, Elixir, ...)

- Increased operations effort

- Hard to develop

Hard to develop?


// In monolith
val productService = new ProductService(...);
val products = productService.find("nike");
                

// In a microservice
val http = new HttpClient("https://product.api.io");
val products =
   http.get("/products?vendor=nike");
                
  • Network error
  • Latency
  • Machine can be down
  • Other failures you don't expect!

Reactive Manifesto

    A reactive system is:

  • Responsive
  • Resilient
  • Elastic
  • Message Driven

Responsive = always responds in a timely manner.

Resilient = always responsive when failure occurs.

Elastic = always responsive during load peaks.

Message Driven

Building microservices w/ Akka

  • Asynchronous & nonblocking processing
  • Actors are very lightweight (~300B)
  • Failure isolation
  • Distribution

Akka-HTTP

  • Both HTTP client and server
  • Routing DSL
  • Testkit

Akka in production

... and Akka is still just a toolkit...

Live coding

Learning resources

Q&A

Thank you!