development requires- • High data scale, we are dealing with too much data • We have high usages of scale • We worry about costs- cloud costs • We don’t want to block our threads • Essentially blocking is our enemy 3
level • We need to call blocking get() call • It doesn’t have composability options. • We are doing asynchronous call, but in the end, we need blocking call (e.g from main thread) • The other thing is, when you have a new thread, it requires to get data from another threads, in which CPU needs point data to. Thread can run into different core, that could leads to cache corruption etc. Also context switching from one core to another core is expensive. 11
• It’s an implementation of the ExecutorService • It understands that some task is dependent on other tasks. • It avoids changing threads • It helps us to prevent cache corruption • The assumptions: newly created tasks are likely to have in closer cache. • That indicates that the newly created task should run on the CPU and older tasks on another CPU • Each Thread has its own queue. • It steals tasks from another thread’s Queue from the tail when it has nothing left. • It gives us a huge performance boast, in fact, pretty much all reactive frameworks are built on top of it, even the project loom itself. 12
than 3000 lines of code • It has more than 50 methods which we can readily use and pretty much serves our all-purpose • A task can be combined, chained, and composed 15
discussed how to deal with individual objects. • What do we have, LIVE data, a stream of data? • We can go far with the CompletableFuture to a certain point, but what if – • Producers produce data faster than the consumer can handle. • What do we do? • Drop the data • Buffer it • We can block • Or maybe we implement some communication mechanism between consumer and producer? • Well that’s where Reactive stream comes into play 16
V S R E A C T I V E S T R E A M Java Stream Reactive Stream Pipeline Pipeline Push Data Push Data Lazy Lazy Exceptions? Nothing we could do here Deal it downstream Error is another form of data Data only 3 channels– 1. Data channel 2. Error channel 3. Complete Zero, one or more data Zero, one or more data Sequential vs Parallel Synchronous vs Asynchronous Single pipeline Multiple subscriber 23
difficult • The reading experience is terrible; cognitive loads • Easy to over complicated things • Don’t treat it as a hammer, and don’t hit every nail you find 27
we have here in reactive but only makes the blocking call cheap which is super cool • Allows us to write imperative code easy • It’s just a different concurrency model, less complicated, less learning curve • You do what you have already know, just do with cheap stuff 28