Merken

Understanding Non-blocking IO

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
take the money and other goodies in your know
1st of all I'm really excited to be edited by this by 1st saying the planet so it's amazing to be the speaker here so thanks to everybody who was involved in selecting adults in giving me this opportunity to do they really do we talking about non-blocking area would specifically how does that work but by the so of
a high-level overview of we are going to look at what is not working on and off try to understand this my example it's uh and essentially what like why do we need to do this really so this is going to be all the not the practical examples but understanding of concepts so as to what really goes on when you talk about looking at you and you know when and where you try to use it but the problem and it is another thing that would also expect the content to be like that but just a little introduction about myself ready when working with might and for about 4 years of as of now I work with those started in based out of New Delhi India and I'm interested attended lenders and interconnect with me here my in some of the solution approach things
but some background as to why I'm doing the stocks when no all along when I was in college I started out as a web developer and this out of curiosity is not going on the stack exploring things and there's some somewhere there was this project which required of me it was the eradication is quite a bit of a scaling 200 more connections on just 1 box it was very limited resources place and all just an underlying when I was taking out some with the view of some some content around how to the scale applications are encountered you want but when I use it but then was that it was that they went into the understand how it works so others wondered what does this thing to but other than that of what I'm going to talk about today is something that I have not really seen anybody talk about especially at any Python conferences you would see in just about every other Python Conference have a was still got needle bodies using coyotes is fact so I think there's a lot of going on right right now apparently this talk about but nobody did he talks about what are the underlying infrastructure that these secretaries of frameworks make use of home and I I plan to shed some light on the so none looking at all
just before we start understanding what it is the 2nd what is blocking so blocking the existence of a simple definition of of a function could block is blocking if it has to wait for something to complete later on the that's probably the simplest definition agricultural and what that means is that let's say if you have a function that makes the issue requests to another the API and does something with whatever this quantity it's the Stuttgart the to address and collect get so this is how we will extend the same example to any kind of network interaction that would cost of for example talking to you my sequel was just database but get application can progress on to the next thing I I want to hear the response by from that of other examples could be alone you know you have some function that does some statistics of some some mathematical computing combination of and that just takes time for example some
complex integration and it may take a while before the next thing can be done in the program on the application of another example could be waiting for and the user to import something for example on the continent of these things are blocking so the problem with blocking code is that it is capable of
dealing execution and as long as the tasks of to each other that's fine because you cannot do 1 thing because it depends on the other 1 but what if they're independent dusting in and application which can actually progress with each other if not at the same time so for example you have a single standard whatsoever so which is usually the case and by the way we don't really like many multithreaded web applications at these with the Python and you get a quest of the yard request and designing and it makes a call of database and at the same time you get another request so the 1st designing single-sided director of it can hardly be some of the other request because the 1st request is blocking the other request of another simple example would be that you have workers consuming tasks some some Q and usually you offload you heavy
processing to workers which asynchronously processes interests so if you work is doing something about and it is blocking when it could be any reason why it's looking but and if it is not looking for it it is looking because of I O then you basically not doing anything at that time because when you put it's not quite because a file of united in making use of these if you have but what it really comes down to is that the old old system is not able to progress during blocking it's fine but of blocking of the things that are independent which could be done 1 of worldwide and the other thing is blocking and not doing anything about the love you know useful at the time but that is not and will as as in areas which who want to like late systems of applications that need a set multiple of uses a modified loss of in a consumer's need to maybe use of they may be any other application we don't really want that so knowledge of directly from Morgan
applications that produces every day to day of things like dealing with the network of indeed writing from a unified system doing operations on by these these are the kinds of things that would follow you know and I 0 but that may not be exhaustive but in general if you wanted to find a lot of near any kind of file operation it would be dealing with file descriptors are doing any operations and for this purpose so today at least for the scope of the stop it going to be willing to talk about dealing with the network and a lot of to the non looking out of the way to you know bring networking and but non-blocking narrow
is essentially dealing with IO so that it does not block institution of execution does not get deleted because of i
of and to understand that let's let's look at some examples of that is it is that is 2nd enough for people to the this problems it's you know it's technology is small that doesn't seem to be something OK what I can do trying to do is
but in this so yes so we we we look at some good in them instead of so this is this is ladies and lowered things that we will look at when we start out with that programming and and of this is a simple basic whatsoever and written by the knowledge does is it accepts connections of weights for some data from the from the client that is tried to connect that gets the big up and said data and then waits drastic and local data and doesn't as long as the plant is trying to send some data they felt that this is the this is a very simple script probably most of us here and the work done any kind of video programming in Python would have all of that something like that so for this scope of this talk we are not actually going to be in making use of this more the this is the
simplest get to point 3 look at this again and his and you know you
know almost as simple planned
as our so this again nothing in distress to connect to the same so this land and try something some data to be precise addresses in about 70 and we'll ourselves and so on when we quotient inferred and so on
until of B and the 3rd is and a was counting on my estate to with so that prompted content was treated development of the problem we have to make do with this so we can build this over now and if we look at this code on on line 11 their so blocks because it waits to receive a connection and want to see for the most innovative Atlanta's to connect to the server and after that online 13 it blocks and the client sends some data is was so that the so that we can actually the data the whatever the with of or that it wants to and then print of the data and then looks again when it tries to get more data from the client and keeps on doing this to the client stops sending any data on the other hand no plants group
blogs but this column where
the of the client is actually trying to send all of the data that is 70 and if it doesn't mean it's understandable that and take away and will be explained and so of knowledge is the block rate so
and this left to the states because this is what was talking in the states and the problem with this is when we then this the big assuming that the so it is an eggplant declined it's about 45 seconds to run on this machine that I'm using made no and while it was a trying I mean the scripts that I suppose not really trying to do anything such that other than sending the data but if it really wanted to do something you couldn't have because descriptive just knock on top of 10 so let's see how we can improve on so for non-blocking
network IronPython at the most basic level where it comes down to is this To make a socket nonblocking calling the same looking method on it and then it will not be looking anymore so you positives false residual and it makes the something books and how does that work and how does it go under looked like in the
world so again that's expected such spectral when
here and this is the same
blinded showing earlier but just with 1 minor change there is 1 that is delaying the has
said something to be non-blocking and everything else is exactly the same and when on
the of and read on the client it's
not exactly the same thing we see in the solution Ford and as a statement on the on the last line of the the strip and says that bytes sent to so it is not accorded the bytes we wanted to send now this happen as soon as we change our stripped transfer and wanted looking did was and that it did not saying all of the data of soul that that the 2nd and this so the start of the year is that when in the previous chapter when the stock was not non-blocking something was blocked hello some essentially works as it makes whatever system got it needs to made to send the data to the other process on the other end of the connection but what's really happened is the process that copies of sense the bytes that it wants to send to the other side and also that the so the code of the amount of data that can be accommodated in the bag before of of the current for that trait called off of that same called gets lost the kind of space 1 of the girls gets that and then basically put the process to because that died before this so and that's the reason why I call the cognitive looking so when the column was looking at the the process lost the the little by too good to a buffer and then the current takes care of that synset across to the other side of the of connections and then in the meantime it puts a process to sleep and then it brings the process back up of makes the process of when the nite before goes and then gets more bytes to send and keeps doing that and along the data has been transferred and why the president's is sleeping it's not making use of any views of we could potentially do something else and that when we made that socket non-blocking some that sent the don't immediately but basically what happened was a distance of the number of bytes of the model today could give to the current through the center the other side of the connection and don't immediately saying these are the number of bytes I could transfer so far so it just send the number of bytes it could immediately and not look at all of but what it give us back in the dollar was a number of bytes of transfer and that was that is use of self so that we can as of knowledge and failed does not end of the data model all we can use that this and all the data in another way so
let's look at another
improvement of the script
well use a slightly different kind of all that things you is essentially the same thing as socket is non-blocking but we put that in the end of life you know as long as the of the of not send all the data it just tries to standardize again and again and again so of sort that standard don't immediately telling as the number of bytes that were transferred and now that we know how many bytes of answered we can try to send you know the meaning in the next iteration so this this this is essentially how we made a socket nonblocking and we keep trying to read we just keep trying to send more data and as soon as that the problem with this just here is of but the good thing is that we have achieved non-blocking something along looking idea what we'll be seeing again a lot of it is 2nd to none in that way you because most of the times but we would not be able to send the data because they go from an audience so if the if the done this actually we would probably end up spending most of our time exceptional instead of actually being in the and this has led to the coherent succeed only if whenever of that is seldom that a before and this is this is again the other the room and I could change we can now make use of this is to make more improvements and probably do something more useful instead of just only trying to send this data so I had to you another the
improvement of the to this very close with some minor
changes again we can have do
and this is again the same pretty much the same thing as we saw just before this again but with 1 extra line which is just this and this is something new which probably if if not to ever tried to look into all non-blocking are not just on looking I worked in this kind of interesting to watch this might look you select basically that the so we are doing exactly the same thing but the way you would look at this line as long as we don't have the same suffered available for writing again so as long as the buffer that I'd often becomes it as as a died before this phone this guy would block here so want select does is it it
stops us from wasting the CPU cycles separable you know mole wasting earlier trying to go some thoughts and again and again in every iteration of the way but what select exactly the was
rather interesting to select is nothing but the system goes away and it's it's an infrastructure
provided by the operating system for monitoring find this proposed what events so elements like it is about disability for writing or abuses by the security for reading what is the status of the fire handling some kind of exceptions tender what's select the selected again that we just use what we saw that is is just to the output of the of the most bitter example of this is gone but it also makes using so they are not as simple as compared to the CAPM but if you understand how to use it with Python you would probably be able to make sense out of it when you look at some sequence out and the
signatures like this you boss select of the subset of 3 sets of affine descriptions of the areas of descriptors in these areas are basically of multi different areas which you want monitor for by the deed event on the right away from an exception on offenders with and this is followed optionally argument which is time 0 so it's basically don't hold only once they could block any of the fundus fossil monitoring
become operative so early in the previous example we did not use that therefore the argument so so they could plot not indefinitely but all you can see that and the other does according to your needs and it determines a subset of find this appears as honest getting these are the finest suppose which are available for performing whatever operation you want you were monitoring them and when we don't define disappears at least uh and bite and what what select except is any object that implements the final number method so will be usually something have I mean not usually out of a tavern sign on the methodology and because of its are essentially for this this and this and that and we have the physical side numbered on something you can learn the corresponding factor support from
some consider other
than the 1 that the media was that the or at least a really doing essentially the same thing that is trying to send it again and again in a way to but we make process of love as long as we don't have another we don't have uh something really useful in a way of performing the operation and here we
look at it 1 last example which is word so
far we have only been trying to you know the same during a non-blocking fashion and not doing anything along with it but essentially the idea of doing non-blocking areas that are even if you are a signal to the upper and lower when you are not doing anything constructive you should be able to do something it's if you can so here's here's another example doubt continuing with the previous example would just change to work of all we have created 2 tasks 1 task is the same that we wanted to send some data but also and the other there's this task which makes use of the viewer just to increment the counter that is part the so that free and amended on this so most of the time for those of you know easy to do so we would really know what you're going to do is we're quantitatively of it but lake in both of these tasks proceed with the help of generator function so this is 1 task which is essentially intended to function a implements a counter in a way and it is after every iteration and the other task is the same thing that we trying to achieve in our kind of and it's again the same code of which assigned assigned the same amount of data but the only
difference is that when were going to make it instead of splitting something that we use and we used the subject that we were socket object that we're using for sending this data and real data what the operation that we want to monitor this so In in this subject for and finally we have a mean log where we implement another in a slightly different words
and of for the use of the way you probably this is unclear but here we what we do is we tried to execute both these tasks was 1 by 1 and then monitor for file descriptors and from execute the corresponding tasks that are or whenever of different disciplines are that if I were to take your data so we show we have I mean you
don't have to lead to the entire core but that the essential thing
to understand is that what we're doing is we're that we have an institute where you where where we are done in this way the lesson we have we have some dust which you already have some fun distributor monitor so whenever there is a fire disappeared from 1 of the reason is that of there some doesn't it wants to the form of do something after that when the fungus becomes available for doing that operation right so all we do is we learn every 1 by 1 and of the task of the generator function for the task user socket announced system wanted we well you know but we we just to keep a mapping of all this by this because and the corresponding task and further down the we got select to monitor those modify support socket object and do whatever needs to be done according to the distance and this electron is that we have used the time of the argument here and there said that a model easier because we don't really want to but why don't we were developed well justified this appears not to 84 l'exécution Whitley's then they other task which was implementing compass proceed as long as these factors not for the operation on the so what we call select and on every iteration we check if the file discipline is ready to be monitored and we create a painting Task list where we keep pushing the the task that needs to
be In executed in the next section of the way and this is pretty much in so that
this this these changes of the not visible again probably service quote somewhere so that you can read it so when you when you like when you have more time at but FIL of what we achieved here was cooperative scheduling using gender the functions ancillary and please let 2 independent tasks proceed come along with each other in a single theory strip and you can actually say that this is system the 1st of network event to implemented dierences implement security also implemented
so I think I have just 1 minute left there and I'm going to
just to the rest of the thing that's was so I select we we just its neglect that operating system actually provides infrastructure for monitoring for this proposed there's something called old you're old game but soon after I don't know if so laughter select model of the implementation on the technical details are pretty much the same other than the appear from that sense of is probably as bad as the length of the time complexity of force components probably the same people and give you a pretty much the defectors today but most of the real part of Web servers and other candidates and make use of the people and if you but if you using inquisitorial of dear of on the next obviously systems chances are that you know they have the full implementation of the implementation and and
another thing I don't have more time working on the inside the happy to have more questions other states where
essentially a lot of whatever libraries you have and in the
bottom of but probably we can catch up with you want to know more about that so any question FIL if you what this is maybe more
related to this system but are you aware of the lean meat over a synchronous is connections you might have the problem the limit
of synchronous connections I'm sorry model approaches that is something that I'd be happy to know all the words in the universe what was that this thing 1 2 million surrounded like the 4 thousand because let in this he appeared on select yes yes Selected is is indeed limited by the number of firefighters suppressed but I think you can change that if you are combining the operating system yourself so there's a book about but what we don't do that so you have most of the time to to be limited by the number of descriptors you can monitor using some about of but of the having said that I I mentioned something about so time complexity in that there selected as compared to the people I think you tends to be slower than of nobody really uses up at this of it really depends on what is the use case of using tonight so if you don't you have many find monitor probably select would be a better choice to make as compared to people before point actually starts signing of
been so much thank
you
Flächeninhalt
Computeranimation
Einfach zusammenhängender Raum
Zentrische Streckung
Softwareentwickler
Bit
Sichtenkonzept
Quader
Stichprobe
Kartesische Koordinaten
Übergang
Framework <Informatik>
Computeranimation
W3C-Standard
Systemprogrammierung
Datennetz
Inverser Limes
Web-Designer
Projektive Ebene
Reelle Zahl
Inhalt <Mathematik>
Lineares Funktional
Statistik
Datennetz
Mathematik
Datenhaltung
Schaltnetz
Interaktives Fernsehen
Kartesische Koordinaten
Fortsetzung <Mathematik>
Computerunterstütztes Verfahren
Code
Computeranimation
Funktion <Mathematik>
Kurvenintegral
Code
Existenzsatz
p-Block
Optimierung
Server
Datenhaltung
Web-Applikation
Systemaufruf
Kartesische Koordinaten
Physikalisches System
Elektronische Publikation
Computeranimation
Task
Physikalisches System
Multiplikation
Task
Funktion <Mathematik>
Menge
Flächeninhalt
Thread
Stochastische Abhängigkeit
Zustandsdichte
Datennetz
Kartesische Koordinaten
Gruppoid
Physikalisches System
Data Envelopment Analysis
Mini-Disc
Elektronische Publikation
Computeranimation
Server
Zustandsdichte
Client
p-Block
Computeranimation
Einfach zusammenhängender Raum
Gewicht <Mathematik>
Stellenring
Extrempunkt
Information
Computeranimation
Videokonferenz
Metropolitan area network
Client
Diskrete-Elemente-Methode
Socket
Skript <Programm>
Bildschirmsymbol
Optimierung
Dualitätstheorie
Datentyp
Elektronische Publikation
Fächer <Mathematik>
Adressraum
Applet
Information
Computeranimation
Metropolitan area network
Verzeichnisdienst
Socket
ATM
Client
Reelle Zahl
Große Vereinheitlichung
Web log
Hochdruck
Gruppenkeim
p-Block
Information
Code
Computeranimation
Metropolitan area network
Client
Bit
Socket
Zoom
Inhalt <Mathematik>
Softwareentwickler
Einfügungsdämpfung
Gerade
Server
Zwei
Fächer <Mathematik>
p-Block
Bitrate
Visuelles System
Computeranimation
Virtuelle Maschine
Metropolitan area network
Client
Socket
Total <Mathematik>
Client
Skript <Programm>
Aggregatzustand
Metropolitan area network
Datennetz
Datennetz
Residuum
Übergang
Socket
Computeranimation
Übergang
Metropolitan area network
Server
Socket
Mathematisierung
Client
Applet
Visuelles System
Ext-Funktor
Computeranimation
Einfach zusammenhängender Raum
Server
Befehl <Informatik>
Elektronische Publikation
Sichtenkonzept
Prozess <Physik>
Datenmodell
Zahlenbereich
Strömungsrichtung
Wärmeübergang
Physikalisches System
Systemaufruf
Gerade
Raum-Zeit
Code
Computeranimation
Puffer <Netzplantechnik>
Informationsmodellierung
Client
ATM
Total <Mathematik>
Client
Socket
Abstand
Gerade
Videospiel
Dualitätstheorie
Server
Elektronische Publikation
Iteration
Zahlenbereich
Applet
Extrempunkt
Computeranimation
Arithmetisches Mittel
Metropolitan area network
OISC
Verzeichnisdienst
Socket
Total <Mathematik>
Verweildauer
Client
Skript <Programm>
Socket
Ereignishorizont
Logik höherer Stufe
Standardabweichung
Server
Elektronische Publikation
Mathematisierung
Computeranimation
Puffer <Netzplantechnik>
Metropolitan area network
Verzeichnisdienst
Diskrete-Elemente-Methode
Socket
Total <Mathematik>
Verweildauer
Client
Datenerfassung
p-Block
Große Vereinheitlichung
Chatbot
Ext-Funktor
Gerade
Chi-Quadrat-Verteilung
Physikalisches System
Metropolitan area network
Server
Zustandsdichte
Dreiecksfreier Graph
Client
Iteration
Physikalisches System
Zentraleinheit
Ereignishorizont
Systemaufruf
Computeranimation
Blase
Parametersystem
Subtraktion
Computersicherheit
Ausnahmebehandlung
Element <Mathematik>
Elektronische Unterschrift
Menge
Systemaufruf
Ereignishorizont
Computeranimation
Portscanner
Teilmenge
Physikalisches System
Metropolitan area network
Deskriptive Statistik
Multiplikation
Zustandsdichte
Menge
Flächeninhalt
Netzbetriebssystem
Trennschärfe <Statistik>
Affiner Raum
Ereignishorizont
Funktion <Mathematik>
Objekt <Kategorie>
Metropolitan area network
Nichtlinearer Operator
Parametersystem
Multifunktion
Programmfehler
Vorzeichen <Mathematik>
Client
Zahlenbereich
Menge
Teilbarkeit
Computeranimation
Metropolitan area network
Nichtlinearer Operator
Verzeichnisdienst
Elektronische Publikation
Prozess <Physik>
Total <Mathematik>
Hypermedia
Client
p-Block
Chatbot
Computeranimation
Data Encryption Standard
Elektronische Publikation
Iteration
Code
Viewer
Computeranimation
Task
Metropolitan area network
Erzeugende
Socket
Zustandsdichte
Flächeninhalt
Mereologie
Client
Wort <Informatik>
Gravitationsgesetz
Chatbot
Hilfesystem
Nichtlinearer Operator
Subtraktion
Oval
Extrempunkt
Elektronische Publikation
Menge
Computeranimation
Objekt <Kategorie>
Task
Metropolitan area network
Task
Socket
Reelle Zahl
Code
Heegaard-Zerlegung
Total <Mathematik>
Wort <Informatik>
Socket
Ext-Funktor
Telekommunikation
Iteration
Oval
Computeranimation
Task
Metropolitan area network
Informationsmodellierung
Bildschirmmaske
Task
Abstand
Große Vereinheitlichung
Nichtlinearer Operator
Parametersystem
Prinzip der gleichmäßigen Beschränktheit
Zirkel <Instrument>
Mailing-Liste
Physikalisches System
Elektronische Publikation
Teilbarkeit
Mapping <Computergraphik>
Objekt <Kategorie>
Erzeugende
Diskrete-Elemente-Methode
Rechter Winkel
Socket
Personal Area Network
Informationssystem
Datennetz
Computersicherheit
Fächer <Mathematik>
Mathematisierung
Applet
Einfache Genauigkeit
Physikalisches System
Multitasking
Ereignishorizont
Physikalische Theorie
Computeranimation
Task
Metropolitan area network
Dienst <Informatik>
Task
Geschlecht <Mathematik>
Vorlesung/Konferenz
Garbentheorie
Chatbot
Informationssystem
Dicke
Implementierung
Physikalisches System
Komplex <Algebra>
Computeranimation
Komplexe Ebene
W3C-Standard
Informationsmodellierung
Forcing
Spieltheorie
Trennschärfe <Statistik>
Client
Server
Zusammenhängender Graph
Implementierung
Wort <Informatik>
Programmbibliothek
Computeranimation
Aggregatzustand
Einfach zusammenhängender Raum
Informationsmodellierung
Punkt
Netzbetriebssystem
Zahlenbereich
Inverser Limes
Wort <Informatik>
Physikalisches System
Komplex <Algebra>
Grundraum
Baum <Mathematik>
Auswahlaxiom
Computeranimation
Roboter
Red Hat
Vorlesung/Konferenz
Baum <Mathematik>
Computeranimation

