SF Scala: Konrad Malawski, Reactive Streams
Recording: SF Scala: Konrad Malawski, Reactive Streams
you hope you're not too sleepy yet so and I will try to speak very fast for one thing because there's too many and too much stuff to talk about and for second thing I do want to talk to you guys like more personally if you have any questions or something so actually I can go further away so vertaki title directive streams acha streams and how it shakes and changes the ecosystem of the JVM what i mean by that should be clear and the first like five slides or so which is that directive dreams are up to for inclusion in jdk nine and it's been a collaborative effort we're all really proud of and yeah there's going to be lots of details about that so let me I work on vehicle team and Europe so which is why I'm really we're not very early but really in the u.s. also i run a conference so if you want to work more on a visit visit Poland this is a great conference you can visit and we try to help out speakers with trevor budgets so let me know okay i'll cut in random projects like companies put and I one thing I do want to know is who is actually using skaara in some way or another and same question for acha like one way or another using it okay that's great okay so we don't have to talk too much about our code surf and we can focus on the meat today which i think is great so that's the plan a little bit of story then we're going to talk about the reactive streams protocol and that's an important word there it's a protocol it's not only these for interfaces it's actually you know these for interfaces and how they talk to each other right so it's a concurrency protocol and then our implementations archos dreams and our HTTP built on top of that and I want to show you guys a demo what it actually does right because this is very important bit okay very very short story so reactive extensions 2009 I believe first introduced in.net of course not the first appearance of functional react programming but one of the first inclusions in a major runtime of that style of programming so verse 2 2009 and that was mostly targeted for a UI development right it was for Eric and clicking the button and i'm getting a stream of clicky events and i'm doing the clicky sound or something like that that was by an eric meyer right so first forward 2013 we're also pushing for very active kind of programming style and our tools to play and akka and then again a getting lots of feedback here so sorry ok now it's better and then acha acha play and eric's java so all of them all already around in 2014 Eric Java was just starting in 2014 early 2014 I believe and they all kind of take root similar things but from different aspects so for play it was it is cracking up a little bit isn't it only for me ok so on so for play it was basically ok we need this poor base back pressure thing so very stole an idea from Haskell which is an emeritus and a treatise and it's a nice functional concept that you can use to it Express pulling data from this an Emirati which is it iteratively well enumerated van coming data stream the problem about it was it's not very nice as in a little bit too complex like just by looking at this API are you sure how to implement it we're not really so that was a problem with its radius and an animal rities we do solve the problem but we're a little bit hard to when a bit too hard for daily use and implementing the cork all the time so in acha we faced a similar problem we do need back question but we faced it on a very low level so we specifically talked about socket and how we write data to socket and read data from sockets and where we solved it with a negative acknowledgement and we'll talk about that in a second so we had read salt in another way but it was not a very and high level API so it talks specifically about bites nothing else and then Eric's had another part of its salt which was a nice API part of it it had no concept about back pressure at all so it's it was more focusing on the nice fluent api s'right so when you look at this chart you probably realize what everybody kind of has a part of what we need so why not combine them together and then we'll get something that's actually really useful which is what we did so all these people banded together around 2013 October Roland first meets with Eric miles over dotnet implementation during the recording of reactive programming principles of reactive programming you may have seen on Coursera this massive online course so they meet and get chatting about it and soon after victim eats here in San Francisco with burn and other guys nervous and Eric and the term reactive non-blocking a synchronous back pressure gets point and this may sound a bit too long but it's actually really important each of these words has a meaning in Phest if its definition that we're going to talk about there's going to be a picture I guess hello okay okay so the goal is perfect timing so the goal is verse with fuzzy definition here what it means is this so it has to be a synchronous because we basically want to sort back pressure over a synchronous boundaries that's what we are solving why is it not for synchronous boundaries because for synchronous boundaries it's a no brainer I mean I call the method and I don't do anything until it returns that's back pressure boring we want the same thing but in any a synchronous context right where do I want to be a synchronous because I want to note block because I don't want to waste threat I think you guys know occur you know why we're doing that I don't want to waste resources so we wanted to be safe so we don't want to cause any buffers for to overflow and stuff like that and so that's the backpressure part of it and then it was a decision to make it a purely local abstraction and I'll explain how we go into the distributed setting even though this is a local attraction right so don't ask questions about message loss when I will be drawing messages here because when it fails to entire effing fails right it's not a distributed system in the examples i'm going to show and yeah it should at all allow synchronous implementations so while it's focused on the synchrony it must not you know be strict enough to not allow synchronous implementations why do we want that well because some implement some very specific streams it just doesn't make any sense to spin up a thread if I will be emitting nothing right my stream is empty so why would I even start my a synchronous pipeline if I'm about to do nothing or just one element or something like that right so it's for optimizations it must allow synchronous versions as well and yeah for our examples today it is compatible with TCP it's not competing with TCP which was a misconception that I had without doing this talk yesterday at LinkedIn all the questions were about why don't you use TCP it's not competing with TCP it's working with TCP ok so and then we pull in vacaville guys which is where the moment this idea starts to be not only you know let's write an API for us here is the moment when you start thinking about let's make an API and we see lots of people have the same problem so since you're about to solve the problem for more than one implementation already how about we solve it in a way that solves it now for everybody and then we can use it for interrupt between libraries right so I don't lock you in to occur and you can just enter a Parker with RX of evidence implementation nice thing to do so this is where active streams come up and Douglas events of a person basically behind all of the Java concurrency classes join the effort and enter from vaca team and Johannes and my tears from his creative and many of us join the effort and a year of discussion later we hadn't finally have something to ship somewhere somewhere along these times I join and I end up writing most of the tck so we've got the technology compatibility get this is actually really important because we want to have multiple implementations what we need to do the right thing right so we need some kind of test suit that's testing all the weird racing conditions because this is a concurrency kind of protocol we want to make sure if you're testing passing the tck I can trust you at but you know I can use your library and it's not obviously wrong at least it may be weirdly wrong but it needs to obviously one so April finally wanted 0 release which is why the title run the rise of one that owes because afterwards lots of libraries release ver1 that our releases being compatible with this as for underneath interfaces so this is only for interfaces publisher subscribers subscription and processor which you'll see in a moment and the most exciting thing about this story is ver jab 266 which is the inclusion of these interfaces in the JDK 9 this is already merged here's the link to the comet which merges face into the JDK so its up for inclusion and like I said it's a cumulative effort of everybody involved so not only us everybody sober very well with the kind of okay okay you guys know what I pay is concurrent distributed the synchronous next so why do I want back pressure let's say you have your car or system and you want to avoid this so this is a system without back pressure its overflowing buffers and it's rushing so yeah I want to let it crash but not in that sense it's let it crash and then you know recover gracefully right but that's not graceful in case you're thinking okay so what is back pressure it's not back pain and it's not back pain but its back pressure is needed when you have this with situation so we have a fast publisher of data slow subscriber of data and yeah this other words used in verse back and this is not pops up another misconception initially since we talked about history vis vis record producer and consumer etc and a multiple number of renames after we stuck with publisher and subscriber and now on every presentation someone asks is this pops up no it's not pops up it's a strictly 121 protocol so we have a fast subscriber and first publisher and slow subscribe and we have some kind of messages let's first talk about the possible solutions to the backpressure a solution to the back pressure problem first up the negative acknowledgement which we have a head in acha acha oh right for writing to tcp module and it's also expressed as in messages so eventually there's going to be some kind of buffer on the receiving end naked i'm about to explain so negative acknowledgement what is it it's exactly what i'm going to explain in the next three slides so you have this buffer and even if you think you don't have a buffer you have a buffer let's say you have let's say you have a thread pool and you're submitting stuff to the fred pool stuff is queuing up in the frets pool submission q you have a queue if you're sending data to I don't know tcp UDP whatever the risk for operating systems write buffer there's always some kind of buffer maybe you're not aware of it worked for is a buffer so in our case it's an explicit buffer for a certain number of envelopes and when that where drugs out out out out of bounds then where what happens a number of things can happen so what usually happens in most distributed systems at least four well designed ones is dropping messages and then requiring recent right so we don't blow up but we require the publisher to resend the data this is what TCP does right easy so what else can we do so you can add one memory right you can try to add more memory but that doesn't scale infinitely and then you're out of memories which is not a viable solution to a problem but a possible solution is negative acknowledgement which is exactly that so I'm looking at my buffer and I'm consuming from my queue at one operation per second but this guy still still faster so I notice oh I'm about to run out of buffer space and I will try to notify the publisher but hey would you slow down a bit or you know I can't keep up we just stopped sending data something like that but the problem is since this is innocent in this system this may not make it in time right because the messages which would overflow my buffer were already in flight so it's not really helping the correctness case while what maybe often it would work but not always right so not a good thing actually the reason why we had a day as a negative acknowledgement is this is what the operating system gives you when you write to a circuit the circuit can say well I didn't manage to write I have a mic buffer for it but in for operating systems case that's in a synchronous asynchronous API so you can keep spinning on the right until it succeeded but in the synchronous systems yeah sadly it doesn't work as good so this doesn't work and then we have the other case wherever the subscriber is faster than the publisher and ver exists a theoretical third case where we have the exact same speed however in reality yeah doesn't haven't they always oscillator little bit right even if there are mostly Faust's exactly the same speed it was hasta late a little bit okay so what do we want we want so just pool would be too slow poor means give me a message and i get a message give me a message I get a message but vets you know doubling the number of messages we send over the wire or over threat so we don't want to do it we need to switch modes but whenever we would have something that switches modes where this versus one point in time but is this switch mode point in time which is again unsafe so we don't want to switch modes but we do need two of them so how do we do that we have one mode which basically expresses both of them then the same protocol which is this so instead of asking for a message we can ask for free messages because we know I have free space for free messages right any abstract manner we can think of it this way so if the publisher got a notification with ok and I got request free which means i can send up to free messages and whenever i send a message i will decrement Viscount and I'm not allowed to send more than the downstream has signaled demand for ok so this is kind of like porn because this guy is slower so he will be slow to sending vc requests however he can send this as one combined message it doesn't have to be always buy one right so he can see send a bigger number and if the downstream is faster than the upstream then he will always send you know bigger numbers which effectively means this guy can go as fast as he possibly can because he will never overwhelm the downstream right because there is buffer space is ready for the messages which will be coming in so we are both safe and we can optimize this so that's the protocol verse of optimizations like and the publisher can accumulate this a demand signal right by obvious summing of demand numbers easy and then he signals for messages so like I said the goal was to not only make this a solve our problem will also solve an interrupt problem and I'm happy to say that we have like five or six or seven by now implementations that are actually using this and you know you can use it for interrupt so this is one thing i wanted to request so this is not a nice API to implement because of all of the weird race conditions between arrival of subscription and demand etc however you can certainly do it I want for video guys however it's not go to like solution you shouldn't first thing I want to do if I need back pressure you shouldn't implement this thing yourself just use an existing implementation like don't don't waste efforts we've been writing this for a year still got box sometimes so don't stew eight your time just use an existing implementation and which looks like that so I hope you guys are familiar with at least I racks so observable of a number of of a number of ends and then and so in our XV couldn't really change ver a POS because it would exist and break existing clients which is why currently they have this bridge method it's like to publisher but in the two data release it will implement it directly right so in our implementation is you can get a source from an integer and when you can just run too if a node publisher etc search and you can see using this interface all of these different implementations abide to the same protocol and the back pressure works all the way down from this guy who's actually writing to a socket to this guy who's generating the data so that's a pretty boring and boring source because we're this is not gonna overwhelm me because it's an iterator and I just pulled from the iterator but it's interesting in hot sources right these klick East dreams or inner if I want to not read from the database because something or I want to collapse data from a click stream stuff like that so finally a constraint so what is it about it's one of the implementations of this protocol we've been driving it from the beginning so and we're pretty happy with a result let me say and it's been rewritten like six times and I just don't want to rewrite it anymore so I'm happy that we are happy with the current implementation but I don't want to talk too much about darkest dreams because it basically looks like scholar collections with one difference being that it's a fully written lifted representation which means when you write and for example source map filter something this is um basically an ASD right so it's a abstract it's like a graph which contains the information what we're going to run and it's completely detached from the execution engine which means that we can materialize in matter with different ways which allows us to do with different optimizations before we run the thing so this is I think the biggest differentiator from all the other implementations and they can't really do as sophisticates the optimizations as we can thanks to this lifted approaches a daily thing Bruce a start-up costs but we you know you can always catch it and then the actual interesting application of this is our HTTP pipeline which is basically its prey to the 0 if you've seen spray nice HTTP library and spray has basically become acha HTTP with all the internals being rewritten and reshaped to use streaming the effort was basically in the last one and a half years or maybe more with spray team and us working together on bed so how does it look like in 20 seconds we're pretty much like a like a scholar collection or it first some maps first group and all the usual operations but for interesting part I want to show you is you have a some kind of source and you have some kind of sink and yeah we have finally have proper typing in a cup woohoo and where is the flow so flow is something from input to output so like a function but it can do a bit more than that and it also internally that's very active stream interface on both sides so if lo is both a publisher and a subscriber right because it's a subscriber from this side right it's getting data but for this side is a publisher because it's emitting the transformed data right and those invest back at least are referred to as processors and are a nightmare to implement correctly which is why I asked you to not try to implement them like by hand but if you do at least use the tck then at least you're going to see what kind of mistakes you can make not saying you will make all of them but certainly some um okay so recap basically source one and one output port flow one input one output sink one input so this is the corresponding wording we use the knocker streams to describe the corresponding reactive streams interfaces and like I said because the reactive streams interfaces are not intended for user and anyway this is a good thing so you're hitting your hidden from accidentally trying to implement you available everything but if you want to you can get a publisher out of it right and various a power mode so power mode is a flow graph which can have a arbitrary number of ports incoming and outgoing typical example would be nice tweet a typical example would be some kind of let's say let's say I'm and modes of data so I'm urging a stream of some statistics with a stream of what page of a guy was and what would page face stats were collected from and when I'm emitting what may be some collapse statistics but also may be a total count of views on this page up until now stuff like that you can imagine arbitrary complex graphs and also each of these is actually flow graph buds you know internally it's very simply a flow graph with one input port for example so it's very consistent and vpon design you just learn these concepts and it all fits together so yeah it's a in plantation of a HTTP server it's not only a routing dsl it's not only in the nvc thing it's the entire stack right from reading from tcp from writing to tcp through the routing layer prove actual marshaling infrastructure of how do i take my object into a protobuf or Jason thinking right so and it's buffers over way down which I want to show you guys in an example so obvious example for any kind of streaming API is something that has an infinite stream of stuffs for example birds or tweets or people call them so you have this source of tweets and it's hot right the tweets are coming in I mean and I need to push them to the client and doing some transformations to the tweets because i don't know maybe on filtering van maybe Im well easiest thing to do is transfer over to Jason right and when I'm writing to TCB so up until now this is our HTTP when akka HTTP also has the TCP implementation of course right but when about the operating system layer and like I said verse buffers all the way down so each of these stages has a buffer and when we have it send buffer and they receive buffer on the operating system level and well when we try to stuff stuff in to the send buffer the operating system can say no because it's for then this stage will stop writing and by which I mean it will stop signaling demand right when this stage will fill its buffer and we'll stop signaling demand which will stop signaling demand to the source which might which will make the source stop signaling tweets okay and the stops tickling sweets can be interpreted in multiple ways right so if it's a source that you can actually stop then it just stops generating the data like if you're reading from a database or something or from Calcutta but if it's a source that you cannot stop then maybe you can start conflating the numbers or dropping some of the messages or doing stuff about it but it's your conscious choice right and I don't see we have to do that okay so data flows here and opposite to the direction of data flow over demand flow is going and that's managed for your phone by this underlying reactive stream today right you don't need to care on the user level api's about demand it's good to understand why my flow has stopped working right maybe it's the right thing that it's stopped working right okay so no the one from tcp know the month to up streams doesn't generate tweets which means bounded memory stream processing which is the goal we want to achieve here because when you see a pipeline you know okay here i have this much space for both buffer space here i have this much buffer space and you exactly know how much at most memory will be used for a guy streaming with weeds guy or girl streaming the tweet which is a pretty cool thing to do because another tools well do you really know how much buffer space for entire thing will take will it even buffer what what happens and I usual MVC thing so demo time I want to show you guys how this actually works with showing the actual operating system buffers too much stuff and ok what do you need intellij 884 no to complain about box early I mean why not ok so ok HTTP do I need to explain for a POS has anyone if you have not seen spray or arc HTTP before right hand ok so a very quick tour of it so the way you write a spray application is well aunt arc HTTP application because this level of API is pretty much the same just all the internals have changed is like that you have us routing dsl which means yeah versa path and complete it with something so this is not a sink it right but it could be a future right so this will complete this request when this future has completed right now we have some a synchronous processing but this is not for all not everything because we also have a random tweet sauce which is a source of tweet oh and I'll explain the second parameter maybe right now so the second parameter is a bit maybe surprising because when you look at the collection ap is where what is the type of list right was a list of tea it's a list of teas right so what is here it's a source of tweet and something right it's a source of tweets correct and the second thing is what we call a materialized value and what this is we've played around with a number of ways to do the same thing and we found that this is the most both type safe and understandable once you get the idea and the idea is once i run the stream so this is still a just in representation they're off i told you about the AST is not running yet so but once i run it I maybe need to get something back from the stream with which I can either interact with it or inspect it for example it could have a site channel which is a counter which I can expect which always has how many elements have flown through this sauce right or maybe it's a maybe it's a control element right so it materializes a constable a conservator bad idea because then you'd usually cancer from inside the stream but maybe it's a throughput tweaking something right and you can change the throttling from the outside because of some statistics you gathered from somewhere and you can tweak it a little bit so it's a way of materializing something from inside the stream into the outside world in this case we really don't care a bit because it's an iterator so and we map it to tweet nothing really fancy here but the fancy thing is for one the reuse of flows so the reusability of flows is interesting because I have a flow of tea idea i'm up and print every element and just return it but if it's pretty boring right but the interesting bit is no one has to care how i implemented this guy right you can just give people a flow of i don't know text to wave sound wave and you just agree with someone i'm going to give you a flow of text to sound wave and you can just assume it's going to work right so it's helping to spread and reuse parts of your api here i have another one which does something really bad don't do it right for people in the back right don't ok this is just for the example i'm about to show so how do i write this thing yeah the support as a gets on the puffed wheat verse for all the get requests i will be doing this random tweets and I complete it with the tweets source how does that actually work there's a 22 response Marshall boom so you have at simplicity and implicit involved and this is our marshalling infrastructure so the way this works is if i can find the two response master for a given type i will just start writing with so of course and how do i render a infinite stream to a HTTP response where there's a number of different ways i could do it and maybe i'm not going to go into the implementations but i can show you a little bit so the spray jason support and will spray jason entity streaming support it basically means it was for framing yeah maybe I'm not God dive into all of it but basically what it is when I have a Jason Marsh floor in scope which I have because I have both a tweet format which is spray Jason for I have a tweet and I watched Jason out of it right so we have a way to marshal one tweet and when we have a way to marshal a stream of tweet which is in our case specifically for Jason and when you have can have different modes of how you on the stream right is it an array so is it starting with a bracket or is it just new line separated once etc etc default one is just an implicit that provides right each of these elements in one line and then a new line and the next line is a new element of the stream so basically I've Twitter streaming and i want to show you how this works unless you have questions you can interrupt me and this will be probably too too low or high of it a little bit yeah server demo and on the right hand side can you guys see can you see that that's Nets third minus P minus n minus P tcp rapping on local host and port 8080 which means I want to look at the TCP buffers of you know this connection and this is on a watch and we have a server running and now I'm going to curl the with a client you don't see that right it's is that better okay so I'm just calling this guy and it's generating some tweets and here we have the writing side i believe and here a reading sign right so if you're just a host with a server you would one of these lines but I have both both a center of the data and a receiver for data now what are going to show you is what happens if I interrupt the curl so I don't control see it I control Z it ok sit sleeping and first very receive buffer got for when the right buffer of the server got four and then eventually it stopped generating the tweet what will happen if I resume well first I'm draining the right the receive buffer than it drained ver send buffer on the server side because tcp figured out ok now you can write and write data again and when it resumed and of course the last feature here is either detection because when canvas happen this can happen if you have a mobile client and someone rides a car and he's suddenly in a tundra or something right he just stops reading the data and then you want to stop you know you have something a little bit buffered in memory at this point you don't have all the tweets being buffered but you have something buffett so I do want to timeout if nothing is happening on the connection for a while so usual idle Hydra timeouts which were time out in a few seconds I think the default is a minute so yeah just come back to it when it times out okay so that one thing so that's the server writing stuff part then we have the server reading stuff part in the same scenario right someone is sending me a very big file but I don't want to store the file and then start working on it I want to start working on veut being uploaded file while it's being uploaded and maybe after five lines I detect well it's this is gibberish and I just want to abort for connection right so this is this guy so if if it's a post request I want the entity to be a stream of tweet and again the same configuration applies you need to provide an implicit which says is it a line-by-line or is it I don't know is it XML is at what not we didn't implement anything other than Jason for now but you can imagine any kind of representation of infinite list you can do your own like CSV right and when you get back a source of tweet and in this example I'm waiting for well I get for tweets and they're consumed them very slowly and I count firm but let's also just take free and you don't wait and take free means I will take three elements and van can service stream canceling the dream means aborting the connection easy right and then I complete with a future or well with this future because this is tweets and run forward means run the stream and you know folded service is a terminal operation this returns a future of wizard so once the stream completes I will get back with some of how many elements I've got when I transform it to a string and just return it and this of course adds or via dose like oh it's a string so it's probably a text plain utf-8 etc etc so let's see that one oh yeah and now we have a time out over time what is a very nice joke trace but yeah it says no elements passed in the last minute so aborted connection and I do want to improve that error message a little bit currently it's not that obvious but it's a idle timeout so now same server but I want to upload some tweets how do I do that cur- d some file with tweets that's a typical one line per tweet format and then it supposed and this is a interesting feature so I told you guys that it's the Sun marshalling is provided as implicit but maybe you can accept both Jason and young CSV or something right so then you provide to implicit and vote the modular and unmask la can say is what content type is understands right so we can provide multiple masters and then once the request comes in we look at it we look at the content type look at the available mark and mullahs and we try to match one which is able to you know handle the data and if we don't then we reject the request with saying where we only handle Jason now over text right so we do it for you you don't have to implement any logic for that ok so I'm streaming the upload and some basil was it not localhost will it be happier wife on sat 7001 oh yeah the demo gods don't like me that's actually sending the data is it yeah a demo fail if it would have worked would be great I'm not going to start debugging on stage it's probably some silly mistake and they actually did not run this example yesterday and I was thinking it would work have worked yesterday and yeah guess it didn't so without further ado I'll go back to the last few slides it's five or so unless you have questions why didn't it work I don't know yes yes I will put this up on github and it will be of course in vertical documentation this is actually not they emerged pull request yet so which is why maybe it's exactly how is that because we didn't see anything like further in vp is right so what happens is when you have this dream like I have a source I have a flow you basically we have a default buffer size what we just a bit more or less arbitrarily picked I think 16 elements or so but you can do configure that explicitly by saying we've attributes buffer size and then you save a buffer size and internally we have request strategies but differed one being if a buffer goes below half of maximum capacity we request you know for this half of elements so because we don't want to send always request to requests to we want to say requests 20 maybe that could be dynamically adjusted yeah so and if you really really want if you really know what you're doing you can go one level deeper but not fully reactive streams deep but acha streams act or proper actor publisher Deep so which is kind of in the middle we do a lot of help we help you around to implement this guy but we do demand management etc for you but you give us a demand strategy so it's one for one or you know you can basically do arbitrary code and decide when you request so you can do that you have full control if you want it so um another example was about pancakes it's in the documentation and it's about pipelining so pipelining is because these 2 i'm trying to make pancakes and I make one side of the pancake on this thing and another side of a pancake on visiting and they can go at the same time and even if they rate is not exactly the same they can go both fast and they can even out at a more or less stable rate because they have buffered buffers between them so I'm getting out a stream of pancake this is how it looks flow via one flow to buy another flow and you don't want to keep you guys too long today so next one which is parallelism so one for two pancakes being cooked at the same time which I can very easily express you know inside of a flow again someone is giving me a pancake flow I really don't care how he's doing for pancakes I just want my pancakes but inside he did something he she did something really smart and actually has two other Corvus hand yeah thank you you have two pans and you're doing the pancakes in parallel but from the outside no one really cares we'll just have people for pancakes are going out faster without but we materialized value so it could give you a pancake counter or something like that you know additional metadata or additional stuff with the stream can give you back okay so this is how it looks like this is a slightly more complex API this is what i call it the power user mode and we're actually trying to simplify this currently but it basically the goal is here too oh sorry I the goal here is for this line to look as if you would draw it on a whiteboard right so verse in this but better output it goes into something and when it goes into something else so it's like having a graph drawn out on a whiteboard and when you connect the dots that's what idea behind this API for this very simple one you can just use a map a sink which starts these two functions at most two at the same time and they return futures right so same thing but in parallel so yeah use these things but no one has to actually see them it fits vets the feature that you can have it inside but no one has to care and yeah the last thing we have finally have web sockets after three years of waiting and what is a web socket and it had almost a hundred upvotes and no one would for requested so I don't know maybe it's a hard feature it actually is and so what is a WebSocket a WebSocket is a flow from a message to a message so Henry WebSocket messages boom done if upgrade doesn't go through if it's you know if it's not a upgrade to WebSocket a request when we just reject this and it would you know handle something else here there's a tilde and when you can say complete well I only handle WebSocket stuff like that so interesting thing how do I do a web socket with only writing data and I want to ignore you know anything the user sends me I don't care i'm just a stock ticker so you do that by combining a flow from a sink and a source so sink ignore source single or source stock exchange and but it looks like a flow because it has one input and one output right so stuff like that summing up buffers are everywhere and yeah we can sometimes try to ignore them but it's not really a reasonable thing to do for an engineer so let's acknowledge them and this is a good example from the Twitter streaming API they actually notify you by their state of the buffer and basically if you're falling behind like being very slow we need to buffer on over server side and they notify you about that right those egg falling behind warning and yeah it's sixty percent fool if you continue being slow we'll just stop serving you up a stream right so doing stuff like that anaka streams also two three lines I guess so soon it's going to be merged I what most it is but released I hope that's a hope and I'm not working at oracle sir I don't have to do this horrible slide with a safe harbor thing right yeah so don't believe anything i say i'm just an engineer so road map one dot one being released soon in a number of weeks it's mostly containing a lot of api improvement and a lot of performance improvements does not as fast as it can currently let's 81 that one one dot one milestone one coming out this Friday so it's you know a preview and after one that one we're going to merge it to a car to about four but it's still an experimental module does experimental mean it's a bad quality no it means some parts of API may still change a little bit so the use word binary compatibility guarantee that we have on all our AP ice doesn't hold yet because it's still a rather new but other than that you can't ride and try it out and see if it works we yeah I had some roadmap things some links thank you very much I hope it didn't take too long because last time I went far over time shall we do shall we get one or two questions and then everybody's free okay two questions no questions do you know any big user ID of the API yeah I save it with a psych because we've been telling people to not use it because it wasn't ready yet I don't know their names actually I don't know when I'm sorry but there are some smaller ish companies with not high throughput things have already been using it since early 0 dot 6 previews and it works for them but the api's has have changed like you know six rewrites but we're still happy and have been migrating and now it's the time to start looking at it because we're in the performance tuning face of it right and when you're writing in HTTP server it should be not slow right last one please so you do need a cross machine through the DCP correct that propagates fruit recipe if like on the other side that means subscribers I'm just going to get sixth at a time producer side you know okay you understand that but you come to the account for the network latency and then you know I thought I would get six is in time but the rate of the king but because of that would latency or burst and spirits of that it's gonna fall apart yeah so the question is we are kind of doing it across machines because we're talking over TCP right when TCP has a windowing mechanism and it propagates the same back person that we have in process but with between frets does it fall apart because here we're talking you know guessing how many requests we a second the current answer is for current solutions it's good enough I believe because the current cases where we want to use it is exactly the streaming API case so if people are falling behind I want to you know slow down because there's no reason for me to go for speed and yeah and some of the lessons that we've learned in this endeavor I haven't have been already fed back into spark actually I don't know when how early you guys have jumped on the stork hype is to do this way but earlier it was not that good at not killing itself and by overloading some of the way Corvin injectors not investors and bed with ver naming the notes that get the data from you know the most outside processes and they were not really good at you know relaying any kind of information from the downstream stuver to vent serves but you knows no one is keeping up and they would kill their own notes so while it's not directly very active strange but of course only lessons from you're implementing this have been fed back to spark already and invariant last release and bedford for versioning numbers again but in the last two dots x release that happened actually our engineers from our spark team have been helping a fan out to implement back pressure support in their existing infrastructure it's not directed redirected streams between the notes but in process it is so yeah it's still an open question how we're going to go about in the long run about enter note communication and the interesting bit about it since this is a flow control or we could try to ditch TCP now the question is should we ditch TCP because it's you know pretty mature and being optimized since 20 30 40 years right but it's an open question one thing on the table is error it's a protocol the same layer as TCP ra r 0 n it's a protocol designed by Martin Thompson and Taunton Montgomery it's for veggie VMs high-performance guys basically and we're claiming that for small messages so not really for stuff like here but for small messages they have really nice Rupert like many millions of elements and yeah maybe that's an interesting thing to look at we have not yet but these are open roads so now no road map updates and that respect it and you're ditching TCP tricky question right it's revving very good at what it does so thank you very much and yeah thank you