Presentation: Servlet vs Reactive Stacks In 5 Use Cases
What You’ll Learn
- Hear how Spring 5 integrates reactive programming.
- Learn approaches to developing web applications that leverage Spring MVC and Spring WebFlux.
- Understand how reactive use cases evolve the servlet model of programming.
Abstract
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 5) 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.
Interview
Interview
Rossen: Last year at QCon New York I presented "Intro to Reactive Programming" based on my own experience with building a reactive web framework for Spring Framework 5. This year my goal is to use sample code with HTTP endpoints to compare the execution models of a distributed application running on the Servlet API + Servlet container stack to that of an application running on a Reactive Streams + Netty stack. Thanks to the reactive support in Spring Framework 5 we can take a Spring MVC annotated endpoint (with a flexible method signature) and in many cases run the same as a Spring WebFlux (the Spring 5 reactive web framework name) endpoint and then reason about the differences. Note however that this isn't about Spring nor is knowledge of Spring required. It is about understanding the impact of non-blocking and reactive on Java web applications.
To make matters more interesting Servlet vs Reactive is not as black or white as it might sound. Servlet has a non-blocking API which can be bridged to Reactive Streams so you can be fully reactive on Tomcat or Jetty. Furthermore in Spring 5, the Servlet-based Spring MVC provides first-class support for using reactive client libraries such as an HTTP client or a reactive data repository.
There are plenty of existing applications that cannot change immediately and many arguably don't have a strong rason to change. This is why it's important to have a clear and evolutionary path of migration as well as to understand the trade-offs.
Rossen: The main target audience is Java web application developers with some experience in running and scaling applications on Servlet containers (e.g. Tomcat, Jetty) including an understanding of the Servlet container execution model. Non-Java developers as well as non-developers can also benefit from the concepts presented in the talk. These concepts represent important trends in the Java ecosystem. Knowledge of using reactive libraries (e.g. RxJava, Reactor) is helpful but not required.
Rossen:
- Use reactive libraries in classic Servlet container + Servlet API stack web applications
- Go fully reactive and event-loop driven in Java with Spring 5 and Spring Boot
- Understand the differences in execution models and explain the benefits of the reactive approach
Generally speaking yes, the Servlet API was originally created for a synchronous and imperative programming model. Some improvements have been made over time such as Servlet 3.0 async requests that allow for request handling code to become fully reactive with no cost to the Servlet container. Others such as the Servlet 3.1 non-blocking I/O go farther but they can't be used without leaving the rest of the Sevlet API behind. The goal of this session is to illustrate the differences.
Similar Talks
Tracks
Monday, 26 June
-
Microservices: Patterns & Practices
Practical experiences and lessons with Microservices.
-
Java - Propelling the Ecosystem Forward
Lessons from Java 8, prepping for Java 9, and looking ahead at Java 10. Innovators in Java.
-
High Velocity Dev Teams
Working Smarter as a team. Improving value delivery of engineers. Lean and Agile principles.
-
Modern Browser-Based Apps
Reactive, cross platform, progressive - webapp tech today.
-
Innovations in Fintech
Technology, tools and techniques supporting modern financial services.
Tuesday, 27 June
-
Architectures You've Always Wondered About
Case studies from the most relevant names in software.
-
Developer Experience: Level up Your Engineering Effectiveness
Trends, tools and projects that we're using to maximally empower your developers.
-
Chaos & Resilience
Failures, edge cases and how we're embracing them.
-
Stream Processing at Large
Rapidly moving data at scale.
-
Building Security Infrastructure
How our industry is being attacked and what you can do about it.
Wednesday, 28 June
-
Next Gen APIs: Designs, Protocols, and Evolution
Practical deep-dives into public and internal API design, tooling and techniques for evolving them, and binary and graph-based protocols.
-
Immutable Infrastructures: Orchestration, Serverless, and More
What's next in infrastructure. How cloud function like lambda are making their way into production.
-
Machine Learning 2.0
Machine Learning 2.0, Deep Learning & Deep Learning Datasets.
-
Modern CS in the Real World
Applied, practical, & real-world dive into industry adoption of modern CS.
-
Optimizing Yourself
Maximizing your impact as an engineer, as a leader, and as a person.
-
Ask Me Anything (AMA)