00:00:17.279
everyone have a seat because there's one thing I despise in this talk it's inefficient use of
00:00:23.960
resources i' like to see there's one here
00:00:31.800
there is one wherever okay Chris there's not one here I
00:00:40.640
lied there's a couple of bags over there that are looking very comfortable all right um I I I asked a couple times um
00:00:49.800
why why at this conference the rubby conf pH there only rubinus and uh and J Ruby t-shirts and there's no yav T-shirt
00:00:58.039
um this is this is the talk about why there's no t-shirts
00:01:09.960
for all right someone in your business cares about money um I'm not going to assume it's
00:01:16.840
you but someone does and as they go about spending that money they think about uh uh sorry I should um that's me
00:01:25.079
just in case You' looked at the slide and wondered the relationship between that name and me um and uh
00:01:30.799
and you're going to spend it in various different ways if I had more space I'd add soft drink
00:01:36.799
um but primarily it's a new stuff uh keeping the stuff running and uh and uh
00:01:42.880
sorry the so the people for keeping it running and the cost of of uh you know power and uh and floor space um even in
00:01:49.719
cloud computing there's still power and floor space it's just you you can get that from an API like hideen need a new
00:01:55.880
meter of floor space please um that's cloud computing and and uh and so then
00:02:01.200
you know so I thought I need to visualize this because you know that last slide was a bit dense so here's two
00:02:06.920
ways to visualize it one is uh fun things and uh and not fun
00:02:12.760
things that's uh that's how I look at it um and so my my core thinking in
00:02:19.519
everything is is how can I not have to spend any money time or thought on on on the nonf fun things now so we we had uh
00:02:27.160
there's a seat here actually right at the front if anyone wants to sit in it um no
00:02:34.040
okay you can see this just come back here you can see the slides and watch
00:02:39.879
everyone's hilarious reactions to you I uh uh so okay so my core thinking
00:02:47.840
is is that how much of that that nonf fun optimizing performance stuff can I get without spending uh thought effort
00:02:55.760
or or money on because to me um I don't whenever have to type the letters
00:03:01.200
thread. new um because I don't know what happens uh when I do that um and uh nor
00:03:08.599
do I really want to have have to do that um because it doesn't fit on the
00:03:18.280
slide uh and nor do I ever want have to do that because it's
00:03:25.519
um I have no idea what that does all I ever wanted to do was just to
00:03:31.239
write code and uh and it got it actually became a bit of a problem for me because I have a job at engine yard where we U
00:03:38.560
well we look after your app and we want to help you make the right choices we want to invest in Technologies they're going to be good for you and I didn't
00:03:45.360
understand I mean so I came to America this is the country we're in and um I
00:03:51.120
don't want to leave out any I don't want to leave anything implicit in this talk very explicit and I know we're in the
00:03:58.280
South and it gets a bit you know question which um all y all what's
00:04:03.720
that that's not that's no real phrase um so so I it got it got kind of really
00:04:11.400
bad and um I was lucky because on payroll is uh the guys that do reinius
00:04:16.479
who are incredibly clever the guys that J Ruby who are Inc incredibly clever and uh and they tolerate me asking them
00:04:22.759
stupid questions in in exchange for being paid and
00:04:30.400
and that's a system that works really well uh but not everyone that knew Inc
00:04:36.360
incredibly intelligent things worked for me so I had to um con them into coming and telling me more stuff so I came up
00:04:42.440
with this idea of of what was at the time called em Ruby comp or vent machine Ruby comp really a better name might
00:04:48.360
have been concurrency Ruby com uh the uh unfortunately um that was I I don't look
00:04:55.199
I don't have a joke I going to take a moment if anyone's got a joke there uh to give me
00:05:01.840
I will use it no all right so it it was called Ruby com it really is a currency com and uh and we flew actually flew a
00:05:09.440
couple people in who were not otherwise going to be rubby conf a couple of people who couldn't come uh due to the relative late notice of me coming up
00:05:16.160
with this idea uh did were very gracious and wrote screencasts and it was really good I think we had 50 people in the in
00:05:21.479
the the breakout room it was packed and it was really valuable and if you go to the website which is em rub. something
00:05:26.960
or other uh you will find most of the content so when it came to uh to to to getting
00:05:32.720
more performance I figured this I had these options now how do those options
00:05:38.080
work well if you're on app Cloud you press that button uh yeah I mean I thought it's
00:05:43.840
worth pointing out that's it that's and if you do that you get uh you get one of those and you spend some money press it
00:05:49.479
some more times and you can spend more money um if I'd shown this to some of
00:05:55.680
the business people they might have asked me to make the dollar signs smaller
00:06:01.360
but uh I think um you know the point is valid all I want to do is write code and
00:06:06.800
I wanted to give so from everything I learned and that includes I started reading research papers um which was
00:06:12.759
tremendous reminder of why I never went back to Academia um and it's uh I think
00:06:20.240
unrelated to anything so and I went back and looked some of the slides from the presentations they did and for all the
00:06:26.639
great things we got out of Ruby on Rails one of the things we never really thanked David for uh was for his style
00:06:31.680
of slides which were quite Innovative to me at the time and and if you ever want to
00:06:37.160
go back and look at academic slides they they break every rule that was thus conceived about how not to do slides um
00:06:44.000
how not to do PowerPoint they're they're very dense and anyway um and so what I I came up with I thought it's the most
00:06:49.919
important thing I could do is to not tell you everything the most important thing I could do is to tell you one
00:06:54.960
thing about five times uh I don't want you to go away
00:07:00.319
wondering what the point was I don't want you wondering you know I don't want you going away thinking well maybe I
00:07:07.199
don't want you going away wondering if the conference was valuable I think the message here is perhaps the the the the
00:07:14.720
magic of this this conference if you get this and the t-shirts hopefully convey this all right if you're not sure the
00:07:22.240
the the let the t-shirts communicate to you let uh let this talk convey to you if I think this possibly could be the
00:07:29.039
money's worth worth of of the conference if you just do this stuff this one thing
00:07:34.160
um and and if you don't think it's worth it hopefully you went to some other
00:07:39.960
sessions um so I'm going to go through this and I'm going to go through this if uh from a web perspective um I'm going
00:07:46.159
to talk about these three things the webout being the bit that you do the other two things being things you don't
00:07:51.599
have to do and that's my favorite part finding things that I don't have to do that are done for me all right quick
00:07:58.080
definition event programming it moves IO around now I'd like to use the
00:08:04.199
word no I can't remember the word anymore that's the problem you put in the
00:08:10.360
slide you can't make a joke about why you didn't use that word anymore because you forget there's a orchestrate that's
00:08:17.960
the word I want to use um Advantage about orchestrating IO the problem is if you use the word orchestrated uh you
00:08:23.800
have to use a smaller font that's out
00:08:30.000
I go by the Shane Becker system of slides and there big fonts black and white you can pay him $12 to learn that
00:08:36.560
message and I think it's valuable one point all right what about
00:08:44.440
threads what's the point of threads or what are threads they're for doing work um and what do you do you write code
00:08:50.800
okay some good definitions there I will use them heavily okay so this is what we're going to shoot for we're going to
00:08:56.240
do vented first they're going to wrap the your code in and attraction using threads that's what I'm going to talk
00:09:02.000
about and when we do that for web apps you're going to find that really there's never for 90% of cases this is actually
00:09:08.920
a really good solution for you so what we want to do is use resources better I mean we still want to
00:09:15.680
pay engineered money that's important but I'd like to see you using
00:09:21.320
your resources better so let's talk about what our options are for concurrency process concurrency which is what we're all using for predominantly
00:09:27.040
now threaded concurrency which is predominantly not using um because we love yav and and we were told we're not
00:09:34.480
allowed to do threaded concurrency um and evented concurrency because um because that's cool
00:09:41.320
apparently we don't know what it's for God damn we're going to use it for everything so first I want to break it
00:09:47.600
out into the two uh two two sort of comparable ones process versus threaded if you haven't seen this sort of comparisons before uh fundamentally in
00:09:54.880
process concurrency you get one request per process and you look it might be depending on the size if of the memory
00:10:00.360
blo 50 to 150 Meg therefore if you want to have 100 100 simultaneous requests
00:10:05.880
you need to make sure you've got 15 gig worth of memory lying around uh it's the
00:10:11.399
kernel that does all the work and if you want process concurrency um because um I
00:10:17.360
don't know you sell memory um um then uh then a couple of web
00:10:24.360
Stacks you might pick a unicorn passenger which uh which manage Ruby processes for for you if you want thread
00:10:30.360
concurrency what you get is that uh you know I mean two I've said two 2 kilobytes it depends on the size of your
00:10:36.480
stack uh and and the ReUse but uh it's it's a it's a relative number uh comparable to 150 Meg so every thread is
00:10:44.839
Trivial so now you've got relatively flat size of uh of your process and you
00:10:50.839
know you're no longer bound by memory on that machine going to be bound by something else that's okay that's what
00:10:56.880
we're looking for we want performance we want to get the the the the you know those edges of performance still you know in a in a kernel based uh sorry in
00:11:03.920
a native thread-based Ruby implantation uh you're going to be uh it's going to be orchestrated by the colonel and uh
00:11:09.959
and Mongrel is a threaded uh adapter a threaded web server all right so this is
00:11:15.720
the core message there that threads are really really cheap and this is a gratuitous logo telling you who the
00:11:21.399
winner
00:11:27.440
is um you may use that logo uh at your leisure so this is the point you're
00:11:33.959
going to wrap your code in Threads and we're going to move uh any uh fast aventage stuff that we need to do to the
00:11:39.279
front of the request queue you and this idea is a useful abstraction that we want to go to all
00:11:45.399
right now first I want to educate you on something anyone knows sign language what does this stand for WF
00:11:56.000
WTF I think if you're going to be rude you should to do it with three fing three the thing is you can't you have to
00:12:01.839
do that with a friend so I hope you both agree um and
00:12:11.040
uh so the question was uh what's what's all this about because anyone's um U
00:12:16.360
used to run apps on on mongrol the last thing we got out of that was concurrency uh they invented a thing
00:12:22.760
called mongr cluster and uh because that was so annoying they eventually you know people invented a unicorn passenger all
00:12:28.880
sorts of things to work around this the core root problem of process concurrency um so why would I do that um
00:12:35.399
specifically you are going to ask that question uh not probably all at the same time though if I put a slide up I reckon
00:12:41.720
we have a red hot chance of you all doing it um so why is it threaded or just a quick proof of it's threaded uh
00:12:48.399
there's the use of the of thread. new uh and that's the extent of my
00:12:56.519
proof what what what do you want math um I'm going to attempt to give you this information and communicate this without
00:13:03.399
actually showing you uh uh one Benchmark or I think I have two graphs um because
00:13:09.720
they're pretty um and colorful benchmarks are not um so okay so here's
00:13:14.959
some concurrency mathematics brought to you by me um essentially if you multiply
00:13:20.160
these things together and all of them are true you can have thread concurrency if any of them are false you're not
00:13:26.000
allowed to have thre concurrency and and you get to to spend lots of money on memory which people
00:13:31.480
will tell you is cheap um but that's that's that's a big fat lie it's expensive and uh and there's no reason
00:13:37.600
to be bound by memory and have to pay for it all right so we've talked about mongrol and I'll come back to mongr uh
00:13:43.639
and and and its future uh later on so the problem is in 2006 whilst mongrol may have been thread safe nothing else
00:13:50.120
was or nothing else supported threads and uh fortunately to uh 2008 the first effort was put into to try finally
00:13:57.240
making rails uh thread safe and that was um widely
00:14:05.480
ignored um lifeo wrote a post about it and and he you know he was very excited
00:14:10.800
as as anyone that cares about this stuff uh should be excited the um and it's a a
00:14:16.120
you know you'll be a to there's no reference to it it's irrelevant but it's it's a it's a good post and uh and all
00:14:21.279
he said was that um in order to get thread safety you just uncomment this line that's it talk over let's go
00:14:31.800
back um now forat you have to do something slightly more complex you have to add this
00:14:40.040
line um spelling is important um and uh put that at the top of your
00:14:47.759
program and I think it works after that so okay so uh okay so you know so we
00:14:53.000
ticking along 2008 our maths are getting better we're getting closer to to having sort of out of the box thread
00:14:58.320
concurrency um okay so then in 2010 sorry yeah that's the right number then uh we got
00:15:04.600
the first production release of of 192 very exciting times uh it has native threads in it which is the good thread
00:15:12.040
that's what threads are that's where you let the that's where you let lus do the work for you all right that's how I like to put
00:15:18.759
it mattz wrote Ruby lonus did everything
00:15:24.079
else all right lonus is really really clever as his mats let's let him do some
00:15:29.240
of this work all right so that's we'll call them Linus threads and
00:15:36.639
um um unfortunately sad face is um there's an odd um concept embedded in
00:15:43.079
the core development practice of of MRI or yav both of them is uh whilst you can
00:15:48.560
have as many threads as you like only one of them could do the thing we want to do the most of which is run Ruby
00:15:56.440
code which is an odd feature
00:16:01.800
um but a selling point um you might hear that referred to as as the global interpret lock with a sad face
00:16:09.639
um uh so that's how you spell that and I I like to call it the grumpy Gill um because of the sad face and uh
00:16:18.440
so okay so here's as of 2010 uh thread mathematics uh not looking so good but
00:16:24.839
uh this year 193 was released it's very exciting sad face still has the
00:16:30.319
Gill um so I we were at Ruby conf and and and Matt is here Matt amonti is doing a talk later on today about the
00:16:36.079
GBS
00:16:42.880
question no fine I'll change my slides I mean they
00:16:55.480
U all right thanks Eric um
00:17:00.959
so okay so once fr the time blah blah blah that changes all right take note um actually I didn't get the correct
00:17:06.919
spelling nonetheless that would have to come up with a new name for it um and 103 came out still got the Gill so Matt
00:17:14.079
Amon is going to do a talk and the question that he's asked me to ask out loud in a very um prepared manner is
00:17:21.520
Matt why don't they remove the Gill to which he will answer it's just too hard
00:17:28.199
and whilst you could do it it it's the implications on the C extensions and blah blah blah blah blah who cares fix
00:17:34.360
it yada yada yada come on grow
00:17:39.720
up uh so that's uh that's that's that's that's reality so we got Mongol thread
00:17:44.919
rails a thread so but no threads and um bring a friend and communicate that
00:17:51.880
um so you're now convinced you like threads all right you're convinced I I
00:17:58.480
appreciate that U here are your two Ruby implantation options at the moment uh the rubinus master branch which is the
00:18:04.000
2.0 coming later on J Ruby's uh stable in production uh use by lots of people there are your two options and uh today
00:18:11.360
You' probably pick J Ruby um the challenge is you're thinking J Ruby that's got more letters in its name
00:18:19.360
um that sounds awkward and uh and um that's that's if you want to take some
00:18:24.600
notes uh that's how you that's how you get a j Ruby based rails app as of rails 3 uh if you're using J Ruby the base
00:18:32.159
rails app is actually ready for J Ruby which is very cool it has these lines in it so you don't have to remember those
00:18:38.760
in fact I can't so whenever I need to Port those lines across to another app to make it work on J Ruby I actually
00:18:44.320
going to create a new rails app and copy the lines out so thread mathematics yay oh by the
00:18:52.200
way the thread safety um logo is gratuitous laziness on my behalf um
00:18:58.039
because it's not really clickable I mean J Ruby is not thread safe it's it's got threads um the the symbol comes from the
00:19:04.520
rails plugins website and I thought that's good enough let's move
00:19:10.520
on um so we want threads and why do we want threads because it doesn't use any memory and we can be performant bound by
00:19:16.720
something else um you might still say that still sounds so hard I mean I don't know how my current thing works it just
00:19:23.039
does leave me alone Nicholas um I want to go to the other talk except I can't get out of the room without looking silly um
00:19:29.440
so let me help answer some more questions how do I actually run J rubyan rails because I'm guessing it's different from whatever I'm doing at the
00:19:35.120
moment which I don't really understand but I'm probably not going to understand the answer to this question either you use Trinidad uh there are a bunch of
00:19:41.679
ways to run J Ruby and and my point isn't to tell you about the mod point is to tell you about the simplest best
00:19:47.200
combination one that you can go away today and enjoy the benefits of of all
00:19:52.440
this technology once you get really clever and and it's your turn to talk you can talk about the others
00:19:59.960
um my goal here isn't to be clever it's to be funny and and to tell you something you know
00:20:07.760
the what's the next step you can take to get a you know a substantial portion of these benefits and so have next barrage
00:20:14.480
of text is going to tell you how to use it yeah outside so you do that inside your rails
00:20:21.280
app and uh and you're good to go you might be thinking it can't be that easy I need a demonstration app there it is
00:20:28.120
uh we had to we just have a to-do app which is kind of nice uh you run it under J Ruby and it just works
00:20:35.200
um I don't know I mean what else do you want me to do what else needs to happen before you just go fine I'll use J Ruby
00:20:42.039
godamn it but don't tell
00:20:50.400
anyone all right now by default still for some reason in fact I don't know Aaron if you could tell me why um even
00:20:57.480
you know why we can't just leave this uh turned off by fault but currently that is you go into production. I you'll
00:21:03.520
uncomment that um but if it's commented or in development mode you'll see a little message about number of run times
00:21:09.760
that sort of it maxes out in terms of J Ruby run times within the uh the jvm process uh what you want to do is um is
00:21:16.559
uncomment that and put hash yes at the
00:21:22.840
end um again font sizes being a limiting factor I would have said booah
00:21:29.240
but I couldn't afford the extra two characters uh we're under time pressure here um oh yeah sorry what else so then
00:21:34.799
you get the just the one J Ruby run time within the jvm uh by default the thread limit is 200 it's configurable um if you
00:21:42.320
find out what what it works best for you but 200 you just fine and you might be saying now that was easy woohoo good
00:21:49.520
let's go I mean what do you want me to do come around all your laptops and install it
00:21:55.320
manually we form a que at the front of the line feel sorry for the next speaker what are all they doing they're having
00:22:01.760
Dr Nick still triner dad get a free candy or something all
00:22:08.799
right so that's what you get you get the the memory is no longer the pr band you don't need to buy gazillions of
00:22:14.799
resources and Ruby is no longer this expensive Beast of a thing that annoys the crap out of you um for everything
00:22:21.279
else except what's in your text editor um and so um the best part of all this
00:22:27.039
is that that it's just you didn't do anything different it's your code so I mean okay you might pick some different
00:22:33.440
gems you're probably going to have to remove some of that Ruby inline stuff that you thought this will make my code
00:22:38.640
faster um and uh so you'll have to you know depending on on how far down your project is but uh D Ruby has got 18
00:22:45.960
support One n support as does rinus so you know you can uh take whatever your legacy app which I mean effectively
00:22:52.679
every everyone's code is is Legacy now unless you're working on it like
00:22:57.919
that guy um way to keep current
00:23:05.520
um not at all offended uh that he's doing that no so um but that I mean the
00:23:11.640
fact that it's the same run time you get the same benefits uh but you can pick which language set you want is uh is great because it doesn't mean you have
00:23:17.200
to upgrade your code in order to use a new runtime like we have to do with 192 we want a jav we had to go to one 19
00:23:22.679
syntax sort of was was a limiting factor there so uh this is the part we're up to
00:23:27.880
you still get to write your code but it's wrapped up in an abstraction of threads that you don't have to worry about I love that I mean every day that
00:23:35.559
I don't type thread. new is a is a day that my app might work um and I like guarantees like that
00:23:42.720
so um and I mean and if you're not doing if the problem space you're in is uh is not web apps then a couple of things are
00:23:48.960
going to change in your life you might need to start caring about State synchronization but we'll talk about that and obviously Trinidad isn't
00:23:55.039
necessarily going to be uh cuz it's a web stack concept but but the premise is the same you want an abstraction for
00:24:01.159
your threading um earlier on Mike Perman talk about uh Celluloid as a as an
00:24:06.840
abstraction around State and um and and girl Friday which is an abstraction around background workers again so you
00:24:12.320
never have to type the awful awful thread. new um Aaron should anyone type
00:24:17.640
thread. new no thank you pay
00:24:24.080
attention all right I'm scared of threads that's okay I've got to for you
00:24:29.159
uh it's it hasn't come out yet but it's Dr Nick's Joy of
00:24:34.679
concurrency probably go straight to Kindle um and uh you'd read the privac
00:24:40.640
of your own home without you KN knowing what book you're reading and uh and and kind of summarized as uh store State
00:24:47.200
somewhere else unless it's safe U and the good thing about web apps is you're already doing that I mean because you
00:24:54.200
were you know already um spawning lots of processes you were never assuming that there was a common state that you
00:24:59.240
could store to so most of our apps right out of the backat are good to be thread safe rails is thread safe sinatro if you
00:25:05.840
do that very cunning little hash thing um but I don't understand how that works um then you're good so most we apps are
00:25:12.760
thread safe you are good to go right just God damn
00:25:19.399
it uh you get to do this your code wrapped in Threads let's let's uh and then and there's a stack of technology I
00:25:25.760
think um is anyone go there a thread of a com an idea I'm trying to share here I don't know if it's been a bit vague um I
00:25:32.520
hope I've I've I've not danced around the topic too much all right you might be thinking but I came here to hear
00:25:38.760
things about event machine and and obviously I've not yet danced too close to that just yet uh
00:25:44.760
events are cool threads are not and I haven't heard the use of no GS
00:25:50.799
once how can I be serious so what is evented programming now uh so basically it's a loop where you say is there any
00:25:56.559
IO and if there is you do something with it now it's a loop and the use of an arrow
00:26:03.279
is in congruous with the concept of loop but I need you to understand that I
00:26:08.480
I don't know how to do a loop in
00:26:13.720
keynote so it didn't an arrow and instead spent like a minute
00:26:18.840
explaining it um so I'm sorry anyway I need you to visualize that that's a loop and uh you
00:26:26.720
might thinking great I understand the loop concept you really explained that really really well thanks Nick but I need a metaphor I learned from metaphors
00:26:32.840
and there been a substant got up to slight 81 and I haven't had one metaphor I want to fix that problem now
00:26:39.720
here's a metaphor for you uh her name's uh uh uh
00:26:45.120
Cathy I don't know who she is um and nor do I know what she's doing okay so
00:26:50.480
Avenged Avenged is is request things coming in and you do something and you you know basically Farm them off to
00:26:56.559
something else iio you orchest rating uh other other people's requests proxying
00:27:01.640
and that sort of network service type activity really you you don't do it
00:27:07.159
much people going to node um uh are starting to to write apps that uh they
00:27:13.320
get the benefit of uh of node being faster so they can do slightly more work but still you don't really be bound by
00:27:19.880
you can't really do anything that's actually got real work to do so what when would you use a vented if you want High concurrency um and uh flat memory
00:27:27.440
usage is really cool I show a graph of that with engine X versus aach in a second and high throughput is kind of the goal real time all that sort of cool
00:27:35.080
stuff um the performance of your evented app is determined by uh how you treat
00:27:41.360
your IO Loop so first concern you need to know what an IO Loop is that breaks
00:27:47.799
Dr Nick's rule of programming I shouldn't have to know
00:27:54.720
anything um so now that now that you have to learn something I should teach it to you your vended code shouldn't
00:28:00.440
block um and you probably don't know what that means how about this your vended code shouldn't do
00:28:08.320
anything so I'm scoping it down just to really so how much work uh it depends like it depends on how much throughput
00:28:14.200
you want right so let's say if you want High throughput it shouldn't do much at all 20 milliseconds isn't much in
00:28:20.480
Ruby so uh so Ruby and advented yeah you can do a lot of stuff I and all the guys doing evented um you know they get some
00:28:26.600
great great results interesting and a whole bunch of guys who've done vented are now coming back and saying um saying
00:28:32.720
some interesting things about you know I'll come back to threading if it's all right and I'll showare that in a second so what can I do with invented you can
00:28:38.880
move IO around uh okay so what's a good for and so what you saying is I don't really
00:28:44.880
need it problem is you do because obviously we move some IO around it's a question of of the abstraction and when we do it and what type of IO um so if I
00:28:52.360
need that and this is obviously competitive thing cuz I said it's vented versus threaded like a throw down type
00:28:59.760
thing but I did that because it makes more people turn up the only way I could have made more
00:29:05.880
people turn up to say the top 10
00:29:11.000
ways um so any obviously you still need threads we talked thoroughly about that so I need both yes congratulations on
00:29:17.960
coming to that very Grand conclusion um the challenge is U how do I use both and write complex apps and this is what I
00:29:24.480
think really interesting is especially if you have a rail Centric model of the Universe because rail sort of says I'm
00:29:31.120
important put all your code inside me use me as as your starting point and so it's it's really hard when you're
00:29:36.919
writing a rails app to to do that and you keep in mind that engine X is really part of your Universe it's really hard
00:29:42.159
to remind yourself that you can have other parts because rails doesn't really want you to think that way um but it is
00:29:48.000
important to to have a bigger perspective what you're doing um so but we want to write complex apps so we can
00:29:53.200
get this abstraction happening um so Chris Anderson said in a comment on some blog um which I failed to reference at
00:29:59.880
all um so I don't care but he said it in some context concurrent abs are easier
00:30:06.320
to reason about when you keep them simple and uh and Tony said uh as a as a bit of is a tweet I did reference this
00:30:12.880
one I'm not a complete idiot um so you can go and find out what the real words were but I'm a bit of fibers wrapped I
00:30:19.760
think he said async IO hips to turn fan of proper abstractions on threads and and uh so tonyy did a whole bunch of
00:30:26.120
stuff with the vender done um you know the earing Ria stuff and now he's come around to realizing that that's all well
00:30:32.440
and good but for a predominant amount of your work just do it inside threads um which looks like this just in
00:30:41.240
case you're wondering or miss the first you know 20 minutes um and uh here's
00:30:47.360
some technology you might like to choose that's youry where can I get that
00:30:53.559
technology it's I'm glad you asked um home brew and ruby gems for your max okay so let's
00:31:01.919
look at web apps this happens on occasion you're going to put some stuff in the cash requests come in either goes
00:31:07.399
to the cach or it misses and you have to hit the web app so let's uh let's put them in boxes we'll say that essentially
00:31:13.120
what we're doing is is uh testing if this is an iob bound problem am I just going to serve a file and this is why
00:31:19.440
this is relevant this is pretty much all you know the predominant you know complexity of web apps is have I already
00:31:24.600
cashed this and can I just serve it or do I have to do work now what you don't want want to do is um is have the what I
00:31:32.480
mean under all circumstances if someone asks for something that's cash you want to be able to serve it you never want to get to the point where where something
00:31:38.320
else is blocking it from being able to do that like I'm sorry I can't show you the homepage right now you know I'm
00:31:43.399
deleting someone's account um isn't quite the right business model so we needed to couple
00:31:49.080
these things and this is why we do the evented stuff first we wrap it out and why engine X is such a wonderful um you
00:31:54.480
know technology has to put in front of this whole thing um so this is the evented part and then our works wrapped
00:31:59.919
up in Threads and so let's talk about engine X so that you don't have to write any code to do this um it's as fun as
00:32:06.360
what we do is if you don't have to write the vented code then you'll thank me um so what is relative to to Apachi what's
00:32:14.039
interesting about it this is old we I mean people have been using and promoting engine X for a long time uh
00:32:19.279
but nonetheless here's the graph this is one of the graphs that people used to reference as y engine X was awesome look
00:32:25.639
how much more concurrency you get how much throughput raw power woof U that would have sounded
00:32:32.360
better if I hadn't like had a squeaky voice at the top of that I always feel I need to have another crack at it um what else what
00:32:39.360
else is is nice about this evented system versus versus the sort of threaded Apache model look at that flat memory usage look at
00:32:46.360
it fry how awesome all that memory that I could use
00:32:51.760
for something else and this is the same idea of what we're trying to achieve so we want to do that in engine X and uh
00:32:57.320
and all work wrapped up in Threads just in case you haven't got the theme of my talk all right so only J Ruby that's
00:33:04.919
crazy uh what about Mongrel since I mentioned it before these things are in congruous with each other um So
00:33:10.559
currently J Ruby is is uh what you're going to use all right hopefully we we've talked about
00:33:16.679
this at specific length and uh but I do want to show you a taste of one of the other Ruby implantations that down the
00:33:23.320
track is that is something an option you might like to choose so perhaps one day you do this uh you install rvx uh and
00:33:30.760
and you use it and you install uh a concurrent app server and uh life is
00:33:36.760
good so uh what might this do well Evan said this that's kind of
00:33:42.960
good it used all of
00:33:51.200
them lovely um small problem with uh with Mongrel um I don't know if anyone knows
00:33:57.840
but uh no one works on it anymore uh doesn't support rack um and
00:34:04.519
that's so bad that now Aaron's talking about something else other than rack so how bad is you know Mong going to be so
00:34:10.839
um so what Evans actually started working on uh instead of you know is is is uh is he's a fork of Mongrel okay so
00:34:19.079
if you go if if you go and look at it essentially it's a it's a web server built for concurrency um and why would we need to build this well the reason um
00:34:27.079
if in J Ruby you get the benefit of all the uh the web servers that that uh that already exist so trinida is a rapper for
00:34:33.359
Tom cat um but back in you know in uh the universe that rubinus and C Ruby
00:34:39.040
live in we don't have one that's both working and supports concurrency so uh
00:34:44.320
essentially it's a fork of Mongrel um if you know believe me then look at the read me which says that it's still
00:34:50.480
called Mongrel but but that's underway so today
00:34:57.760
going to choose uh Trinidad uh you're going to install Trinidad you're going to uh change some of your gems and
00:35:02.920
you're going to deploy Trinidad and you're going to say thank you Nicholas I'm glad that I came with you to talk it's both interesting funny and
00:35:09.079
educational and I appreciate that about the time that we spent together and um
00:35:14.760
you're not going to fit that on L tweet so you're going to do that in sign writing across the sky that'll be awesome and uh so in the future then the
00:35:21.920
pumer might be your option rinus and you're thinking but Nick where can I have this hosted gratuitously sell me
00:35:28.880
something not a problem
00:35:34.680
um Mor j s uh I would love to work with some of you I can't be specific I don't
00:35:40.280
know you all so let's do it this way you come and ask Nick can I work with you and then
00:35:45.480
we'll talk I would love that um obviously you get to hang out with these guys they're all around the country and
00:35:51.200
uh and obvious the work we do is is is wonderfully fascinating hard and uh
00:35:56.240
important so some summary just in case you're new or you have a short
00:36:03.200
memory um you want to be happy uh I think what we should do is let me be the
00:36:09.440
Surly one and you be the happy ones all right so you want to be happy you want to write your code but you want
00:36:15.480
performance you're going to wrap an abstraction of threads that not going to touch your life no thread. new for you
00:36:21.920
just happy times you want to wrap it in Threads and you want to move the uh uh depending on the type of project working
00:36:27.960
on where there's a a known sort of iio at the start of of requests move that to the front and uh and Here For Your Glory
00:36:35.680
for your educational benefits is the money shot uh please use these things
00:36:55.040
much laps time 19 minutes seriously only through 100 and something slides that can't be right ah it's not Let's ignore
00:37:01.880
it questions you have a hand and it's ra go so one uh concern me and I I imagine a
00:37:08.440
bunch of other people have about going to a threaded model is if you use uh external gems and they're not necessarily thread safe you have no
00:37:15.960
quick way of finding out oh this isn't threat safe except you all of a sudden get Rand production 5 weeks that's an
00:37:22.359
excellent question uh let me let me let me reference something else
00:37:27.640
oh what's what is that my thing wow can you see that cool all right let's go
00:37:34.079
those tabs rails plugins. or there we go
00:37:42.720
boah but you can imagine that works um
00:37:48.880
anyway so that site was uh includes an attempt to both uh help uh gem authors
00:37:54.079
to document their their commitment to the fact that their gem is both thread and works on J Ruby
00:38:00.119
travis. answers the does it work on J Ruby if you're going to put your gem up on Travis and have the CI done there you
00:38:06.800
can add a file to say what rubies you want to tested against that the thread safe is always going to be difficult but at least this is the starting point
00:38:19.720
um I guess to that can you give advice on how to make your gym spr safe uh a
00:38:24.800
lot of people would need to know how to begin with that actually I'm going to defer Aaron you want to answer that anyone Trad safe uh don't share
00:38:37.920
data dat don't create data don't
00:38:43.560
do yeah world is perfect as it is stop writing code move on with
00:38:50.599
yourselves yeah sorry that's s the broad scope of my lowlevel uh high level talk
00:38:56.880
on on um yes you know ensuring the libr of the thread s is important um but this
00:39:03.560
magnificent site that um says unable to connect which is a
00:39:12.760
con about uh currency for non web app something similar to maybe like openc
00:39:19.040
where you kind of just ignore the fact that you're actually in the background uh so then the sort of like an actor
00:39:25.280
model of of abstracting your concurrency away um sorry so uh as Mike P gave a talk on
00:39:33.440
this before which is why he did the talk involving technical things and I did the talk involving whatever I talked about um so
00:39:41.880
S Lloyd is an interesting gem runs in J Ruby and uh it's it's a nice syntax um
00:39:48.200
and each uh each object runs in its own thread that that involves that uh you include that
00:39:54.280
module I forget but did you ever actually mention anything about invented uh all right yeah that's a good point
00:40:04.359
no if you do run uh I mean the standard web uh appstack for for doing evented
00:40:09.480
apps is going to be thin um run that behind engine X Works a treat but I
00:40:16.000
don't want to tell you to do that that all gimmick to get us in this
00:40:21.440
room next question uh you had a slide this said in
00:40:27.720
the future we'll be able to use ridus when is the future tomorrow on what question um no
00:40:36.720
there are people using rubinus Edge like so master so rubinus two work which was formerly known as Hydra uh and then
00:40:44.119
became the 2 branch and now that's been merged in is um you know in its final months it's got some um unrelated to the
00:40:51.640
to the the the threading the Gillis Behavior U it's also got the one n support and windows which is unrelated
00:40:59.119
to each other so we got to tie those three main things off as as part of that get installers Etc um but uh um yeah so
00:41:09.240
for anyone that wants to start asking me of dates I will start asking you for dates for your
00:41:17.319
projects no look I apologize for not spending more time you know discussing V it I just don't want to confuse it like
00:41:22.839
one core conversation I don't I don't do kidding
00:41:29.119
fight let all right thank you very much have a
00:41:35.280
great day