RubyConf 2014

Desarrollando aplicaciones Ruby concurrentes

Richard Bishop  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

so I'm Richard bishop i'm here to talk to you about concurrency some of the info concurrency and ruby but what it is what it isn't and hopefully some things you can use in your applications today a little bit more about me I was self-proclaimed

polyglot with a problem I love programming languages I don't know if it's all right to say this every week off but if you're not looking at another language to play with just a bend your mind in different ways you really should there's a lot

of interesting stuff out there right now and a lot of them are dealing with concurrency and interesting ways and that sort of had an impact on me as a rubios and then away from the keyboard I'm a huge coffee and beer nut and it's great but this is

in San Diego because I used to live here we also have the best beer in the world in my opinion so if you're out and you see some local beer try it but don't drink too much because you are at a conference and you want to make a fool out of yourself

and since this is a conference got a shout out to my employer I'm a freelance programmer we are not hiring so for me learning about concurrency was actually an accident I like to call it the other side of RAC most of our time is spent on the app call side

and then completely down the other side you go into web servers and system calls so one night I had this issue with bind to and at the time I'm like what's bind to this looks like a method call I'd have a method called bind i might not even realizing

what a system call was then it kind of went from there down into these patterns that unicorn and all these web servers implement but it's a lot of fun and Ruby's actually a great language for getting your feet wet in concurrency because we have all

the primitives and obviously of course it leaves you wishing you had more and that's sort of the story with Ruby and concurrency but it's a good place to get started so i'm going to talk about today we're going to start with just some concurrency

basics some of you are probably familiar with a lot of this brothers might be new to you it will look at some practical uses of concurrency and Ruby and a lot of the talks actually going to be about abstractions because that's really what concurrency is

all about as I'll explain in a little bit and we're also going to talk about Ruby because it's Ruby cough and it might sound weird but prob about eighty percent of this talk is about concurrency in general and then the other twenty percent is going

to be about that as it sort of relates to Ruby specifically the concurrency is a huge huge topic so i have a not agenda as well a lot of talks that concurrency start off with spawning some threads and then seeing how quickly you can put a million integers

into an array that's not really exciting it's not and however i got me interested in concurrency and that's parallel isn't any way and we'll talk about those differences later i'm not going to bash the gill that gets done a lot it's

here deal with it we're mostly i/o bound anyway and I'm not going to look at a bunch of other run times as rubios we're pretty spoiled we get to run our code I'm like five different runtimes but each one of those could be a talk i'll buy

them sell so why should we care about concurrency so we all know right we've if you've heard of the free lunch is over over in a multi-core world we need to get more out of our hardware as rubios we love forking it's really expensive maybe if you

don't get the server bill every month you don't care but I think we should be getting the most out of our Hardware another one is better user experience if you look at highly concurrent parallel runtimes they're very consistent in their response

times they don't have these crazy 99th percentiles or your long tail Layton sees that are really important like we just you can't just look at the requests per second or the average response time you have to look at the whole picture and the last one

was a huge surprise to me as I learning started to learn more and more about concurrency but you actually see some better design when you design your programs concurrently so let's get into what concurrency is anyway Oh first let's just just get this

out of the way this is George sook here I think he probably thinks that concurrency came from aliens but concurrency is really confusing because just to start it gets confused with something related known as parallel ism but they're actually quite different

but thankfully in the last couple years a good definition his surfaced comes from Rob Pike is one of the creators that go and done a lot of great eunuch stuff so this is what rob has to say about concurrency so he says concurrency is about dealing with lots

of things at once parallelisms about doing lots of things at once that's pretty good definition but if you're like me the first time I saw that now I knew what it wasn't but I didn't I still didn't really know what it was there's not

really any context around it so to look at to make this a little more concrete I think most us our application developers so first to look at parallel ISM if you're on a multi-core computer and you're using threads or lots of processes with several

cores those can actually be all cpu bone up to the number of cores that you have at the same time but the big thing is those are just points of execution there's no sort of communication happening between those things right so in the case of a web server

your your request as a boundary for concurrency I think a good example would be batch processing even on something like MRI you could you know fire up 30 sidekick processors they're not all actually using cpu time at the same time but they are running

concurrently and if you're batching it can be communication with say there's a parent job they can update with failure or success or when they're all done something else can happen there's a lot of communication and there's multiple points

of execution but they're not as nothing to do with time overlap so the reason there's a lot of focus on concurrency right now is that we want the benefits of parallelism but we want it in a clear concise way so what concurrency is really about these

two things composition and communication so it's at the intersection of performance and clarity and that's why there's tons and tons of different models for how to do it so before I really get into the talk while I was working on this presentation

[ ... ]

Nota: se han omitido las otras 3.259 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.