servlet vs reactive stacks – live blogging from spring days

Servlet vs Reactive Stacks in 5 Use Cases
Speaker: Rossen Stoyanchev
See list of all blog posts from conference

Asynchronous

  • asynch is a perception from the beholder. For example, HTTP is synchronous but looks async from the server. [i’m a little confused but i think i get the point of this example]
  • Amount of asynchronity is growing. The more you do it, the more complex it becomes
  • Puting blocking component behind a thread pool makes async because now there is a callback
  • Different to do async throughout the app vs one callback in one place

Elastic thread pool
<ul

  • absorb latency of blocking call
  • can be difficult to configure because need enough threads for the number of slow clients so can absorb lateny
  • uses memory from increasing call stack for threads especially at scale.
  • strategy works, but doesn’t scale

Event loop

  • Have only one thread
  • Model is non-blocking

This is how modern HTTP servers work – certain number worker threads and event loop delegates to them

Reactive

  • brings flow control/li>
  • Scale without adding more threads

Java 9 Flow is closest built in option but need library for implementation.Ex Reactor, RxJava

Reactive Stack
Need Spring 5

  • Netty/Servlet 3.1+/Undertow
  • Reactive Streams Reactor
  • Spring WebFlux

Servlet Stack
Need Servlet 3 for async

  • Servlet container
  • Servlet API
  • Spring MVC

The use cases were live examples. It was cool that the Flux API looks like Java 8 streams code.

Showed how backpressure prevents adding more when not ready.

I like the @Tailable annotation – it shows what you can tail the results of while running.

Overall, I learned/reviewed some basics. The use cases were too fast for me to follow. Which is a sign I need to read a book about reactive. I’ve seen some presentations, but I don’t remember enough to recall all the terms fast enough to follow the code examples. That said,live demos are fun.

Leave a Reply

Your email address will not be published. Required fields are marked *