spring5 reactive programming
Reactive Programming (2016.09)
https://community.oracle.com/docs/DOC-1006738
- Reactive programming is about processing an asynchronous stream of data items.
- In the Reactive Programming model, there is a Publisher and a Subscriber. The Publisher publishes a stream of data, to which the Subscriber is asynchronously subscribed.
Spring Web-Flux – Functional Style with Cassandra Backend
https://www.javacodegeeks.com/2017/04/spring-web-flux-functional-style-cassandra-backend.html
Doing Reactive Programming with Spring 5 (2017.09)
https://stackify.com/reactive-spring-5/
- Simply put, it’s a non-blocking alternative to traditional programming solutions, working entirely with event driven data streams and functional programming concepts to manipulate these streams.
Reactive Programming With Spring 5 (2017.11)
https://dzone.com/articles/reactive-programming-with-spring-5
- Reactive Programming is all about non-blocking applications that are asynchronous and event-driven and require a small number of threads to scale.
Reactive Streams With Spring Data Cassandra (2017.12)
https://dzone.com/articles/reactive-streams-with-spring-data-cassandra
장점:
1. 적은 thread로 더 많은 일을 할 수 있다. (pub->sub)
2. 모아서 주는 응답의 경우 준비되면 바로 전송하기 때문에 응답의 시작이 더 빠르다.
3. 응답과 관계없는 작업(통계 데이터 저장 등)을 하는 경우 별도의 처리가 필요없다.
4. 일을 할 수 있을 때만 일을 하기 때문에 자원을 효율적으로 사용할 수 있다.
단점:
1. 함수는 Publisher<>의 구현체를 리턴하기 때문에 호출시점에 실제작업을 하지 않아 디버깅이 어렵다.
2. 아직 지원하지 않는 API가 다수 있으며 그 중 JDBC는 지원 계획이 미정이라 현장에서 적극적으로 사용하기 어렵다.
3. API가 자주 변경되서 버전이 바뀌면 컴파일을 새로 하거나 구현 방법 자체를 바꿔야하는 경우가 생긴다.
4. 호출과 실행이 분리되다 보니 CGLIBAOP가 남발하고 CALLSTACK이 깊어서 무겁다.
(벤치마킹을 보면 이론보다 성능 향상이 더딘 이유일 수도)