ROSSEN STOYANCHEV SPRING FRAMEWORK DEVELOPER
In the past year Netflix shared a story about upgrading their main gateway serving 83 million users from Servlet-stack Zuul 1 to an async and non-blocking Netty-based Zuul 2. The results were interesting and nuanced with some major benefits as well as some trade-offs. Can mere mortal web applications make this journey and moreover should they? The best way to explore the answer is through a specific use case. In this talk we'll take 5 common use cases in web application development and explore the impact of building on Servlet and Reactive web application stacks. For reactive programming we'll use RxJava and Reactor. For the web stack we'll pit Spring MVC vs Spring WebFlux (new in Spring Framework 5.0) allowing us to move easily between the Servlet and Reactive worlds and drawing a meaningful, apples-to-apples comparison. Spring knowledge is not required and not assumed for this session.
9. Async throughout (not an afterthought)
Code needs to evolve to adapt to non-blocking execution
Efficient use of resources, scale, resilience
Reactive brings flow control
10. How Java can help
Future: forget about it
CompletableFuture: good but single value only
Stream: for collection but no latency
Flow (Java 9): a.k.a. Reactive Streams
12. Spring Framework 5.0
Ready for JDK 9
Functional with Java 8 and Kotlin
Java EE 8 integration (Servlet 4.0, JPA 2.2, Validation 2.0, JSON Binding)
Reactive programming model
13. Servlet Stack
● Servlet container
● Servlet API
● Spring MVC
Reactive Stack
● Netty, Servlet 3.1+, Undertow
● Reactive Streams, Reactor
● Spring WebFlux
14. Reactive Spring
Reactive starters in Spring Boot 2.0
Spring WebFlux endpoints + reactive HTTP client
Reactive Spring Data Kay repositories
Spring Security
and more…
24. HTTP GET with reactive data repository
Designed to work on both Spring MVC and Spring WebFlux
Simply return reactive type (Flux, Observable) from @Controller
34. Servlet 3.1 non-blocking I/O ?
Unlike Servlet 3.0 async, Servlet 3.1 non-blocking is hard to retrofit
Requires deeper change
Mutually exclusive with rest of the Servlet API
48. Servlet stack summary
Reactive data repository
Streaming to the response with back pressure
Reactive orchestration of remote services
Reactive request input
Data ingestion with back pressure
49. Reactive stack summary
Reactive data repository
Streaming to the response with back pressure
Reactive orchestration of remote services
Reactive request input
Data ingestion with back pressure