HTTP/2 for Go

Video in TIB AV-Portal: HTTP/2 for Go

Formal Metadata

HTTP/2 for Go
Overview of HTTP/2 and the design of Go's support for it
Alternative Title
Go - Http/2
Title of Series
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date
Production Year

Content Metadata

Subject Area
Group action Server (computing) Implementation Wage labour Code Multiplication sign Web browser IP address Cumulant Word Intranet Bit rate Causality Different (Kate Ryan album) Software testing Communications protocol Library (computing) HTTP cookie Hydraulic jump Data type Addition Dependent and independent variables Email Demo (music) Server (computing) Closed set Binary code Content (media) Electronic mailing list Audio file format Line (geometry) Binary file Semantics (computer science) Connected space Type theory Personal digital assistant Encryption Information security Communications protocol Library (computing)
Satellite Computer file Internetworking Tesselation Decision theory Multiplication sign Bit Web browser Connected space
Point (geometry) Frame problem Slide rule Server (computing) Length Workstation <Musikinstrument> Streaming media Client (computing) Web browser Theory Number Twitter Facebook Fluid statics Graphical user interface Different (Kate Ryan album) Googol Extension (kinesiology) Data compression Proxy server Email File format Uniqueness quantification Fitness function Streaming media Bit Instance (computer science) Frame problem Connected space Single-precision floating-point format Data mining Basis <Mathematik> Personal digital assistant Order (biology) Quicksort Table (information) Communications protocol Modem Computer worm
Logical constant Email Meta element File format Client (computing) Open set Fluid statics Medical imaging Type theory HTTP cookie Arm Mapping Bit Maxima and minima Process (computing) Internet service provider Duality (mathematics) Buffer solution Analytic continuation Quicksort Hacker (term) Reading (process) Booting Web page Computer file Control flow Streaming media Number Product (business) Goodness of fit Googol Ring (mathematics) Codierung <Programmierung> Implementation Address space International Date Line Form (programming) Data type Default (computer science) Dataflow Information Interface (computing) Physical law State of matter Directory service Line (geometry) System call Frame problem Graphical user interface Word Hausdorff space Spring (hydrology) Error message Personal digital assistant String (computer science) Universe (mathematics) HTTP cookie Table (information) Window Flag Standard deviation State of matter Code Length Multiplication sign 1 (number) Set (mathematics) Proper map Web 2.0 Bit rate Semiconductor memory Flag Huffman coding Endliche Modelltheorie Extension (kinesiology) Area Email File format Streaming media Variable (mathematics) Connected space Type theory Auditory masking Website Right angle Gauß-Fehlerintegral Row (database) Frame problem Dataflow Trail Server (computing) Implementation Functional (mathematics) Game controller Identifiability Service (economics) Codierung <Programmierung> Real number MIDI Web browser Vector potential Field (computer science) 2 (number) Internetworking Operator (mathematics) String (computer science) Analytic continuation Proxy server Dependent and independent variables Sine Mathematical analysis Peer-to-peer Particle system Sheaf (mathematics) Communications protocol Extension (kinesiology)
Scheduling (computing) Hoax Concurrency (computer science) User interface Archaeological field survey Bit rate Client (computing) Software bug Expected value Medical imaging Array data structure Type theory Different (Kate Ryan album) Orthogonality Conservation law Office suite Error message Multiplication Physical system God Strut Mapping Block (periodic table) Software developer Structural load Constructor (object-oriented programming) Interior (topology) Electronic mailing list Mean free path Staff (military) Maxima and minima Bit Unit testing Message passing Buffer solution Phase transition Pattern language Reading (process) Writing Spacetime Booting Point (geometry) Web page Slide rule Computer file Streaming media Mass Rule of inference Product (business) Number Goodness of fit Energy level Selectivity (electronic) Configuration space Codierung <Programmierung> Data structure Communications protocol Computer-assisted translation Maß <Mathematik> Metropolitan area network International Date Line Data type Default (computer science) Key (cryptography) Copyright infringement Server (computing) Interface (computing) Weight Code Counting Client (computing) Limit (category theory) System call Frame problem Word Spring (hydrology) Maize Loop (music) Error message Software Personal digital assistant String (computer science) Function (mathematics) Table (information) Library (computing) Flag Intel Greatest element Code Length State of matter Multiplication sign Sheaf (mathematics) 1 (number) Set (mathematics) Mereology Total S.A. Uniform resource locator Duality (mathematics) Mathematics Bit rate Semiconductor memory Flag Software framework Series (mathematics) Logic gate Point cloud Graphics tablet Area Email Electric generator Transport Layer Security Internet service provider Menu (computing) Streaming media Fehlererkennung Parsing Connected space Type theory Interface (computing) Configuration space Website Hill differential equation Right angle Whiteboard Block (periodic table) Freeware Frame problem Trail Dataflow Functional (mathematics) Implementation Server (computing) Game controller Statistics Freeware Service (economics) Identifiability Token ring Discrete element method Graph coloring Field (computer science) String (computer science) Operator (mathematics) Program slicing Software testing Addition Dependent and independent variables Slide rule Sine Coalition Debugger Bound state Pointer (computer programming) Logic Communications protocol Computer worm
Email Complex (psychology) Scheduling (computing) Presentation of a group Mountain pass Numbering scheme Client (computing) Software bug Roundness (object) Radio-frequency identification Different (Kate Ryan album) Set (mathematics) God Link (knot theory) Block (periodic table) Staff (military) Process (computing) Quicksort Writing Reading (process) Spacetime Web page Dependent and independent variables Computer-generated imagery Streaming media Authorization Boundary value problem Myspace Key (cryptography) Suite (music) Server (computing) Interface (computing) Physical law Content (media) Code Client (computing) Field (computer science) Total S.A. Line (geometry) Limit (category theory) Frame problem Loop (music) Error message Personal digital assistant String (computer science) Revision control Video game HTTP cookie Force Library (computing) Gradient descent Code State of matter Length INTEGRAL Weight Multiplication sign Direction (geometry) 1 (number) Set (mathematics) Mereology Peer-to-peer Bit rate Logic gate Email Information systems Network switching subsystem Transport Layer Security Term (mathematics) Connected space Type theory Interface (computing) Self-organization Hill differential equation Software testing Right angle Energy level PRINCE2 Laptop PC Card Frame problem Digital filter Server (computing) Functional (mathematics) Overhead (computing) Line (geometry) Tape drive Content (media) Theory Field (computer science) Power (physics) Connectionism Regular graph String (computer science) Software testing output Analytic continuation Window Default (computer science) Domain name Dependent and independent variables Sine Haar measure Inclusion map Logic Sheaf (mathematics) Synchronization Spectrum (functional analysis)
undergo go and I read the magic you're going go around the center library and anyone here is not mentioned in the that so this is more addition should be the stuff of this talk is I has maybe 1 third about each to what it is of really quickly on that animal jump in look a lot of code of so yeah around their labor stuff on so yeah is you to know history of paintings and stuff anything in getting a document on intranets I served over and go over the protocol can look like this the red was kind what your browser or whatever you call the thing there was a nova browser sense and the response was like you know lists of texts in the columns and the little 1 and 0 basic were the content type weather is you know by text document or another listing original like 7 and it was like an audio file or something and then it should be 0 9 1 91 you basically just 1 line there were no content really everything was now 1 0 sorry adding some headers the you can send some of the key value pairs on your request and his and you know has a response uterine contemplates as it evolves come slowly they added I keep alive so you can opt in delight not tearing down the TCP connection every time and on the response of several would say OK this is a keep-alive eminem's inter-speaker action you could then issue another 1 and 1 1 that was implicit so all connections are keep alive was you opt out of it the Commission close now you have to say what hostname we're talking to to make you know all the IPD for shortage problem and having virtual hosting the virtual host that so we have 1 IP address for hundreds of customers and you would bounce of really and it's now a like 99 and that's about it that's about where we are on so recently this they into requests it looks a little bit different of then the main thing you Lotus's in over the last while many many years tax protocol you can only do 1 thing at a time from only 1 you browser only asking for a single request at a time of year hundreds of milliseconds away from the thing of basically like 6 in the MS of dead time that is the connection there and it is a cumulative lots of packs and stuff like special cases for working around browsers and we're servers and stuff over time also issued to another is still pretty clean inconsistent causes not many implementations of people are trying pretty hard for Interop on as binary protocol as you also things at a time and I guess as a demo close that so here it is alive test was 1 over time OK so but this says server rate should be 2 as an example if we look at it steady 1 with 2
and all sectors latency you could see do you are you getting is a delta files or CSS but the browser can only keep 6 connections open to server times like a policy decision is the 1 that was to out 6 and that's kind of how browsers have worked around they should be 1 of its and I got a little bit more connections but it's still consorts especially like
1 2nd leads if you're out of out the woods near the satellite internet connection this is how you browse the web but on the other hand if we look at it should be tilde one-cycle latency the you know like it was 1 2nd for all of them but we ask for all we ask for all tiles all at once so that is that is the
promise of a should be 2 of the back 2
slides I so yeah there wasn't really any improvement from 199 Jun 13 teenagers cut up the number of connections there a C 1 1 theory support pipelining Regan on 1 to speak action ask for a whole bunch of things and yet given back in orders fell on but in practice it is doesn't work in all browsers have turned off and servers don't really supported and many people in the middle transparent proxy is that try to like stuff and I'll be out they just choke on it so no 1 uses on to around 2 dozen Niners overly earlier Google was Google had a browser this point in you as some servers and so Google started opting into both sides to likes upgrade to different protocol which is pretty easy over each GPS because nobody in the middle can massive you because as all encrypted so what you do at that point you know the school so they started operating people to experimental protocols and measuring lots of things and generally well other people liked it on Facebook and Twitter and other we wanted Facebook ended up recommending to the idea that it become the basis for a of the 2 of you have agreed to be will is really but most people are generally happy with finale should be to use basically speedy with the budget weeks so back back to the station at the request they should be to request you figure like that there's all 9 byte header so it starts off with the the frame length so 1st there's 12 bytes of this is 12 bytes of the payload yours and mine bytes they won by this is what the sort of packet is for this frame is from 1 means headers then you have 1 bite of bits that says better bit specific to this frame so this 1 says and stream which means the so every every basically requesting the request you make over 1 of these long-lived like could be days of TCP connections is has a unique stream ID and so I had a is starts a new strain and honestly 91 and stream bit says the there'll from my side The client is done sending for instance there's this is a GET request there's no post body attached to this and and headers means this is the full extent of my headers and I know how follow-up frame coming later that like you know you could in theory have like a gigabyte of issued the request headers no you have to be cut in the multiple frames in this case it all fits in here and there's the 12 bytes avoids the request which is compressed with each pack which is a whole new compression format that is like an adjunct spectator should be 2 that is just crazy town with lots of different things FIL static tables all common things there is guy I have here so
where each that yeah so there's there's all these
tables of like common issues of the things that you will see is of these gifts statically assigned numbers really sure variable encoding numbers than the static Huffman tables for like who will do some analysis of all the traffic is he's on the web and this is the smallest way to encode that the empirical data that so as of this is baked into this back and so once you do all this stuff of what you
do all the stuff that represents like a whole 1 of those get connected by browser and this encoding a stateful so if you have this 1 TCP connexion open and you send a cookie that's like you know of a page long new user agent would have all that crap and the user agent is send 1st request and the some sort request it it's a couple bits because you just refer back to something you did in the past the nerves of as of industry but it has to do with the connection so that so what 1 should use the connection dies like all year each pack state goes aware of yes analysts on the Russian vein of to these are they should be to frame types that are defined as the ones on the right are cannot optional ones that are hints from the browser and at his from the server and but the main ones data is of stuff going up or stuff going down on you know like of post body your response body response to a GET headers is you know like a new a new stream 1 new issued the request continuation is kind of a hack in this back that says the would have been of it a packet I have to add another 1 on these ones kind of special and that all the other frames to be interleaved on the connection but whenever the the header that doesn't have in headers that's that you have said continuation directly adjacent to it on the wire on so yeah of course there's still special cases already settings left the 2 peers the client and server negotiate like upgrade to like higher settings and saying you know what you're flow-control rates are and on the maximum size of the packets maximum size of like various other patters how big you know you committees to be request so that paying disclose the client or service area is still there resistance an idle TCP connection that you know when when go way allows for graceful shutdown so initially 1 1 you have a problem where the you know your past year whatever has the keep alive time out of 30 seconds that 29 and a half seconds the browser like AAAI user request well maybe the post and the same time universities in bag of like or reset coming this way and other other cues might procardia tells you know if this server not enough so is you to actually addresses this in a clean way where you can like know whether or not the 2 regarded reclined out it and on the a graceful shutdown that I window update is form Everything Asia refuse flow controlled so on every stream so it would between the priority and flow control you have a client that does a whole bunch request but then the client knows like to render these to meld may be any the jobs that women CSS or I really want this file more than that 1 the the client could tell the server exactly how much is allowed to stand on each 1 and how many bytes it's allowed so that the client can kind of eyeball both sides really can control how the other 1 is sending crap and it's a violation if you don't keep track of all these counters about how many bytes your labs and on the whole connection and buys your descend on certain stream to yeah I both sides have to do lots of accounting during the process as far as how you upgrade from each had to be 1 day should be to where they should be yes you do it with an extension until us it was previous called NP notes there's a they move how it works skull LTM is basically the same you basically just stay in your handshake our by the way of after were done with this whole Hendrik business these the protocols that I would like to speak and the other 1 so that is just like you negotiate site sweets and stuff you can negotiate the protocol that you can speak next is the right after the handshake is done you know on this this works really well for another's a like political thing about whether of all the to goodness should also work for each DPT any others people saying 0 no word on the only way we have to everything on the web now there's other people as a of of great information if he doesn't work in practice because of all these transparent proxy is that break everything which is true this is been measured on people counter argue but interstellar to fix it but you know don't really fix things on the internet so anyway in practice for political reasons but as far as I can tell the supporters back for each operating from http but of IE Firefox and Google and chrome in the dual servers nobody's implementing this on I'm not planning on implementing those on those new servers and applies really implementing it but it's inspect but so we will ignore that effectively its issue yes only and maybe would give us lepton grip thing more people of sorts by default but I'm anyway at talking his records so don't don't don't How do I make anything a that they have that so the 1st thing I did when I started writing this I ask if 1 little part about on the upgrading connections you can see like this is we have to do in TLS they need to accept a connection with you just click until listener and the next particle on honors for his age to 14 which is this is the identify string for the protocols as each should the 2 draft 14 and then after the handshake you look at the connection status has a field called negotiated protocol so it so in there of there is a about onto it fell as region frames so we will read something in return something of Raleigh Roger frame we don't really know exactly what the frame is yet but and I showed you the frame format our so there's 9 bytes and there's 3 but the length a type of lines and stream identifier only the law 31 bits of which are the same identifier them as a reserve that maybe for use in the future on so the 1st thing I did was made a frame header struct and to represent that 9 byte header and so there's the type which is defined as a name type overbite and then there's the flags which again is just a name for of light that had the length which is the UN 32 because go doesn't have you in 24 but so this thing is the destructive little bit bigger than 9 bytes but whatever and then the stream ID the frame type like I said was just a bytes has proper documentation about there's when 2 constants notice I don't use IUD here don't you lie odor when you're actually implementing aspect that has defined numbers use I when you just need your own set of numbers as purely internal so here this is what the specter finds and these numbers as the the of I give up you know little names I defined string methods on frame type which is you know very useful when you're dealing with a binary protocol and some some crap comes in and you like long it is nice to have the it'll all string file out so it has a name iPad product the name if I don't know the name I say unknown friend type and whatever number is likewise there is a type called flags for thing and you have a convenience methods on like has so I can say is that they have is better than the code can reads nicer later and I don't have to say like little bit wise operations all over the place in your compile so the same thing and then I have all all the flags there defined for each frame so late and stream of data and stream on this they haven't had the same number but like in this back there the different so we have different constants here form then of course I have a big map of which bits are defined for which frame types for a new which flag that's and that ends up string flying really nicely so when the ice isn't debugging I get some stratification of it as a spring providers with these flags set and maybe this debt so 2 known but it's still you know prints out and the other 1 the symbolically stream modeling 17 so yeah this saves you a lot of time when you actually write good string methods on things on the rack directory frame my reader over images frame which we still know what it is yet on but 1st before we read a frame with 3 just the frame header when we do know a friend Hatteras of constants there's no 1 ever known it's the C see the those law case by others 998 bytes suffering as a new 1st implementation could look like something like this we have Bob off and you have to brain Herroelen by 9 bytes and we as we read full whenever you read a thing it always has totally soundbites all rainfall once we have that thing we could just return the frame and to unpack it get the length in you know mask off at mask off the reserve bit you know we don't care if it's higher low but the the Lotus here is this read fall because this is doing interface call for this thing scape analysis really can't tell the doesn't know what the implementation of rigorous doesn't know whether sold skate for this will be 9 bytes of garbage every time this calls the really wanna come with reuse the buffer that we read the frame header into so we don't want a function like this we want to like provided the memory to read into so instead he could readily this were the caller supplies the buffer to read the frame header into so now now this is being passed in and we just say it has really stand bytes and you make that a requirement so this is actually the the real implementation arm in the code of course there's
tests were always relative to us you know there's actually poly twice as much code invasivity package as there are is in like the non test code so as are office encounters like this that I rose manual reasons can verified it does approximately the right thing of this back to reframe when I read bring matter we don't really have a bath yet though to pass to this thing so rather than having a brain function this podium method on something else this point and make a framework and the framer has a reader and has a little 9 by buffer is reuses 9 by buffer every time we read the on little constructor to make a new framework and that's not all the is there were any users favor for reading and writing on the now wintering free method on prima edges reuses this this little man by buffer on the thing and then summed up about so what is frame and you could probably go either way instructor Phase may change it back to stop at some point for for garbage you reasons but currently interface on there is like 9 10 different frame types and that what they all have in common is they all have unethical header that returns the frame an orthogonality invalidate does later we basically want to let the caller we water reuse the memory for all the internal field between things so we don't like generate garbage as things are coming in so we have a caller with done with the frame call invalidate I'll show how that works when they so the frame matter addition to like those field as a before we also added this on exported valid bit that basically says does the caller on this or not and if they don't you we will blow up later and there methods on the frame header on a pointer to the grammatical invalidate of which is part of the interface so nobody else to implement the spring interface it's only the of the 10 types in the packaged implemented because they knew that trick of case method names on things and then there's this technology method that blows up as is useful for debugging the CIA from you know somewhat someone did something wrong Gorgias somebody like did understand lifetimes a so here's an example of 1 of the 10 frame types there's the headers frame is bad the frame header so I get the invalidate method embedded and I am excesses on it like the headers frame we had those 12 bytes no earlier than the had h packing included stuff the higher level code is when get access to those but it's going to be using memory this despite slice points the memory that it doesn't own the frame owns that until the person called nowadays so this I called check ballot on here to see if the caller does indeed still own this frame and if not blow up otherwise a return and the slice and then I have some convenience methods on headers frame that have tutor names like headers ended rather than having the caller after I f flags housefly headers and so it is it just makes the call so it's a lot easier when I'm checking that's the done when is an outcome would at this we have a framework and we have some optional suffered things back at the max size a lot of stuff they can use back I can't see http to use that and was the they start a really low limits like 16 K or 64 K in various table sizes and the 2 sides if they agreed that they have enough memory above a space they can initiate higher there's is mapped reads as constant the buffer may also have on this function here called get rebuffed so after we write a frame and we know that there's gonna be like you know 32 k a of a Magar something coming we need a buffer to read the rest of it into and so I pull this out into a function so we different policies about like how we manage the memory for incoming stuff the we don't want to like have every idle connection if you have a server that has like hundreds of thousands of connections you all of them good muscles connections the idols they should be to you have a lot of idle connections all time you want of all holding onto a little buffer just in case I need to read imag later you call them to get that we easily when they really really need it and then that you wanna like return it back to somebody else actually needs that so I pulled out onto a function that the default implementation just appends onto this thing this rebuff so you don't really have to think about unless you want to override the allocated the the default thing is justified on the where it then I have a map of from all the frame type of frame passes so I have back in the frame header which the frame function we read the frame header already we know how big it is we got the memory for it and so now we have make a type called frame bar services internal detail that given the payload returns the actual final frame their face as a the deliver map from all the all the types and that we have this function called given a frame type give me a frame parser at the known 1 so like I don't I have push during development I only have like 3 or 4 these and you know I would just fall back to the past unknown frame 1 which is basically does nothing and so this is good for debugging I probably should change this from not being a map look up here every time it is doing a rare look up involve active personal brain but the so now we frame like this we read the frame header and if the length is bigger than we've negotiated is acceptable we blow up until on the frame is too large otherwise we get an appropriate buffer to read the the payload into I read fall and so we now we have both we have a full packet basically the whole frame in memory and now we tell the tight frame parser which is you know who knows the knows the issue do http into level details of like how to look at the bright and there was do that evidence of frame and we also keep track of the last frame we read in the beginning of frame the invalidate the previous 1 there was 1 so here's an example of 1 of the 10 like a pass a data frame other spec says that if this stream idea 0 the data must be associated with a stream of solid pump some of the frames are like higher-level things like negotiating settings but data frames in particular are always associated with a streams of we see 1 that like 0 we use drop the connection they violated spec and so I can quote this back Anopheles places and say what section this back said this in the tons of tests for all from the 1 of the flag data patterns which is what's the declines obscure the size of the packets by putting in dummy data that is actually there and so we all the staff keep track of what the actual real data is ignoring the pattern and return that frame so there's the others 10 of these little functions that parts of the different brain types that a file is the error signal error code have all the error codes from the spec and then there is a cat they should between h 2 H 2 college to spec defines connection error and stream error basically kill whole connection they violated the whole the whole protocol basically and there's a string error which means there is some problems specific to a stream that we can recover in only that stream only that each should the request goes away I on the right hand side there's a whole bunch of Our right functions the specific to the frame has with the right rating data settings pains data were no stuff and he is the 1 that right settings takes variadic settings thing and we say start right with the flags for the other 1 is golden settings rights and fields and we say and write those things look like and he's setting that is a really simple right 1 star right offering type from settings without flag and I think rules length and loners I so on the frame where there is right and there's the buffer we write into 2 like build up that little partial packet I start right of artistry Monday yeah so the stream office settings the stream ideas is always 0 and because those are specific to strings but we write a 9 bytes here with a pen we leave 3 bytes they're ready to fill in at the end after we're done writing the thing and then and right we know how big the buffer is now so we know the proper length and just as a sanity check if we wrote more than we can express in 3 bytes we blow up and think the color that a linearly Don and then I we know the buffer is big enough for this psychologist abuse append July like quickly but 3 bytes in there because of how it works an SOA what it the bounds actually you append like this the other pilot and that's a check that g of space for 3 things rather than saying for everyone you have space for so it and sure it's not even a performance problem but it's it's cute but and then we write thing to whatever the the writers so writing and any others who will convenience things are running Abijah writing you in 16 Orion you 32 on here's the right frame method we basically say you know we don't to have support for padding right now because I'm not sure if anyone really use it but when they're all at it the Freya has support for doing illegal issued http to legal things just in case you want a test another person's of limitations and the garbage and so I have actually used up my unit test framework against other people services such as implementing the right hoax to bring up the servers and so on so you have if this is the end stream will always about that we start right 3 flags of the data in the score and right so all these right that is a pretty easy
the I so now writing the server itself I I showed it a creation B 2 on to say that connection 8 and you get a field negotiated protocol and then in the issue to package as of like can go 1 3 go 1 2 there's a steel on the on the server kill next proto and probably never used it before because there is no purpose of using it but this is an existing hope that's been there for like 2 years so this is given on the part of the EP and the N R a O P N of identifier like each 214 what should we do that connection when we receive that this isn't defined as you know that the go should be packages handle that but if you put something in there on in In this package in the package there's this configure server function that sets it to the overseas 214 arranged to and we use as a all will handle conservation will be hijacked the connection from the stand libraries if you actually go to use this you don't change in area code or a should be handlers still the same you still called listen and services are kill us or whatever and adjust the transparently speciation B to when it can right so inside this package we now have the ECB server which has all the them the configuration that you've set we have actual connection which is all in practice will be the TLS con and we have a handle on that you wanted to run on to what so the for every connection that we get we're basically gonna have 3 go User for 5 there is with the 3 main ones is there's 1 that I call serve and this 1 is non-blocking keeps all the state all these like accounting of flow control and stuff on is in it's maps and stuff there and there's 1 dirtiness reading it's just sitting there blocked forever basically really calling and was waiting for 9 bytes to show up want to get signed by its in the reads the rest the bytes and have a full frame in memory then it's and the were channel to the server ones as you know deal with this frame and then it's it's the board and told has been handled and then we say OK read another frame forming we unblocked you likewise as a rule go routine was writing to network and a block sometimes it as a flush something and I'm but we never want to either block reading or block writing what this would always be fast and I'm walking and discover teen actually I had this 1 running all the time that 13 is used to be for k then a K and then and then what will last release a 2 K Estela B 6 K of memory bridal connection which is kind of a waste if you have you know 1 of hundreds of thousands of connections or something so actually found it was faster to start up discovered team does right a single packet and just let it be destroyed when was done then sending a message over channel writing it as an ambassador back but it was done so actually every frame right there's a new purity and it sounds kind ridiculous you know writing creating something urgent so quickly that goes really fun with it does matter at all so you're Garching counts in your servers if you look at your the bug statistics will be really high but it's fast so I think I can even make this the logic Gurteen shut down most the time when there's no packet to be red I that to k will go away and then you just prairie idle connection you'll have this to K reader 1 and when a new packet comes in if the the logic reduce is running also started up and it corn is all the other stuff so whenever a request comes then is decides to make an you know a new news to be request and then we we start a new Gurteen freeish to be handler which might be you know your D false mock series to be handler funk and they communicate with the server 1 about like OK right in data reads data and all the push back of like you know you're allowed right you don't have the flow control tokens to write this now are always push back happens on channels here so it for this reason coalitions on that stuff it the so this is a beautiful structure that is created every time you a connection is like crap loads of channels that of things going up and down and sideways between these little pieces of and you know we initialize the flow control with the initial number of tokens you allowed we set up a encoder decoder with the buffer the brain right to or read read from so what we do when we get a new header field a new key value pair letters which basically notifies of the server that you know the connection that at the 2 list when we build a framer the read read-side is based on like whatever the negotiated the protocol and then we serve the survey 1 sets up a bunch of stuff for the basically the 1st thing it does is right a frame to the remote site and says here is my policy on what you're allowed to do like what your Mac frame size mass concurrent streams only how many how many should be requesting fight once there's also all these differs they just win win the server function returns we'd would be terrible the world which aired on all these other your retains the running and we'll make sure HCB handlers that are blocked it unblocked because of you know you don't you wanna handle sitting around blocked on a rights or something and strain rate data on the issue response writer but and the remote cited you know killed the initiator close the connection you unlock those to use all these things can just tear down things but the of yeah right well right frame does via all right schedule a also as area here so the and and this is the bottom of this 1st function of serve then basically all it is is is big for select loop weights for things to happen like a frame of frame coming in or a notification from the right Gotti that we wrote a frames and we note OK were no longer writing a frame now we could scandal another frame right from the the frame scheduler is issued to as always priortization things the client there were does before assassin and when all this and so we may have all this stuff can a buffer operators and we don't know which packet the client wants next so we use that you know they're all sitting there in memory some maximum bounded size is sitting there memory we choose what this and the next I and then there others other things like they send their settings framed within the right amount of time so when we know we go away the system shut down stuff I this is the dodginess their reading all the time basically and makes a little dates but I have on the slides have a date which is just a fancy name for a channel of empty struts and then I just so I can attach some names to as I don't have to write G. sense Drucker legal paralegal legally n i is a dominant weight and so I make this gates that I read the frame I send it to the server loop as it had lot of frame and here's a gate and so when you're basically we're done with this frame amino it just as they're called weight and expect so this pauses the in so it doesn't trample over the memory that somebody else already dealing with so that's the framing date nothing fancy there is their face value and that the channel I so I know God his own ideas and we don't ever want to give you ideas this you'll do grows in discussing things them but it is possible to get them and sometimes it's useful on Andrews prolonger infringe on the slide but I thought I found so this is soaring over here is a four-door Henes going on should be handler at the serve on the read 1 right 1 you've all the state all the stuff on the sovereign nation thing and it's easy to document in english what the rules for access is like you know this 1 can only be done this data is owned by discouraging this data is on the this new tags regarded by this new text but enforcing it the race detector perhaps works very well when you actually trigger arrays but it doesn't happen doesn't have something that he did wrong when you got lucky so I wanted a little bit more paranoid so I made this type called dirty lock which is just a you 64 this set the size of internally dirty 94 and I made a little constructor that looks up occurring dirty 90 using undisclosed tax but you can you can look in the code it is or it's really really slow so it's only during tests now I say that have check and have check not on and basically this this grateful number that when you call check on it the number better be the same in the word team that when you originally constructed this thing otherwise is blows up as a during tests as a debugger reduced the true and in production these are like no-ops but I'm so then I think I should that on this page who yeah things like and serve there's like served you . check is almost the functions in this all start with like what go routine they're locked onto is just to check in this had can't 3 or 4 times but those are the 3 or 4 times it would have taken days or weeks to debug of the SOI so I have things like right frame handler that has documentation about like what Gurteen you have to be on and there's that is here like check that you're not on the severity and call this 1 or right frame check that you are on the right on discouraging to call that 1 so this depends on whether or not it's a handler trying to write something or of frame rate that's happening from the like the main logic will serve loop and when we do understand something we basically just added to the frames gondola and say q
this maybe not right now and the scandal frame rights in this the frame writers says our if already writing a frame and the frame rate are always runs of the logic never gene that the server loop was a Ferrari reading frame will be tolerant 1 at a time to do nothing and will will get tickled again later to run instead of something else whenever that frames done writing and then some stuff like if we needed to tell the peer to shut down for going graceful shutdown was in bad readers and the setting that you do that otherwise there'd been domain case is we ask the frames cajoler Haywood's was the next best thing descent and and this does the privatization of various things and want if we got 1 then we call star frame right of In stop rewrite actually does the rating the must as good well well then is sort of this room to the and then there's um of the stuff like process and this is why organize lots and other ones when a when a frame comes in no there's basically just functions for dealing with each 1 of the ones when you get like I have process headers we I all the stuff is back like is these this about that there verify that I the stream ideas the arranged the stream it is always have to be odd in 1 direction and even in the other direction because either side can initiate strains the server can push pre and I did talk about this but any she to the server can preemptively issue of response for HTTP request that hasn't been made yet that you get a request for the up like a slasher your your front page you know that like you know there's some CSS and Indulska something on page you can send a response to the front page and say here's a hypothetical request for you that you can use if you want and here's the answer to it and so it's a then the clients you can get all that once a 1 stream without another round trip and so because both sides to generate ideas 1 that has to be even 1 that has to be on so we on the server we check that it is actually odd we make sure that they're not reusing the stream that was you know older in the wrong straight but then we create a stream for with the idea they said in this a and a certain state and then do the priortization staff and then process was told by its members told by the racetrack present effort was side or at the continuation which is utterly like the same 1 as as headers but they have to appear in back-to-back on the wire so if so we process the Herblock block fragments and we write and H. pack so this can come at in the boundaries you can have any argillite user-agents Eunomos love i . noble off that can be split over dozens of frames and it's not aligned on key-value boundaries of all status you the dates back decoder whatever data yeah this alliance to use when reading this back it doesn't say what you're supposed to do at they files accessible bugs against this back just does whatever code should I use in this case on I don't know I guess I would be a stream air but I haven't implemented that 1 I just I think that would bubble up and the connection in the in the air that all annotators a connectionist streamer becomes a connection with total collection but I'm so yeah college my decoder right at the top when they maybe it's packed and new decoder as specified a callback and this is this is a method values on you that this is the receiver name and this is the method names of the thing by itself is a function and God you on new header field yeah the that that type FAQ header field is those struct basically key-value string and then I could check to know whether it's 1 these magic wand rather than sending like get all capital MySpace all this stuff the method the path the scheme the authority these are all this magic key value pairs of start with colons and nothing else can work begin with colons we also check things like cookies a special case than this back for a weird reasons we check that the valid 1 you can have any upper case feels they should be to so we normalize it NGOs and you don't see a difference in years should be handlers but if on the wire we see a capitalize field you the spectrum of the hang up on them so the the tests are fond of there's whole bunch of tests in here that do things like the 1st I made a type called server tester just so I can make the other test double easier in these have lots of little convenient methods for doing stuff then I'll have a test like for the here is a a single test that but a post with no content length and stream does the right thing so here's a new nation the handler and he in metal server tested gets passed in into test server requested little test helper we write the headers with stream anyone in the block fragment with method posted net this this and not that set and we verified that would go sees eventually is a as post with you know that the ink on the line can be 0 because we had no and so is pages of the use of all the different all corner cases and you know and you run FIL feel like tons of all tests of all the different cases I and there's even 1 test in there that will run on my laptop with unobserved doctor but actually yeah at are there questions this contest is darker to run integration against other limitations this is a very important part of yeah so the question is that Guruji lock making at what of public in the standard library I actually I would make a case to others that it would be useful but I expect pushed back on the and how right the the we the the what the you my life am on so we is that I'm not actually writing little 9 by thing I might and several back it's the frames cajoler has a field those needs flush and once a prince Google has nothing else than a raised above I writer and once once there's nothing else to do it spends sends a special type called flush frame writer that actually functions it to the wire all of that by you mean that you could in theory be a minor performance improvements worth the complexity yes indeed there are a couple more copies here but theories of the of right it exposed to light and all to thank you very I could do lots of things I I think the problem walls like take something space and also like it seems to it makes the collar think was matter were true was measured of false there's nothing magic about either 1 of those and also I mean that I don't care about but the overhead in his life value this was free and actually on there's paths for various things like if you have an empty struct it goes into different scheduler bring power laws so I I The adding is easier to read is the main reason why we care about performance other well because the general but I do I do this multiple times I reuses AI you the in writer and read frame yeah so I create it once the gate of their and then I just read reason the same 1 every time the the the jails are so small and they're around 64 80 bytes or something like that for all the bookkeeping so 1 more question the but once and all is what all this in 1 way so this back they should be D-spec upstream isn't blessed is officially and so sometimes annual so we we would put it in go until it's done at the client finish the client started the client so our body 1 6 but it's it's available in on that having you get added to your thing in like 2 lines of code I think important is a contiguous servers we're using it and chemist or some for the I L O you once it goes in 1 6 of what is the on like you want to do anything to cost several of the the same same response primary while they added the interface AUC is unchanged under be some optional things that you can often do like do the server push thing but I'm yes well thank you