Skip to content

Instantly share code, notes, and snippets.

@aksh1618
Last active January 24, 2022 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aksh1618/dbff8b4fb6a4c8db3777a8c0999cac48 to your computer and use it in GitHub Desktop.
Save aksh1618/dbff8b4fb6a4c8db3777a8c0999cac48 to your computer and use it in GitHub Desktop.
Spring Reactive Talks + Notes
  • Guide to "Reactive" for Spring MVC Developers (2018) by Rossen Stoyanchev (Pivotal): Great explanantion of moving from RestTemplate to WebClient while staying with WebMVC/Tomcat
  • Do’s and Don’ts: Avoiding First-Time Reactive Programmer Mines (2019) by Sergei Egorov (Pivotal):
    • Need to subscribe and use the return value
    • Do NOT use for CPU intensive tasks
    • There is probably a better operator for what you are trying to do: https://projectreactor.io/docs/core/release/reference/#which-operator
    • Migrate in steps, but block only once
    • No ThreadLocals: Use deferWithContext or SchedulerHooks
    • Resiliency: timeout, retry, default, error etc.
    • Run blocking code on custom schedulers: publishOn & subscribeOn
    • Stack traces for Debugging: checkpoint, ReactorDebugAgent
    • Blog posts: https://bsideup.github.io/posts/
  • Avoiding Reactor Meltdown (2019) by Phil Clay (Blizzard):
    • Either move everything blocking to a separate service or use separate threadpool/scheduler for blocking
    • Inbuilt context (Security, MDC) etc. needs to be propagated manually in a mixed MVC/WebFlux app (using SchedulerHooks ?)
    • Enable BlockHound at startup and fix blocking calls:
      • fromCallable
      • subscribeOn(Schedulers.boundedElastic())
    • Avoid doing significant work before subscribe (i.e. outside the reactive chain)
  • The Value Of Reactive Systems (2019) by Violeta Georgieva & Stephane Maldini (Pivotal):
    • Lots of benchmarks comparing WebFlux & WebMVC
    • Very high throughput on WebFlux & improved throughput on WebMVC with WebClient
    • Resiliency benefits (OOM replaced by handled exception: OutOfCapacity, support for fallback)
    • No good logging solution (yet ?)
  • Flight of the Flux (2018) by Simon Basle (Pivotal):
    • Nothing happens till subscription..
    • .. unless it does: Hot publisher (normal ones are cold publishers)
    • Time operators (intervals/delays) run in parallel scheduler
    • publishOn -> pipeline starts with subscription sceduler for operators specified before publishOn, then switches to that specified by publishOn for further operators
    • subscribeOn -> everything happens on scheduler specified by subscribeOn, as it gets propagated to subscribe call
    • work stealing: Threads work on a shared queue, backed by an atomic integer instead of lock; if one thread is working, the other just submits and exits, and the live thread steals it and continues working on it
    • operator fusion optimisations:
      • macro fusion: a.then(b).then(c).then(d) -> a.then(b, c, d)
      • micro fusion: using single queue for compatabile operator chains instead of instantiating separate queue per operator
    • Live coding version: https://www.youtube.com/watch?v=hfupNIxzNP4 (2018)
  • Cancel, Retry and Timeouts: Keep Your Sanity Thanks to Reactive Programming (2020) by Simon Baslé (Reactor, VMware):
    • Cancel: Whole pipeline can be cancelled
    • Timeout: Complex combinations possible, such as timeouts for inner ops and timeout for complete pipeline
    • Retry: Can be used to retry on failures, supporting exponential backoffs and still retains above abilities
  • How to Live in a Post-Spring-Cloud-Netflix World (2019) by Olga Maciaszek-Sharma & Marcin Grzejszczak (Pivotal):
    • RIP Spring Cloud Netflix: In Maintenance Mode (No new features, no first class reactive support)
    • Hi new Spring Cloud Stack: Spring Cloud Gateway, Spring Cloud Circuit Breaker (Resilience4J), etc.
  • Building Robust and Resilient Apps Using Spring Boot and Resilience4j by David Caron (Pivotal):
  • Designing a Reactive System: Discussion on reactive architecture based on rsocket and netifi

To explore:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment