Bestand wählen

High Performance Networking in Python

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
brother condominiums your fellow uncle on the mandates that should help already thank you very
much all I'm not quite the users since I think the 1st by conversion I still I started to use actually was likened to London and once I switched off I can be used since all of or something and there vector so use by the and the quite co-developers things evolved the to you what do we were sure started to to do things even before that you might know me from the gravity successful which I call the with very fast and and pretend it's a inspect history behind all of them I have but I've I read for 9 2 that's a sink away now that we have and like
people 5 animals helping we go and with the standards to maintain a single cells to preview the rule of law and the late structure of the so called I actually wanted to focus the billions so much about how to write high-performance called by prominent in a city
you that with a single in particular but the constant that had to come up with my my slides like like I don't know about 50 per cent of my slides capable and so on will be at the start of a weekly and or you all had a single we then move quickly cholera using K 0 and you will and then will answer or try to answer a question of how you should write a protocol should implement them using sockets or protocols or maybe you should use streams of their presented with something new it's a new high-performance brighter that open source like plausible and then we will recover all I have to say that there will be
old whining cats lights just because performance is hard
so all is said and Prescott cats from all so let's start there should be just 1 obvious way to do it right so we have
5 different ways of reporting them by the first one is to hold its different settings was that actually started in the region in this approach 1 of the 1st major frameworks that these that use that and then the volume that it is possible then without stack with Python and relents and I'm pretty sure everybody for involved here
and less and right but that's a good example of frameworks that that use them ensure the the programs and even like like formal programs of In the kind of like you're using friends but instead but it's it's just 1 from 1 plant and every point of view called connections suspend and resume it's it's a lot of dark magic and as we said it will never be immersed in survive and so all of those days or kind and the role that we have you know and it was possible to
see through the use of generators of that supports environment and since they do it 2 . 5 or something
and that was that the correct called enlightened pullbacks so that you can and that implementation of the American cold using coroutines in we that we could we could do this for years then but people in the you from was introduced at the sink using cable benefits from the uh that's that's called most of the year I seem to hold is written using you from and then invite will by without
a single way that's that's the new ways and why the thing that a single weight is the answer well 1st of all it's a dedicated syntax for coroutines is concise and readable but it's it's easier to actually if you want to work lot large chunk of code and see what's what's actually going on will never confuse coroutines and generators of there is no a new building backwards in such a way the 1st time but history that have been you dedicated
built and I just reporting of also have new concepts the sink or in a single week and I believe this is something
rather unique the of when we had the way a lot of people actually told us what we call the the from shot but yes we computed from the shop but we also introduce new things and ideas this kind of anything for increasing we are kind the unique like I haven't seen any other imperative language that has this this conference on the single which is also a generic concept of a lot of people think that the single we and all only work with the single that's not true actually the single eating away but you can
view entirely new framework and and and use them on your own that that's for instance will be used we've used framework called curious but uses the single even with a different way from colony single always used in the single else's to await our it's past but if you write something like the
Fibonacci cult leader and you will see that the people who run just twice slower than that those financial because you can indeed be single programs you don't have as much the single
weight calls as you have normal function calls it so that you can implement compared like 100 times more so use a single weight as much as possible it won't hurt the performance you won't you won't see any of the Broadway so of course you are a subtype of generators of modern classical like 20 % of that in Python they share the same CC practically all of the share like 99 per cent of the implementation of about a court scene is not be in an instance of the a generated actually and you can you can see this this sharing of the machinery if you if you a for example assembled quality and you will see that it still uses you from our focal and then we have explored the originally we introduce that to but we also style you from carotenes from using compressible with new proteins that use single weights index because you can't just away from things you you can only always from awaitable objects are so you cannot avoid the number 1 and you cannot avoid magenta but if you rock generator you we're that's caught in the corridors you can always actually and again the reason we use this kind of regional interior right if if you are interested in a single weighted differently recommend you to take a look at how they think I was implemented and cultural implemented just to compare different approaches time and then we have a bunch of protocols for releasing iterators and using context that's more a list of all the recent only you cite them and you will so if think I would use the world like we did himself originally I
think a lot of it is inspired with that of and and it's it's it's actually just with that existed for animal 20 years something and the volume that that this concept of a single programming by actually works so I think
we we copied quite a lot these different ways that actually led to the use case and some point when the we might migrate to point they will just use of H encoded with there are a lot of people call these framework well it's not that framework I would I would call it the books actually it doesn't
implement HTTP for instance or any other higher-level protocols it just provides the machinery and maybe for you to develop this this kind of stuff you want http probably would use they which you before that if you want some amount of
gravity you will have full support the standard library which is both good and bad why is it that
I think has sold release of received a new bike and a major
releases so every year and a half and of walking through is usually aura of the couple Europe part of it I would say that were a single so sometimes it's not enough something to discover a box and you want to treat them as soon as possible but you have to meet with the and really side but it's also good because because you can know that they think I will stay with us for a while it will be supported by someone always because it's a part of the library and also by has a huge network of of walls with different architectures and different operating systems and it's quite important action best something as a symbol that hard as i all and only on different platforms to using goes it questionable right now and will be even more stable bridge so so what's inside a thinking so we can
standardized and pluggable eventful uh actually facing from the beginning was it was in the region in a way that you can use all of the you and implementation was something different because the defiance of tropical center transparency and that's 1 way to actually Mary Colbert style programming and and a single we used actually develop protocols using low-level primitives such as protocols it also has factories or servers and connections and streams and this is also quite important because if you implement the server let's say using using what constructed so that you
don't want the money for it and the 2nd time you will see that you have lots and lots of boilerplate called the continents the same every time so a single takes care of that and factors all-pole this implementation and community elders for creating servers and creating connections we also define features and costs costs
are passed past and something that actually runs the quality and that's just the volume in the quality that suspend them and we use them you framework independently of the courts and rubber
bullets and run the actually are in futures features always include all of to interface with callbacks of that that's how you actually introduced the single wave into something that is called but also as interfaces were creating a something and communicating with subprocesses a synchronously
assist use and by the way q is to use a very useful class you should you should definitely you that's exceptionally hard to freedom a synchronous cue that supports constellations of all this stuff like
that development of blocks like we were still speaks a lot of what you want in 3 . 5 2 2 so what is a useful for things like connection with the that material and also have walks events of some of course everything like that everything that everybody nobody knows the user actually and as the longer sentences spoken like the last couple of months ago you you if you want to lock you can still have the amazing thing so is the
foundation the engine that actually writes that actually of execute the syntactical call it also a little surprised factories for past future false and I will multiplexer that the engine that actually reason the use of the the wire it provides PPI for a low-level EPI for scheduling all that's for stealing time went out for
working with processes and handling units of the signals and the best part about it is that you can replace so that's what we had to with you you look is 99
. 9 per cent combined with the single I not aware of any incompatibilities but maybe there are some of this far as I know you can drop in you can pretty much the problem and people just work it through the and whether 1 2nd is just amazing thing it's it's unfortunate that it's
not as widespread and I think it's it's kind of under appreciated what you can do inside from essentially a superset of Python language you can use you you type and B will compile c and you will have to be you you you you can easily achieved with into forces applied so that mystical quite ineffective site and and try to use of you will be useful immediately beauty is something that keeps small just writing actually know
just use we will only be as you want and actually good thing because not just super widespread and it's it's very very well test so we believe stable and it's part it also provides plethora of past and future so you Europe's all we call runs faster on union of
about 30 per cent and it's also thanks to review the interview box
uh it's superfluid have super fast so
how does this yield well compared to the sun goes to times faster than simple benchmarks like that so again nobody nobody probably deploys and servers in real life so as soon as you add more and more quite cold because of course it will become smaller but again in in in real applications like single words that that you from school about therapists and faster and also the latency distribution is much better you will well so
it's faster than the single of all other platforms and frameworks for instance the same at server also written in Python that users and which is you will use 2 times faster than GSM can be interesting because small GS is itself written mostly in view that the Johnston implementation of it usefully be which is written in C and there is a thin layer adjusted on top of it so still you could use the same with the students faster for the
same holds was the same amount of gold that is as fast as goal of wrongly of of next month mark thanks to the the will accept the 1 that essentially means people can cannot paralyze in multiple CPU but still it's it's it's quite an impressive impressive result because always is like before we compiled language and itself it's also has I think it more efficient implementation of IT all of them then we just because we believe the strength and generic it supports Windows that supports supports units long supported to look in slightly different ways anyway look then the cost it's much
faster than we from from from just because of the if you have a lot a lot of different things like most of you so usually my idea for a
for the sport was put in this slide just using the will of the people died questions but unfortunately unfortunately it's
not that easy so party but football soccer streams and protocols that's this 1 obvious way to do it is to so what should you
choose to the use of words like stock symbols received of tokamak or should you use fallible streaming API or maybe you should use lower a low-level protocols and transfers of curious connected server implemented with little stop methods and if you a little bit also you will see that if you can draw the sink and a way here the words it looks like like a normal looking cold water that uses of the psychic module and so on it is kind a convenient when you have lots and lots of cold and also that cold walking cold but you can kind that easily little converted to a single weight here streams there is the version of the server but it's it's it's quite a quite high level as you see you don't you don't work with sockets anymore because the reader and writer and furious level implementation of aggressive using protocols so essentially probable is something that can be given just just to be the mean and protocol the transferred to push that the the back to the client or the server so the key method here is the the that that's like the main man but even the event will ensure that the that would be the received them political can process the data and then called transfer book the chosen to approximately the sentence and response back to the core of our foreign conservative
so is quite a simple implementation but you can imagine it gets pretty scary for for more complex problem so that means that when you use low-level
that sort the methods will cannot buffer points so you were responsible to to implement the buffering and top and you also have no control which would also buffers doesn't make any sense to you know his whole control but when you start to implement the buffers you will have and ask whether we can think to to implement correctly and then another thing which is why you shouldn't use it is just because the event has no idea what you're doing right now let's say you were reading from data OK so that when people will spend your file
descriptors through collector which can be people or take you a on on on on Unix on and essentially wait for a for a branch-and-bound went to receive the so when people try to read data because of the vector but it will also remove the file descriptor from the selected that connects the system called but because it doesn't hold we continue reading the data or you you know you write that the the need stop overview of the whole of the connection so it cannot predict what was going on when the news streams and streams are but we used our our using
protocols event just more because you you haven't then just keep sending and the way they received or too much freedom and when I don't need this they have the connection myself so you want to go back optimize for that and full control of standing
on the back of a like each of those traits that sometimes it can be kind of that is that something small
or something that you don't want to use the a break so we should be I should use you should use the
looks of methods when when Europe with people that something or when you are according to some existing cold but I would highly recommend the ritualistic strings even of for reporting cold just rewrite the constraints because things are much easier to use you can just see you mean exactly this amount of data on the Gulf streams we until you see flesh and or something like that and will also implements a buffer of reason right offers quite quite efficiently and you can use a single weight problem the prior protocols with creams but then use probable and prosperity working formants actually but you want exceptional
performance incredible incredible and so of this school let's 4 let's focus on political from transport and begin again this the standard word Europe publication called you should always use the single would never even touched never think about profits transposon protocols this stuff is just for right drivers for progress field for for member radius for any kind of of this kind of high-level courts would never think about protocols always used a single weight if you will be enough so let's look at a problem so as mentioned
before or which is available probable probable they been using transparent and protocols can implement specialized read and write buffers and they can also for control you begin to change the rental or through the transfer of the resume and calls read methods of and you have full control over how I was performed you you hold transferable tried you can post war resumed their consumption so you can of difficult to control the so how to use political processes of rock basically 2 strategist the first one is you implement your own obstructions your own buffering buffering uh and your own stream of search and a and a good example of that is issued the that's that's what they do they can have buffers and stream specifically designed to handle forest http protocol and then they they just use the single which arises affine approach will be slower than using a and then using called weights and then accelerating everything and see but but it's it's quite quite good so quite so the 2nd strategy is to actually implement the whole political passing you know in coal up and then create created for state that following the rules facing the away and the main human reason why
this way this is a better so than what might be the strategy and why this can offer better performance is because you can just drop by complete you can you can always you can use the site and you can use the soul of course the same gene and this is something that I just source couple Ausubel all this is right now the office forces killed rather a single input light and actually
it's 2 times faster than psychology is completely re-implemented the protocol from ground up doesn't use sleep PQ that's the library for for working with will killed after just implemented a completely come from scratch it uses polymerase of either the woman by the way when you are implementing protocol and you have a choice of this text or binary always true binary it's easier to read viruses usually just Leslie because encoding is more efficient and you can put as much faster you can uh because both binary form of words usually have a length field that building call on much the of calls this frame and then you have a lot wanting to meet friends much
faster and equal bags much faster so always choose binary and also not all all these types can can be encoded
in text and it should be equal to the next so of small so compass that's for instance if you have a recursive company that which is not
possible to hold it in and take so what what we need for a single dimension we forgot about the media completely there no DB API for a single we look for and what you can see that the can
sprinkle using the weight of of of of existing DPI so already there was let's look the driver than just use favorite were both instance uses progress features and we also support goal of mutant but of course this types but there is a so for this loss prepared statements of use it and if you if it doesn't need to actually watch distinctly all will begin when you prepare statement that has some structure on the server with a plan with forest clearing and progress for intervals of toxic products and then under the current stop so we use proper students every time even when you don't explicitly freedom we have and where you catch of all prepared statements and with the transport before you will also dynamically new pipelines work it recently encoding and decoding decoding data so that the pipeline is essentially an array of
pointers C functions that important parts of the screen like the norms and so on and it is actually souls of this chart compares different
progress drivers for different languages in the past as long as there is in the manager's will show almost 900 thousand of queries of them to the server the 2nd 1 is able to g that some of the of the of the of the users would be became which is also is written in C but unfortunately psychic doesn't doesn't provide an efficient interface so so it's more and also the sinkage you could G and a psychic injury the spectral from text there including so but always with the support of the then you will see the 2 implementations and then you will see no G as drivers of which are just sometimes and fight what about this 1 is that images produces them actually fewer jousted implementation of the driver and you native is usually pictures so somehow a lot of jobs to foster than events you have no idea how the funny thing about this performance is that there is another library it's not part of this job because this is kind of slow it's called like was were still nobody knows about it
we use this for several years and then we just the relation included anyways it's a pure Python implementation and it's as fast as a pure adjusted the communication so everybody is is saying that by controlling ingeles conditions you should you should use it but of we kind of that it's possible to to write your Python called them as fast as well called so that maybe the mechanism that sold so I using architecture of large basically implemented in the other implemented
corporal corporal is something with an insightful it uses called to process the the protocol them of political class that just wraps up a protocol and of sort some future objects in the so that you can use a single weight and the rest of is just pure Python implementation of that I just implement the cattle because PPI so out of the poorest parts of the progress protocol naive approach would be just to use Python bytes of memory use but unfortunately that doing so will cause will cause a lot of quite promoted to be creative and you will you will actually see how how long you spend memory of number electricians so the solution is to use I come and go over to the C C C back and and and just don't even touch by but bytes and the number of years so this is a preview read buffets it's it's a bit bigger than this the it's it's a we can see you know that the 1st method is most important if you data that's what protocol they received actually holes probably the receiver has just landed the first one consists of a ring buffer and the 2nd 1 falls apart from that just means from the box and this box kind of the way work progress protocol have low level we encourage to in and the 2nd most important a whole series of private bytes private invites you the returning view on the level of the CC of of the of the of that working with President monopoly there and if it with mouse pointer then you actually all read we should review by commodity which is much lower but most of the dimension and person that very succeed and we can we can all with creating a new python object so on but again fellow logical facing injuries you compute by from that is how we can actually use it or you can see if it's pretty high level of dialog with the the statement we temporal transactions with each and we have and we iterate over a scrollable cursors parts like this got so don't be afraid of protocols and use them to implement really really high-performance and used by the you cite for a little while it's really much easier to hold inside and then it's even more quickly
refractory called completely changed everything and will just work on the single which should always be used in your application people don't think about probable from
prosper using only kind
and again once you have passed that various members there is stuff like that and you use you will you will see that you will see a replication being much much faster up look great user was introduced by the 3 . 5 . 2 actually that's a new feature with this if you use
if you create future that you can actually inject prosecution implementation in because you implement its own version of the future and it's about 30 per cent faster of them them I see that all the future always used by the
protocols never never even tried to learn the parts that were articles
about doesn't make any sense if you if you got the binary worldwide always properly called is actually quite because when I went extinct actually started work I benchmarked against the energy 2 dice and I don't understand why this should be fostered like because there's no way you can forward
1st and about 3 hours of sleep optimizing this complaints faster up for system so the important lesson from this is that if the 1st round of shows that these include you would like to represent faster than it is in the more maybe I wouldn't spend so much time trying to optimize so always profile of always underlies the demonstrated to the use of forward and by the way 2nd called in the profile right and you can visualize results and take
advantage the useful tool to get and 2nd has useful flag what's called best of it generates the stimulus presentation of the source file and each line is but it's either blank or it's in the shade of yellow and the most the alliance use more by Python CPI and it useful so basically you have a quick way of analyzing your 2nd call but it's it's it's
so that musical there always residues Eurocorpus tried to all who were working with bytes memory use of a little this
kind of stuff side and and and don't Python objects never and the 1 of the last devices actually used to implement an efficient buffer to write the exam for instance for eating G what you were writing messages with have right buffer that just reality it's proportional memory and then can messages in with that API and we think don't touch the memory of and when the message is ready to send it to have a higher level at the end of reading the message of allocate any memory while
they're doing so so when you look at this this this this this control you use so that was the city itself to be an orderly that we probably will set up by the fold increase encoding but people and 6 right column it's not that you should do it because it will speed up profits right method uh basically of we this flag set in the sockets psychic doesn't doesn't wait until it receives the TCP messages just since the latest thing you if you unit but if you have if you don't have control over all how frequently you're going to transfer the price you can basically use TCP port what would you do
you for the channel then you do multiple rights with then you on working and just sense all you all you that you as you UTC people pockets of responsible and the last slide is timeouts always implement mouth this part of i don't asking users to use you seem to be a single we work because the forest for the approximate 14 in the past and and that that that comes from the huge penalty recall we will become very % of
those work if you use a week or so uh divided by mouth this part of the API at the lower level implement them off with of all books local method that will just work that said they were there you know soon think we have pushed time for maybe 1 or 2 questions my my my to into from new institution and have I want plus you about that you seen as seen your and you be you you you and you and not for high performance that followed by conclusions see you have you need any help me do you see full high concurrency occurrences and this scenario we found candidates of sounds and so concluding connections that if you look at that and therefore that because it uses less memory than you think they'll of know he you what you look you look as much there for a highly concurrent obligations of candles like hundreds of connections single because it uses less memory of the instances of the egg and possibly with that that with the 100 and connections to the candles that's pretty pretty pretty thank you nodes and porcelain as all time and that didn't
Schreiben <Datenverarbeitung>
GSM-Software-Management AG
Gerichteter Graph
Fahne <Mathematik>
Profil <Aerodynamik>
Generator <Informatik>
Einheit <Mathematik>
Computerunterstützte Übersetzung
Lesen <Datenverarbeitung>
Demoszene <Programmierung>
Reelle Zahl
Endogene Variable
Primitive <Informatik>
Spezifisches Volumen
Generator <Informatik>
Architektur <Informatik>
Anwendungsspezifischer Prozessor
Wort <Informatik>
Faktor <Algebra>
Bridge <Kommunikationstechnik>
Streaming <Kommunikationstechnik>
Prozess <Physik>
Familie <Mathematik>
Befehl <Informatik>
Lineares Funktional
Arithmetisches Mittel
Framework <Informatik>
Automatische Indexierung
Web Site
Zellularer Automat
ROM <Informatik>
Puffer <Netzplantechnik>
Bildgebendes Verfahren
Einfach zusammenhängender Raum
Wald <Graphentheorie>
Physikalisches System
Objekt <Kategorie>
Innerer Punkt
Offene Menge
Umsetzung <Informatik>
Bridge <Kommunikationstechnik>
Gesetz <Physik>
Streaming <Kommunikationstechnik>
Protokoll <Datenverarbeitungssystem>
Metropolitan area network
Befehl <Informatik>
Zirkel <Instrument>
Güte der Anpassung
Gebäude <Mathematik>
Kontextbezogenes System
Rechter Winkel
Lesen <Datenverarbeitung>
Mathematische Logik
Klasse <Mathematik>
Automatische Handlungsplanung
Arithmetische Folge
Protokoll <Datenverarbeitungssystem>
Elektronische Publikation
Overhead <Kommunikationstechnik>
Konfiguration <Informatik>
Formale Sprache
Kartesische Koordinaten
Strategisches Spiel
Einheit <Mathematik>
Prozess <Informatik>
Algorithmische Programmierung
Klassische Physik
Funktion <Mathematik>
Strategisches Spiel
Gewicht <Mathematik>
Kombinatorische Gruppentheorie
Framework <Informatik>
Zeiger <Informatik>
Einfache Genauigkeit
Keller <Informatik>
Puffer <Netzplantechnik>


Formale Metadaten

Titel High Performance Networking in Python
Serientitel EuroPython 2016
Teil 27
Anzahl der Teile 169
Autor Selivanov, Yury
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/21244
Herausgeber EuroPython
Erscheinungsjahr 2016
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Yury Selivanov - High Performance Networking in Python The talk will cover new async/await syntax in Python, asyncio library and ecosystem around it, and ways to use them for creating high performance servers. It will explain how to build custom event loops for asyncio, with an example of using the libuv library with Cython to achieve 2-3x performance boost over vanilla asyncio. ----- The talk will start with an overview of async/await syntax introduced with PEP 492 in Python 3.5. We'll go through asynchronous context managers and iteration protocols it introduces. I'll briefly explain how the feature is implemented in CPython core. Then we'll explore asyncio design. I'll briefly cover event loop, policies, transports, protocols and streams abstractions. I'll explain that event loops are pluggable, which really makes asyncio a universal framework. We'll cover libuv - a high performance networking library that drives NodeJS. I'll highlight where it's similar to asyncio and how it's different. In the final part of the talk I'll explain how to make an asyncio compatible event loop on top of libuv. I'll showcase Cython, which is an amazing tool for tasks like this. Finally, I'll share some ideas on how we can further improve the performance of asyncio and networking in Python, and what are the challenges that we will face. **Objectives:** 1. Deeper understanding of async/await in Python and why it's important. 2. Deeper understanding of asyncio architecture and protocols. 3. How to improve asyncio performance by implementing custom event loops. 4. Show that it's easy to integrate existing complex & low level libraries with Cython. 5. Some perspective on how Python may evolve wrt networking.

Ähnliche Filme