Metadaten

Formale Metadaten

Titel Understanding Non-blocking IO
Serientitel EuroPython 2015
Teil 75
Anzahl der Teile 173
Autor Kapoor, Vaidik
Lizenz CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
DOI 10.5446/20216
Herausgeber EuroPython
Erscheinungsjahr 2015
Sprache Englisch
Produktionsort Bilbao, Euskadi, Spain

Technische Metadaten

Dauer 29:56

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Vaidik Kapoor - Understanding Non-blocking IO As an engineer working on any web stack, you may have heard about Blocking and Non-Blocking IO. You may as well have used any framework or library that supports Non-Blocking IO. After all, they are very useful as you don't want to block execution of other tasks while one task is waiting to complete a network call to another service (like HTTP call to an API or may be a TCP call to your database). Non-Blocking IO while doing tasks and not wait for IO. This also helps us handle a lot many connections than we possibly could with Blocking IO. Python supports Non-Blocking IO, but we always use some existing 3rd party library that hides all the gory details and makes it all look like black magic to the uninitiated. But there is nothing like black magic. This presentation will be an introductory talk focused at explaining how Non-Blocking IO works, which is the basis of libraries like Gevent, Tornado and Twisted. We will learn about how Non-Blocking IO can be implemented using the most basic modules that form the base for the above mentioned libraries. Hopefully after this talk, Non-Blocking IO will not be an unsolved mystery for you anymore.
Schlagwörter EuroPython Conference
EP 2015
EuroPython 2015

Ähnliche Filme

Loading...