Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0

9,484 views

Published on

Reactive Streams 1.0.0 is now live, and so are our implementations in Akka Streams 1.0 and Slick 3.0.

Reactive Streams is an engineering collaboration between heavy hitters in the area of streaming data on the JVM. With the Reactive Streams Special Interest Group, we set out to standardize a common ground for achieving statically-typed, high-performance, low latency, asynchronous streams of data with built-in non-blocking back pressure—with the goal of creating a vibrant ecosystem of interoperating implementations, and with a vision of one day making it into a future version of Java.

Akka (recent winner of “Most Innovative Open Source Tech in 2015”) is a toolkit for building message-driven applications. With Akka Streams 1.0, Akka has incorporated a graphical DSL for composing data streams, an execution model that decouples the stream’s staged computation—it’s “blueprint”—from its execution (allowing for actor-based, single-threaded and fully distributed and clustered execution), type safe stream composition, an implementation of the Reactive Streaming specification that enables back-pressure, and more than 20 predefined stream “processing stages” that provide common streaming transformations that developers can tap into (for splitting streams, transforming streams, merging streams, and more).

Slick​ is a relational database query and access library for Scala that enables loose-coupling, minimal configuration requirements and abstraction of the complexities of connecting with relational databases. With Slick 3.0, Slick now supports the Reactive Streams API for providing asynchronous stream processing with non-blocking back-pressure. Slick 3.0 also allows elegant mapping across multiple data types, static verification and type inference for embedded SQL statements, compile-time error discovery, and JDBC support for interoperability with all existing drivers.

Published in: Technology
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... ,DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0

  1. 1. A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0 Endre Varga, @drewhk — Akka Team
  2. 2. Outline • Reactive Streams • Slick 3 • Akka Streams • Akka HTTP • Bringing it all together 2
  3. 3. Reactive Streams 1.0.0
  4. 4. Participants • Engineers from • Netflix • Pivotal • Red Hat • Typesafe • Individuals like Doug Lea and Todd Montgomery 4
  5. 5. Recipe for Success • minimal interfaces • rigorous specification of semantics • full TCK for verification of implementation • complete freedom for many idiomatic APIs 5
  6. 6. Supply and Demand • data items flow downstream • demand flows upstream • data items flow only when there is demand • recipient is in control of incoming data rate • data in flight is bounded by signaled demand 6 Publisher Subscriber data demand
  7. 7. Dynamic Push–Pull • “push” behavior when consumer is faster • “pull” behavior when producer is faster • switches automatically between these • batching demand allows batching data 7 Publisher Subscriber data demand
  8. 8. Back-Pressure is Contagious • C is slow • B must slow down • A must slow down 8 CA B
  9. 9. • TCP for example has it built-in Back-Pressure can be Propagated 9 CA B networkhosts
  10. 10. Reactive Streams • asynchronous non-blocking data flow • asynchronous non-blocking demand flow • minimal coordination and contention • message passing allows for distribution • across applications, nodes, CPUs, threads, actors 10
  11. 11. Slick 3.0 The Reactive Database Layer
  12. 12. Slick 3.0 • Reactive API for accessing databases • Provides internal management for blocking JDBC access • Reactive frameworks/libraries can be used together with ordinary blocking database drivers • without sacrificing scalability and efficiency 12
  13. 13. Slick and Reactive Streams • On top of the usual database operations, a Reactive Streams implemenation for queries is implemented • Query results can now directly streamed in a non- blocking way • Allows integration with other Reactive Streams compliant libraries • (Akka Streams and Http, and many others) 13
  14. 14. Akka Streams
  15. 15. Declaring a Stream Topology 15
  16. 16. Declaring a Stream Topology 16
  17. 17. Declaring a Stream Topology 17
  18. 18. Declaring a Stream Topology 18
  19. 19. Declaring a Stream Topology 19
  20. 20. Declaring a Stream Topology 20
  21. 21. Declaring a Stream Topology 21
  22. 22. API Design • goals: • supreme compositionality • exhaustive model of bounded stream processing • consequences: • immutable and reusable stream blueprints • explicit materialization step 22 http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC2/stream-design.html
  23. 23. Materialization • Akka Streams separate the what from the how • declarative Source/Flow/Sink DSL to create blueprint • FlowMaterializer turns this into running Actors • this allows alternative materialization strategies • optimization • verification / validation • cluster deployment • only Akka Actors for now, but more to come! 23
  24. 24. Akka Streams in Java 8 / Scala 24 Typesafe Activator: http://typesafe.com/get-started
  25. 25. Akka HTTP
  26. 26. Why do we add an HTTP module? • Akka is about building distributed applications • distribution implies integration • between internal (sub)systems ➜ akka-cluster based on akka-remote • with external systems or between microservices ➜ akka-http (lingua franca of the internet) 26
  27. 27. Akka HTTP—The Origins: Spray.IO • Fully embeddable HTTP stack based on Actors • focused on HTTP integration (toolkit) • server- and client-side • seamlessly integrated with Akka 27
  28. 28. Spray.IO Features • immutable, case class-based HTTP model • fast, lightweight HTTP client and server • powerful DSL for server-side API definition • fully async & non-blocking, actor-friendly, modular, testable • based entirely on Scala & Akka Actors 28
  29. 29. Spray.IO Weaknesses • some unintuitive corner-cases in routing DSL • deep implicit argument chains in some cases hard to debug • missing features, foremost websocket support • no Java API • handling of chunked requests is clunky, incomplete • dealing with large message entities can be difficult 29
  30. 30. Proxying Large Responses 30
  31. 31. Akka HTTP is Spray 2.0 • addressing the weaknesses, polishing the features • Java API • simplified module structure • core improvement: fully stream-based 31
  32. 32. HTTP Stream Topology 32
  33. 33. Stream Pipelines 33 TCP SSL/TL S HTTP App Requests Responses optional
  34. 34. Bringing it all together
  35. 35. The Application Stack 35 O/S-level network stack Java NIO (JDK) Akka IO Akka HTTP Core Akka HTTP application level Akka Streams Database Driver Slick 3.0
  36. 36. 36 More interesting stuff… WEBINAR Reactive for DevOps: A New Series REGISTER HAVE QUESTIONS? Get in touch with Typesafe today! CONTACT US WHITEPAPER Getting Started with Apache Spark DOWNLOAD NOW
  37. 37. EXPERT TRAINING Delivered on-site for Akka, Spark, Scala and Play Help is just a click away. Get in touch with Typesafe about our training courses. • Intro Workshop to Apache Spark • Fast Track & Advanced Scala • Fast Track to Akka with Java or Scala • Fast Track to Play with Java or Scala • Advanced Akka with Java or Scala Ask us about local trainings available by 24 Typesafe partners in 14 countries around the world. CONTACT US Learn more about on-site training
  38. 38. EXPERT TRAINING Delivered on-site for Akka, Spark, Scala and Play Help is just a click away. Get in touch with Typesafe about our training courses. • Intro Workshop to Apache Spark • Fast Track & Advanced Scala • Fast Track to Akka with Java or Scala • Fast Track to Play with Java or Scala • Advanced Akka with Java or Scala Ask us about local trainings available by 24 Typesafe partners in 14 countries around the world. CONTACT US Learn more about on-site training
  39. 39. ©Typesafe 2015 – All Rights Reserved

×