List

Living Social Lightning Talks

Living Social Lightning Talks

by Ed Weng, Dan Meyer, Tyler Montgomery, Nick Sieger, and Rodrigo Franco

The video titled Living Social Lightning Talks features a series of technical discussions and insights shared by developers from LivingSocial during the RailsConf 2014. The speakers, Ed Weng, Tyler Montgomery, Dan Meyer, Nick Sieger, and Rodrigo Franco, present lightning talks that delve into various technical challenges faced while building and maintaining a consumer marketing platform. Here is an overview of the key points discussed in the video:

  • Transition to Microservices: Ed Weng highlights the architectural shift at LivingSocial from a monolithic Rails application to a service-oriented architecture. This shift has led to complexities such as maintaining shared components across multiple services, specifically addressing how to manage shared views and assets like navigation bars and footers without redundancy.

    • Stepford Service: To tackle shared view issues, Ed introduces a service called Stepford. This service enables front-end applications to request UI components like navigation and footers as JSON responses, resolving the issue of keeping user interfaces consistent across different applications.
  • Internal Gem Infrastructure: Tyler Montgomery discusses the importance of creating internal gems to share code effectively across different applications. He explains how using gems can minimize code duplication and encourages a culture of internal open source, leading to better maintainability and tracking of code dependencies.

  • Production Code Analysis: Dan Meyer emphasizes the growing complexity in debugging as applications evolve. He presents techniques for identifying and removing dead code using tools like New Relic, which helps monitor application performance and usage patterns. He stresses the need for production code coverage to ensure that only actively used code remains in the codebase.

  • Mindfulness and Productivity: Nick Sieger introduces the concept of meditation in a tech context, advocating for increased mindfulness to improve focus and productivity in developers. He shares insights into the mental benefits of meditation, encouraging viewers to incorporate mindfulness into their daily routines.

  • Working from Home Productivity Tips: Rodrigo Franco concludes the talks with suggestions for remote work productivity, focusing on establishing boundaries, reducing multitasking, and managing distractions effectively.

Overall, the presentations cover practical strategies for enhancing both technical implementation and developer well-being within the context of software development at LivingSocial. The talks promote a culture of sharing knowledge, adapting to new architectures, and maintaining healthy work habits, all fundamental for thriving in the fast-paced tech environment.

By

Ed Weng
Dan Meyer
Tyler Montgomery
Nick Sieger
Rodrigo Franco

Help us caption & translate this video!

http://amara.org/v/FGZt/

RailsConf 2014

00:00:18.240 hi everyone so uh we're gonna do uh we're living social we um
00:00:24.240 build this consumer marketing platform we you go to livingsocial.com and it looks
00:00:30.320 like it's just a deal site and it looks small and boring but there's like actually a phenomenal amount of stuff
00:00:36.800 under the water line we have most of our apps are written in ruby and rails but we also have teams working in closure
00:00:44.559 scala um i almost said small talk that would be a lie um
00:00:50.160 ios like native ios native android big data stuff
00:00:55.600 operations all sorts of stuff so there's tons of interesting weird like big problems that we come
00:01:02.399 upon and we're going to do a few lightning talks on those technical things and then also a
00:01:08.080 few on how we operate as a distributed team and how
00:01:14.240 we just operate as developers um so the first uh that's going to speak to you is
00:01:19.680 ed wang he's a he's a graduate from our hungry academy training program where we
00:01:24.720 pulled uh basically just like 30 random people off the streets um no they uh
00:01:30.880 it was not we did not press gang them uh we they applied we put them through uh
00:01:36.000 it was nine weeks not nine months right six it was some number of months so six
00:01:42.159 months uh they did a really intensive training program um and
00:01:47.680 uh are all really amazing developers um and so he's a hungry academy grad he
00:01:54.320 works on our uh mobile consumer uh apps and uh if you meet him later ask him
00:02:00.719 about his pen pal so this is n
00:02:06.479 hey guys so uh so my name is edwang and what i'm
00:02:12.000 going to talk to you today is about sharing templates in a service oriented architecture
00:02:18.080 cool so if you've never been to our site before if you go to livingsocial.com this is the page that you land on and to give
00:02:24.959 you some context about our architecture about two and a half three years ago we
00:02:30.400 were still a monolithic rails app right so everything was inside this one gigantic rails app
00:02:35.840 since then we've been working very hard to kind of break things out into smaller micro services so if you come to this page this is
00:02:43.120 actually in an app that we call browse and browse is responsible for surfacing the browse experience to our customers
00:02:51.040 so uh you can see some of the deals uh on our site uh if you click on let's say the audible deal
00:02:57.280 you actually get taken to a page that looks like this so most of our users won't be able to tell but they actually just left the
00:03:03.920 browse app and now they're in an app that we call sponsors so sponsors is responsible for servicing deals that are
00:03:10.879 sponsored so this deal is sponsored by audible.com hence it's free and let's say a user then decides to
00:03:17.760 click on this tab up in the top the shop tab they get taken to here
00:03:22.959 and this app again is not the sponsors app anymore it's an app that we call products and products
00:03:29.680 is responsible for servicing physical goods that we sell to our customers so if we were to look back at the last
00:03:35.760 three slides i just showed you and i were to ask you what is the one common thing that appears on all three slides
00:03:41.680 you might say it's the navbar and you'd be correct um one of the things that we've kind of
00:03:47.280 discovered along the way of splitting things out into smaller services is things that might be very simple in a
00:03:52.640 monolithic rails app can become quite complex when you move towards a service oriented architecture
00:03:58.319 so the big question that that we're going to ask ourselves today is well when it comes to sharing views how
00:04:03.519 exactly do we keep ourselves dry right so i don't need to tell you guys that
00:04:09.439 you know out of the box uh in a monolithic rails app you have partials and layouts right so
00:04:15.360 how much you show the nav bar on every single page well you'll throw it into a partial called nav bar and then you'll
00:04:20.560 just go into your application layout you'll render the nav bar and then it just shows up everywhere right
00:04:26.320 this is great for a monolithic rails app but as soon as you move to a service oriented architecture it starts to break
00:04:31.680 down well why is that the first thing is that it's a lot of copy and paste coding right so
00:04:37.520 anytime you want to make a change you have to copy the nav bar into a bunch of different places the second thing is
00:04:42.960 that it requires changes in multiple places and so it it kind of slows your development down anytime you want to
00:04:48.880 make a tweak you have to go to 5 10 15 services and issue a pull
00:04:54.960 request uh so that uh you know the nav bar is updated in that specific application what we've noticed is that
00:05:02.000 things tend to get out of sync very quickly if you if you take this approach um so it leads to a bad kind of user
00:05:08.639 experience in that the navbar starts to change as you go from page to page
00:05:13.759 so this doesn't really work for us the next thing that you might think of doing is well what about putting everything inside an engine or a gem
00:05:20.240 right and this is a a much better solution right why is it much better well the first thing is that it
00:05:25.680 eliminates that copy and paste coding that we were just talking about right so everything is kind of stored in this
00:05:30.800 single central repository uh and and then anytime you want to make a change you just update the gem and kind of
00:05:36.800 release it into the wild one of the great things about putting this in an engine or a gem is that you
00:05:42.320 can share more than just the markup right you can share translation files you can share images javascript style
00:05:48.880 sheets etc etc so that's great the problem with it though is that anytime you make an update you still
00:05:54.880 have to go to every single app and issue a bundle update so um you know it might work fine if you have a couple of apps
00:06:01.360 as soon as you move to 5 10 15 apps it becomes a hassle so this is not quite good enough and at livingsocial we have
00:06:08.160 a saying that if services aren't solving all of your problems you're probably not using enough services so what did we do to
00:06:15.520 solve our problem of course we built another service and the service we built is called stepper it was designed by a guy named
00:06:22.400 eric brody and stafford is responsible for sharing our views across our service
00:06:28.800 oriented architecture so when we were first building stepford we went through kind of a ddd approach a
00:06:35.600 design a dream driven development approach and we asked ourselves what do we really want the interaction with a
00:06:41.280 service to look like and this is kind of what we came up with so we have a client app we wanted the
00:06:46.960 client app to be able to ask stepford and say send me the footer right stepford would then go off do some stuff
00:06:53.440 behind the scenes and then just come back and say here's your package so let's kind of break that down into
00:06:58.960 three separate steps so the first step send me the footer we tried to come up with the simplest
00:07:04.479 possible thing that we could think of and that is just a get request to some json endpoint right so this is what the
00:07:11.520 request looks like inside the stepford app it's a get request to the packages controller
00:07:16.639 and we just put the things that we want so different elements uh inside the
00:07:21.759 query string so here we're requesting the footer we can also pass additional variables
00:07:27.759 things like city id if we need that footer to be semi-personalized or modified
00:07:34.000 so now you're probably asking well what's inside a package right so a package is actually made up of
00:07:39.680 three separate things right it's made up of markup it's made up of styles and it's made up of scripts
00:07:45.039 um and everything kind of revolves around the markup that that you're requesting so you might imagine that if
00:07:50.479 you're requesting the footer uh there's an associated set of styles with it an associated set of scripts with it if the
00:07:57.520 styles don't come through then your footer looks really ugly and if the scripts don't come through then your
00:08:03.199 footer probably isn't going to work the way that you want it to work so so we kind of package all the three
00:08:09.120 things up because they all have to kind of come together and we put it in this concept of a package
00:08:15.039 okay so the next step so the next step is stepford gets that request and what does it do behind the scenes
00:08:21.280 so it's a little bit complicated and this is a very simplified high-level version of it but uh
00:08:26.960 in the top left corner we see that the get request comes into that package's endpoint stepford then tries to make the package
00:08:34.000 so it grabs the markup it grabs the styles it grabs the scripts it tries to pre-compile the styles it pre-compiles
00:08:40.080 the scripts it throws everything into the database and then it actually tries to render the markup on the server side
00:08:46.560 so that's super interesting it takes the erb template that is stored inside stepford and it actually renders it into
00:08:52.480 raw html it then sends it back via json so that's the last step of the three-step process but here's your
00:08:59.360 package and i'm about to show you what a package response looks like so the package response contains the three
00:09:05.600 things that we talked about right the styles the scripts and the markup and here you can see that all we
00:09:11.839 requested was the footer right but you can imagine that in our in our architecture where
00:09:17.360 an app generally requests more than just the footer it probably requests the footer it might request the nav bar it
00:09:23.120 might request button styles etc etc and that is kind of all going to show up in that markup as raw html
00:09:30.800 and the nice thing is that stepford will kind of package together all of the styles and all of the scripts for every
00:09:36.959 single markup element that you've requested so everything just kind of boils down into one pre-compiled style
00:09:43.200 sheet and one pre-compiled javascript cool so let's spend a little bit of time
00:09:48.560 talking about the pros and cons of spinning up a service like stepford uh the obvious biggest pro is that you keep
00:09:55.120 your views dry right uh i don't need to tell you the benefit of uh of having all
00:10:00.240 of your views in a single central repository right there's huge benefits it's easy to maintain et cetera et
00:10:05.839 cetera uh the second thing is that it's super easy to release changes so stepford is all pull through which means
00:10:12.160 that anytime you update a navbar or anytime you update the footer you don't have to go to every single app and tell
00:10:18.640 them there's a new nav bar there's a new footer the next request that it makes the stepford it's actually going to stepford
00:10:25.200 is actually going to send back the latest version of whatever element there is on the uh in the database
00:10:32.560 okay so there's obviously some cons the first con is that it's another service so one thing that we've realized by
00:10:39.120 spinning up so many services at livingsocial is that anytime you make a service you're trading application
00:10:44.399 complexity for network complexity right so that means that your tech ops team has to maintain one more application
00:10:51.040 they have to make sure that it's up all the time otherwise you know your styles won't come through
00:10:56.480 the next thing is that because it's another service it also means that there's another network request going on
00:11:01.760 so stepford does introduce some amount of latency into your application right
00:11:07.279 there's another http request that goes on on the server side at livingsocial the way that we kind of
00:11:12.959 have gotten around that is we put in a lot of a lot of caching right so we have varnish caching around uh stepford we
00:11:18.720 also have memcache around it the reason is is because uh a lot of times our main ui elements
00:11:25.920 don't change all that frequently and so it's okay to put things like varnish in front of it it's okay to put memcache in
00:11:31.120 front of it and the last thing is that changes have a much larger impact so when i said it's easy to release changes
00:11:37.839 sometimes it's too easy to release changes uh you know there have been instances where
00:11:42.880 we'll make a change in javascript and we quite we can't quite anticipate what the effects downstream will exactly be
00:11:50.160 and so as such you really need very close javascript monitoring to make sure that
00:11:55.600 you understand when errors come through so that's it that's my talk on stepford
00:12:01.760 if you have any questions please come find me after the talk and we will chat
00:12:11.440 thanks ed so the these guys get to watch me use a computer which is great fun
00:12:20.639 over my shoulder this is tyler tyler works also on our consumer apps team he's from uh southern
00:12:27.440 california which is his handsome looks northern california i botched it sorry uh but still handsome
00:12:35.600 but he's taken ladies and i just learned from his website that he wants to learn everything so if you
00:12:41.920 see him in the hall just literally tell him anything and it will be the best part of his day
00:12:49.279 howdy i'm tyler i live in northern california i work remote
00:12:54.480 um so how do you work a computer okay let's let's start at the beginning
00:13:01.040 it's a good place to start all right ready and play all right so i'm talking about um
00:13:08.720 internal gem infrastructure basically making it easy to write gems release gems
00:13:14.800 for us you know sharing is caring being able to share code effectively across your apps makes things really awesome it's it's
00:13:20.800 easy like we said to extract things in the services break down the monolith when you can share code you can put it into a gem really easily
00:13:27.519 it's reduces the copy paste to mayhem we've had you know we put up a little service and someone writes a little
00:13:32.720 client it gets copy pasted 50 places and then we make changes it's really hard to track down who's
00:13:37.920 hitting what endpoints so we've had to go back put those things into a gem so we can share and keep things maintainable
00:13:44.079 building gems and having this you know code in gems uh really helps build this culture of internal
00:13:50.560 open source the gem gets its own repo gets its own readme it's really easy for anyone to contribute to it but people know where things are
00:13:57.199 you get all the benefits of pull requests help rates it helps with separating concerns like we're told like
00:14:02.639 hey you should make a mess you know um but where do you put that mess in a rails app it's kind of weird like where
00:14:07.839 do i put all these little tiny objects with single responsibilities where do they live how do i keep track of it and putting the stuff in a gem is really
00:14:14.320 nice it helps you draw boundaries around your code to find your domain better um isolating your code is is actually
00:14:20.720 really great for deleting it later you can track it down you can find where it needs to go and get rid of it but you
00:14:26.720 don't necessarily have to delete the code you don't have to go where is that one commit that one time where i did that one thing and i gotta go look
00:14:32.800 through all these old commits you just go look at the repo but you've deleted all that code out of the other code bases you still have some of that
00:14:38.399 history around isolating is good too because it forces you and how does your code interact with rails how do you interact with the
00:14:44.639 database how do you do logging when you're isolated in your own little gem do you even need rails for this little
00:14:50.560 business project that you're working on does it need to be part of a rails app this has really helped me like try to
00:14:55.760 constrain my code the simplest form it needs to be to get the job done this helps me mock and stuff boundaries and
00:15:01.279 my tests because it's clearly defined where it needs to interact with other pieces of our of our architecture this
00:15:07.519 has really helped me with writing good docs because i have a readme for this thing it's really easy
00:15:12.639 so a real example a few weeks ago i was tasked with automating a daily csv
00:15:17.680 report out of the database and uploading it to a third parties ftp site they then will return us a plain text email
00:15:24.000 telling us the results of processing this data a co-worker commented 1997 wants its architecture back
00:15:31.360 so we've all done this we say hey man i'm just going to drop this in the model you know this ftp code csv it uploads
00:15:36.639 gets the job done you know fat models bro um and a couple weeks later you're like what is
00:15:42.560 what is this code who put this here what does this even do or a year later two years later who who did this
00:15:48.320 and so you know i was thinking this is really gnarly code it has just it has a kind of a single responsibility it has
00:15:53.759 this one thing it needs to do so i'll make a gem so the rest of my talk i'm just going to
00:15:59.759 quickly go through building gems releasing gems and then hosting your own gems internally
00:16:06.560 so building a gem this is another crash course inside a crash course this might be review for some of you but um this is
00:16:12.000 just kind of the easy way that i see how to do it um so it's a it's another crash course so um so building a new gem is
00:16:19.199 this easy you already have this installed you already have bundler installed you just type bundle gem your
00:16:25.279 gem name um the ls on the front there that's to help us with name spacing i'll get into that in a second but bundler
00:16:30.959 will do that for you this is what it creates this is your basic fresh gem it's a gem file a license which is mit
00:16:37.920 uh you read me like i said you get a rake file and then you get your lib directory with all your program code in
00:16:43.040 there the most important file there is the bottom that's the gem spec without that you don't have a gem there's plenty
00:16:48.480 of documentation on you know what goes into gemspec but bundler does a good job of doing
00:16:53.920 defaults for you namespacing if you hadn't seen this before i've done this with a couple different
00:16:59.519 companies and it's really helpful you basically take your company name shorten it down to two letters and you put it in a module and you put all your classes
00:17:05.839 under this global kind of module um that's how you use it there it's ls for this one a gem
00:17:11.600 of the box client and you require it if you've seen that like you know ls slash thing that's how it's
00:17:17.039 that's how you're doing name spacing this is really helpful um we have some early gems that didn't do this and i
00:17:22.959 wasn't sure when i first started is this an open source implementation or is this internal like where did this thing come from so maintaining this namespace is is
00:17:30.880 helpful in uh knowing where your code has come from and that it's an internal project um so basic example this is just
00:17:37.039 just kind of uh an example that has a few more things in it we threw a changes file in there so we know what happens
00:17:42.240 when the version changes um and then we got our you know some more program code and we have our own tests like
00:17:47.440 everything is nicely tightly compacted for for this little project um a quick review on semantic versioning you can go
00:17:53.679 to semver.org um yeah some people don't understand it so i
00:17:59.600 want to review it um the last number and a version number is the bug fix number you increment this when things change like when you fix bugs but you haven't
00:18:05.760 broken the public api you haven't changed you haven't broken anything um the minor version number is when you added a new feature yeah we have new
00:18:12.240 stuff but you haven't removed anything you haven't you haven't broken the public api you haven't forced people into changing things and then finally
00:18:18.960 the major version number is you broke something you have changed significant amounts of things and people beware like
00:18:24.799 this might break your code and you can think of this like how hard it is to upgrade from rails two to three or from rails three to four that's a big
00:18:31.120 change so that is a major version number if it's stable it should be 1.0 if it's
00:18:36.160 not stable it should not be 1.0 um this is a good signifier it just says hey
00:18:41.200 this has been used in production it's stable it's everyone can use this when you go to 1.0 um if it's before that
00:18:47.200 you've probably seen gems that are zero zero 1237 and it's like i'm not sure if i
00:18:52.400 should use this that's a lot of version numbers um so that's just quick refresher on
00:18:58.000 building gems and versioning name spacing um now we need to let the world be hold your awesomeness or at least the
00:19:05.120 people at your company releasing should be easy we say deploying should be easy deploying and releasing gems should be an easy thing
00:19:12.480 this is not easy remembering the version number and tagging it and rake build and like this is not easy
00:19:20.000 this is easy rake release this is really easy you use bundler you get this rate command for free
00:19:25.840 but don't accidentally open source your code uh this happens and there are bots that
00:19:32.160 mirror rubygems right away it's very hard to take that back so how do you go from this to this but
00:19:39.120 keeping everything internal um you can monkey patch i mean subclass bundler um
00:19:44.559 gemina box will actually tell you on their wiki page the to monkey patch bundler don't do that um so what we can
00:19:50.160 do we rewrote our own gem that just inherits from bundler's gem helper
00:19:56.880 there's tutorials on this but i'm just going to go through real quick how this works in your in your rake file you see
00:20:02.000 this bundler gem tasks at the top what that actually does is that gives you those three default rate tasks the build
00:20:07.600 the install and the release by default it's going to push it to rubygems and we don't want that
00:20:14.320 so when we subclass it what we want to do is we want to say we use geminabox as our server living social
00:20:20.559 we want to say hey don't push to rubygems push to gem in a box so we subclass bundler and said hey don't push
00:20:26.080 the rubygems if you try to if you even try to call the private the protected method there you're going to get an error so just don't do it and then once
00:20:33.440 we release that gem it's just a really small gem we put ls gem tasks in place of bundler gem tasks and all of our
00:20:39.440 other gems so by default this goes to our gem server when you release it's really easy
00:20:45.039 so gem servers you you know how to build one you know how to get it out there now you need some place to put it
00:20:50.080 there are three options there's gemina box stickler and then gem fury so if you're hosting your own it should
00:20:56.320 be behind the firewall it's internal code you don't want anyone else accessing it gemini box provides a nice web interface
00:21:03.120 for managing your code it has authentication you have to build your own rack middleware to do the authentication
00:21:08.640 it does pull through mirroring which is kind of cool you can tell it to mirror everything from rubygems as you
00:21:15.039 install things so you don't need to depend on ruby gems being up uh when you deploy gem of the box will pull down
00:21:20.799 everything for you and it has a nice command line client it's pretty simple patches gem with this
00:21:26.480 in a box command and allows you to push and set up your own machine to talk to your server
00:21:33.200 the other option for open source thing gem servers is stickler it provides authentication in the same
00:21:39.120 kind of way it does selective mirroring so you can tell it you know mirror active record 3.2 and it'll pull it from
00:21:44.880 rubygems you can also give it a whole gem gemfile lock and it'll take everything in there it'll mirror all of
00:21:50.559 it for you which is handy it has a really full featured command line client you can do everything that
00:21:55.760 you can do from their web interface and then it's the author wanted me to note that it's going to support the
00:22:01.039 bundler dependency api in the next release coming soon um for a hosted server that's not behind
00:22:06.799 this firewall it's on someone else's machine there's only one option i know about it's gemfury.com they provide authentication
00:22:13.120 obviously because it's not on your machine um they don't appear to do mirroring which
00:22:18.159 is you know if you're still relying on someone else's service you're gonna probably be relying on rubygems too so they don't do mirroring they have
00:22:24.159 command line client and then they do support node.js and python packages so that's it my name is tyler montgomery
00:22:30.240 uber majestics on twitter
00:22:38.159 thank you tyler next up we have dan mayer he's also on our consumer app team not everyone is on the consumer rap team
00:22:45.280 uh he does a lot of uh teaching in the dc area teaching people ruby um and i
00:22:50.480 just learned that he can fix bugs from ski lifts over the phone so that is a useful
00:22:56.799 parlor trick uh take away dan all right uh hello i'm gonna be talking
00:23:02.960 to you about production code analysis obviously as you build up all these services and split out all your code it
00:23:09.520 gets much harder to debug and start finding out things about your code like a small application is easy to reason
00:23:16.080 about in your head uh but as your systems grow and your architecture grows it gets more difficult
00:23:23.200 oh uh could somebody fix the projector and get us all on
00:23:28.559 uh shrink down is that one on or is that off as well
00:23:33.840 well if somebody could fix that one too that'd be great um you can't improve if you can't measure
00:23:39.919 you can't improve what you don't know we often focus on performance and exception monitoring
00:23:46.559 some fixate on test code coverage there's a lot to learn from what your code actually does in production
00:23:53.120 ruby tools aren't quite as good as like the java tools so we really are still trying as a community to improve those
00:23:59.120 tools so that's some things we're working on internally and then i want to mention etsy uh they
00:24:06.720 have some great posts all about measuring production systems graphing everything and actually uh release stats
00:24:12.480 d which we rely on quite heavily so i wanted to just say thanks for that
00:24:18.480 all right so i like to focus as we split things out and kind of forked off code bases on getting rid of unnecessary code
00:24:25.840 because i want to be able to only think about and reason about the code that we actually care about and what's actually
00:24:31.440 being used in a system um dead code ends up in production for a
00:24:36.480 whole lot of reasons i've list up a whole bunch there but we don't really need to go through every one if you've ever worked on a team as it grows you
00:24:43.200 eventually find code that you're like this was written three years ago and nobody's using it why is it here um i
00:24:49.760 think it's important to try to track that down and get rid of it as soon as possible especially as you're adding a
00:24:55.120 lot of code very quickly to systems um so there's various ways to find dead code some as simple as just using new
00:25:02.559 relic or formerly trace linux you can do custom stats and instrumentation which
00:25:07.600 i'm going to going to talk about a little bit uh there's production code coverage uh there's the gem i've been working on
00:25:13.919 that does code coverage but not on your test suite it's actually live code running in your system and
00:25:19.600 after uh seeing some of the talks by tilda i also realized i can make it much more
00:25:25.520 performant in ruby 211 so i'll be working on doing that because right now there's a high cost which i'll talk
00:25:30.640 about a little later um you can use logs you should definitely have your logs all searchable
00:25:36.159 and we'll go into that using statsense instrumentation and production code coverage we've deleted
00:25:43.360 20 plus thousand lines of app code and then hundreds of thousands of lines of code if you start including our assets
00:25:50.080 our javascript um test files and that sort of thing we've really been able to shrink down our code
00:25:56.640 bases as we expand out so third party real quick if you use new
00:26:02.960 relic you can go to the transactions go look at the last seven days sort by count the things at the bottom
00:26:10.480 likely are dead deprecated or you can start working on killing them they have like one request in the last seven days
00:26:16.320 you might want to go look at what those are it's really easy but still useful if you're ever finding an end point and you
00:26:21.840 wonder wait a minute what is this go check it might not be hit in the last seven days you can probably kill it it's
00:26:28.320 real easy it's actually even easier because we have a gem new route like route check
00:26:33.760 which basically you can download the csv from new relic this generates your rails route file and then compares your routes
00:26:40.159 versus the output of new relic and then starts telling you this was in your routes file but never
00:26:45.679 actually hit you can go look at those endpoints stats instrumentation we're gonna step
00:26:52.720 through all of these uh fairly quickly uh but basically there's a lot of different things you can do with stats
00:26:58.799 to help you find code and tell what's going on in your systems
00:27:03.840 so background events you want to know which jobs are being executed you want to know if they're completing
00:27:09.039 successfully you might want to know how long they take this is an example for rescue we
00:27:14.880 actually have our own wrapper around most of our background jobs so we do it at a different layer
00:27:19.919 statsd before perform after perform you can throw in whatever else you want there if you want timers anything but
00:27:26.480 it's really easy to instrument that then you have your nice graphite graphs where you can kind of follow and see the
00:27:32.320 see the charts on everything you can also look at graphite and see if a job's no longer ever being performed
00:27:39.279 emails email templates especially transaction emails eventually you have a one-off transactional email for
00:27:46.240 some holiday thing some special uh product something that's no longer being
00:27:51.760 triggered you can check all your emails it's no no reason to work on updating them or
00:27:56.799 fixing them especially when you're doing say a rails update and you have to change all your action mailer code this
00:28:02.240 will let you know if it's worth your time views rendered
00:28:07.840 eventually your view layer will get very complicated with layers and layers of partials if you have layers and laser
00:28:15.200 layers of partials it's hard to reason about which ones are still in use which ones have been refactored away entirely
00:28:21.760 you can actually really quickly using active sport notifications find all your layouts and all your partials and
00:28:28.960 templates and track them this is an example showing it to statsd or you can just render it into your rails logger
00:28:35.600 and then you can search it in something like splunk elasticsearch see if it exists again we made a gem for this to make it
00:28:42.159 easier you can see flat foot basically you set up flat foot it does this
00:28:47.760 for you and then it gives you some helpers to find used views unused views
00:28:52.799 you can reset it on each deploy it makes it really easy to kind of automate this process and generate reports on it
00:29:00.799 uh one-off trackers sometimes you just find some code and you're not quite sure what's going on
00:29:07.120 it's very easy with statsd to just throw on one off trackers this is an example of a controller we're trying to figure
00:29:12.399 out which of the types are paths in the controller are still being hit you can go ahead and throw increment on
00:29:19.120 each of the formats on that request.xhr now you're going to be able to say oh actually we stopped using the you know
00:29:25.600 json format months ago let's get rid of all the related code
00:29:31.039 uh production performance comparisons uh this one i of thanks to uber james
00:29:36.399 uber majestic over here tyler um he actually just threw this out and didn't really make any fanfare of it on one of
00:29:43.440 our applications and i saw this and i was like that's really cool we had two different options for stripping out some
00:29:50.960 html and we wanted to know what's faster you could benchmark it locally on some fake
00:29:56.000 data but the production data is very different than what you're going to test with and it it will vary a whole lot
00:30:02.480 over all our applications he threw this in there splits it 50 throws the timer around it measures both
00:30:09.600 one implementation of the algorithm versus the other a couple days later it's incredibly obvious that nokigeria
00:30:15.919 is much faster than just using the regular strip tags from rails um and that that i i just thought was so
00:30:22.159 interesting that i've kind of been carrying around to point out to everybody i can find that's interested
00:30:29.440 uh translation usage uh this one i owe uh chris morris some credit he's another
00:30:34.559 engineer at livingsocial he works a lot on our payment systems but he used to do a lot of our translation and
00:30:40.399 internationalization work and eventually your translation files get really large and they actually take up a lot of
00:30:46.399 memory and you're running ruby processes so if you're trying to shrink down your memory so you can foot fit more workers
00:30:51.840 on a box you might want to look at your translation files they tend to be a pain point for a lot of companies that have a
00:30:57.919 lot of languages this lets us track which keys are actually being used what are we still
00:31:03.279 translating in production or what is it we no longer using the translation for as you delete all these views it's easy
00:31:09.679 to forget about all the translations that were in the views this actually makes it very simple to go
00:31:15.120 and find those uh production code coverage this is a
00:31:20.640 little bit more experimental at the moment uh we do run it on production i have it on a lot of systems
00:31:25.679 uh i cannot use um coverage which is what like simple cover and things use in your test suite
00:31:31.679 because there's a bug in ruby if you sample and turn it on and off it will crash which luckily i learned prior to
00:31:37.840 production um so i switched to using set trace func and this lets us see each line as it's
00:31:44.559 being run uh live and then we do sampling to cover the fact that set trace func is extremely slow uh
00:31:50.640 sometimes 400 800 slower uh so we can sample a very small rate of request but
00:31:56.720 it still will over a whole lot of volume give you a pretty good idea of what's used in production and like i said in
00:32:03.200 211 i just learned that you can actually get the cpu profiler is a sampling profiler and you
00:32:10.399 can get the line number data out of it with a very small uh c extension so we'll probably be updating this and that
00:32:16.640 will only help 211 it'll still have to use trace func on 193 and 200
00:32:21.760 but you can get some really interesting data and delete a lot of code this way here's a quick example of the setup but
00:32:27.600 really go to the gems homepage you can see you can do ignores on things it'll check your app path it tracks and redis
00:32:35.200 i use a startup delay because rails is very slow on the first few requests because it actually builds a lot of code
00:32:41.600 and memory at that time and you really don't want to be checking your code coverage as it's
00:32:46.880 building new methods it's just not a good use of cpu
00:32:51.919 um yeah and this shows how to set it up in your rake file and
00:32:57.440 uh real quick i'll um i was gonna have a demo i think i missed the slide but we've got other speakers so i'm gonna
00:33:03.679 skip ahead real quick on logs i just want to mention make sure to get all your logs from all your applications in
00:33:08.960 one place elasticsearch splunk cabana doesn't really matter you just want
00:33:14.320 everything in one place so you can actually see how requests are going across your system i've been working on
00:33:19.440 a gem called imprint but also you can look at zipkin which is uh
00:33:24.880 i guess some of like twitter's work um mostly they do scala but i guess they have stuff for ruby as well i just
00:33:30.559 learned about that at this conference but basically if you put a trace id on your request you can see as they're
00:33:35.760 coming in your system and then as you make multiple api requests to your back end you can see how that fanned out in
00:33:42.640 your system you can also drop it to all your events so any event that fails you can track it to the incoming request if
00:33:48.880 you have an exception it's going to be in the headers it'll be on your exception you can actually take the exception and go see all the logs for
00:33:55.360 all the requests and debug what was coming in that was so awkward to cause this exception
00:34:01.120 and i think all these tools can help you clean up your code and actually understand what's happening in production much better and that's all
00:34:08.639 i've got
00:34:17.040 thanks dan um right are you going next or is okay oh i
00:34:22.320 don't know i i'm telling rodrigo to sit down nick nick is going to go next
00:34:28.960 uh nick is a minnesotan he's on our mail tools team a jruby
00:34:35.359 contributor he and if you're wondering he's six foot four inches tall and can help you get things off of tall shelves
00:34:42.240 uh and he's gonna talk to us a little about meditation
00:34:47.280 which is french for i think therefore i am of course by the famous philosopher rene descartes
00:34:53.440 i'd like just to ponder today a little bit about whether that's really an appropriate frame of mind
00:35:00.400 you can interpret that statement to mean that we identify ourselves our entire existence by the fact that we can think
00:35:07.760 and i personally think that's a really bad idea
00:35:12.800 early in my career i was obsessed with my capacity of work done i wanted to work all the time
00:35:19.599 um and i was constantly searching for that sort of state of that elusive state of flow
00:35:25.520 but in fact what i think i really got stuck in most often was
00:35:30.800 an off more common state of yak shave so when you think of yourself during the
00:35:36.880 work day you know how often do you find yourself getting distracted
00:35:42.839 um running it down a rat hole uh and then once you get done with that
00:35:48.800 whole that whole once you finally unwind the stack and get all the way out of that rat hole how many times do you find
00:35:54.800 you're saying wow that felt great it's like no it probably did not and i'm arguing that one of the reasons why
00:36:01.200 it doesn't feel great is because we all too often let our minds run wild we take every thought that comes into
00:36:07.040 our head and we believe it's the truth or we believe there's some element of truth to it
00:36:12.560 we might even have perceptions about ourselves and the way other people perceive ourselves and we think that
00:36:17.599 some for some reason those are true and i'm here to tell you that they're not
00:36:22.960 i think that um we have all of us inside us we have a
00:36:29.359 sort of a silent watcher observer of our lives that's behind all the thoughts and
00:36:35.680 um if we can all take a little bit of time in our day to access that part of ourselves we find that we're going to be
00:36:40.960 happier we're going to be healthier and that's kind of a little bit of what
00:36:46.880 i want to outline today so as far as meditation goes in terms of a discussion for today i'm
00:36:53.040 going to say that meditation is sort of spending some quiet time you know attempting to find sort of an
00:36:58.880 absence of thought in your head and if you've ever tried meditation you know this is actually extremely hard
00:37:05.119 people have been meditating for thousands of thousands of years and it is most certainly a lifelong practice
00:37:11.280 um and when you realize how hard you think oh my gosh how am i gonna actually
00:37:16.720 will i ever get to a state where i feel comfortable with this is this something that's really worthwhile to do
00:37:21.760 and i would advise up front that meditation like many other things in our lives that we find worthwhile to do
00:37:27.440 all it requires is just a little bit of time and making it a habit to get the most out of it so don't make don't don't
00:37:33.920 listen to the voices in your head again don't listen to your thoughts that are saying oh my gosh i have no time to do this
00:37:40.079 i'm not going to do this right i don't know how to do this it's not going to be perfect so therefore i'm not going to try just ignore all those and just try
00:37:46.880 to try to do it there's a number of studies out there meditation does have actual tangible
00:37:52.400 scientific health benefits uh there is one study that had people meditate for 30 minutes
00:37:58.160 a day for eight weeks and they did brain scans on the people before and after and found that their grade matter in brain
00:38:04.400 regions associated with memory and stress and empathy actually increased in just eight weeks
00:38:09.440 so you can actually you know even as an adult you know we're long past puberty even as
00:38:14.720 adult you can spend time and change the composition of your mind and the composition of your body
00:38:21.119 another study at uc davis folks found that focusing on the present
00:38:27.280 doing activities like meditation rather than letting the mind run away or drift uh actually lower levels of the
00:38:34.240 stress hormone cortisol in your body so meditation also will allow you to get on top of your um
00:38:41.760 your hormones and get a better hormonal balance you'll feel a lot better about yourself so
00:38:47.520 unfortunately a lightning talk is probably a bad place to actually try to try to lead a meditation session
00:38:54.000 since i think you to do it justice you'd want to probably have at least a five minute quiet time to yourself but
00:38:59.280 instead what i want to do is take just a few moments and actually ask all of you to um
00:39:05.200 you don't have to do this yet but what i'm going to ask you to do in a minute here is close your eyes and just try to get comfortable and try to clear
00:39:12.160 clear your mind of any thoughts um and then what i'm going to ask you to do is to just
00:39:18.160 spend some time trying to attain that that that clear head and watch your mind
00:39:23.599 for the very next thought that comes out and watch your mind like a cat would watch a mouse hole so i'm going to ask
00:39:29.119 you all now to close your eyes and watch your mind and just try to watch for the very next thought that comes in and just
00:39:34.160 try to be focused and attentive don't try to follow don't try to lull yourself to sleep or anything just just be focused and
00:39:40.320 attentive and try to look for that very next thought and i'll just give you a few moments
00:39:47.359 and when that thought comes in go ahead and open your eyes okay some of you actually
00:39:53.839 lasted quite a while there that's pretty good so what you might be finding with this little exercise is that
00:39:58.880 when you take the time to be really attentive about having a clear mind it actually takes a little while longer
00:40:05.280 for that thought to come in so this is this is actually the very beginning of a meditation practice
00:40:10.480 you're actually trying to rather than being completely uh completely uh lifeless or or almost
00:40:17.119 like uh well you're actually trying to be very very attentive to the ver you know to the
00:40:23.280 immediate present moment um so when you're doing this it's important to not be self-critical right
00:40:29.359 so maybe a thought rushed in right away again and you feel like oh gosh i have no control of it well
00:40:34.800 don't try to control what's happening don't try to be on top of it we you know we're all control freaks a lot we're in
00:40:40.079 technology we like things to work we like to control computers don't try to be in control of the situation just
00:40:45.359 observe where your thoughts are jumping to and just just try to be that passive
00:40:51.200 observer of what's happening in your mind and then so once you start to get in
00:40:56.800 this habit of taking time to at least checking yourself maybe you start a meditation practice or maybe you
00:41:03.440 just want to take moments out of your day to just take a break from things and be a little bit more mindful a little more self-aware
00:41:10.079 ask yourself throughout the day am i at ease at this moment you know ask yourself how do you you know how do i feel at
00:41:16.160 this one am i at ease or what's going on inside me and just just pay attention to those feelings and those what's going on
00:41:22.720 inside you without judging or trying to make any changes about it we're just trying to cultivate self-awareness here
00:41:29.520 i also find that doing meditation has led me to doing other things really mindfully as well i i like to do i like
00:41:35.760 to cook i like to clean i like to do all these little kind of
00:41:42.240 tasks that don't require a huge amount of metal energy and i like just focusing on them intently and i find that even
00:41:48.160 doing things like chopping vegetables or or cleaning or doing dishes or any tasks which you think normally would be
00:41:54.640 completely you know oh what a waste of time i don't want to do this right now i really don't want to do these chores you
00:42:00.240 can actually find a little bit of pleasure in just focusing completely on the task and that's another way to just kind of open yourself up and be be more
00:42:07.359 at ease and you know of course we all have screens on us at all all
00:42:14.640 times of the day these days and that's another area where it's like looking at a screen is you're putting your
00:42:19.920 attention out into the either out somewhere else from where you are right now so when you're with someone even when you're by
00:42:26.560 yourself maybe every now and then put the screen down and just focus on on just what you're doing
00:42:32.800 um and i think for me my my opinion of of the you know
00:42:39.520 this this lifelong process of trying to be more mindful trying to meditate trying to make make ourselves better
00:42:45.280 through meditation is actually a contagious thing and one that we can contribute to the well-being
00:42:50.480 of the entire planet so i hope you will consider uh you know reducing the crazy noise in
00:42:55.599 your mind and maybe check out what meditation can do if you're and kind of follow up on some of those studies i i
00:43:01.839 mentioned i will have uh i'll tweet a link later on i was i was planning on posting it before this talk but i forgot
00:43:08.079 to do it i have to get back to my computer but i will i will tweet a link later my my twitter handle is um nick
00:43:13.839 seeger n-i-c-k-s-i-e-g-e-r and i'll tweet a link later with some of the the articles and and links to things
00:43:19.839 that i i looked i referred to during the course of my talk so meditate be happy make the world better
00:43:26.560 thanks
00:43:36.160 now's your time rodrigo so uh rodrigo is uh a developer on our
00:43:42.480 merchant team and uh he's an avid gamer both board and video
00:43:48.960 right yes and uh you're from brazil right yes definitely south of the equator yes and um if you see in the
00:43:55.359 mall ask him about his goats you're gonna they're gonna see them all right
00:44:02.720 so yeah okay take it away thank you
00:44:12.800 you're strong so hello everyone my name is rodrigo
00:44:18.720 and i'm here to give you one trick to boost your productivity when working from home
00:44:24.800 uh my twitter handle is careful even my wife calls me that so you can call me that too or rodrigo
00:44:31.200 whatever you want uh i wrote an article for our tech blog about uh how
00:44:36.800 uh i do work from home and uh how i try to focus on things while doing that
00:44:43.040 and uh the most important thing that people talk about was the pet goats uh that they were in the article like
00:44:49.920 briefly i'm going to show you some here's me with my pet goat in a hangout for work
00:44:55.920 if you want to read the article it's available here it's a tiny link and i have been working remotely
00:45:03.440 from home for about 10 years so i had to find my way
00:45:08.560 to focus on stuff otherwise i would just play video games all the time and that's why we have this unrelated
00:45:14.800 cat picture and this article name is one weird trick
00:45:20.079 because when i was browsing the internet without adblock i saw a lot of these these like ads like one tip for a flat
00:45:27.680 belly and like gigi said like there's no way we can have like a quick fat
00:45:33.040 flat balance so what what would be like this one trick that you can get to have focus and i
00:45:39.119 think it's boundaries like uh i had a couple things i do that limit my
00:45:44.880 work day and my personal day because at home they are very together and i'm just gonna briefly show you some
00:45:51.280 of these things like every day i start my day with a startup ritual i get presentable because we do
00:45:57.280 hangouts and i need to be properly dressed not undressed whatever and then uh i do what
00:46:04.240 i call i open the cafeteria i get like some fizzy water done i put coffee in
00:46:09.839 the aeropress i grind the beans and then i have a very good cup of coffee
00:46:15.920 uh the other thing that i think it's important after all of that done i get my cup of coffee i sit down and start
00:46:21.520 working and i think you you really need to eliminate distractions you need to find a way
00:46:28.400 to be in your mind office while in your home and what i found out was very good
00:46:34.480 for me was having a good pair of headphones the headphones are nice because they
00:46:40.000 allow you to focus on stuff and like people around you like my wife knows when i'm with the head headphones she
00:46:47.040 can talk to me the dog don't care about a lot about it and the bad goats just
00:46:52.079 get sad because he can't get my attention and i also have all sorts of gizmos like i plug the
00:46:58.640 headphones there so i can have even more like better sound and that way my wife just like needs to
00:47:05.280 throw stuff at me like wake up get out of here need something and i call that my focus flag it's like a way i can show
00:47:12.240 to the world and to myself that it's time to work i'm not here i may i may be
00:47:17.760 here in my body but my mind is doing other things for my company
00:47:24.640 so uh okay you got there you had your startup ritual you got your computer
00:47:29.680 your headset got the way so you can really start working
00:47:35.359 and then you're done because you do a lot of multitasking and you can do that
00:47:41.040 like why we spend all the time in hacker news on reddit because the it's way more fun
00:47:46.319 than do work like you have that huge list of things to do but you want to be on reddit so you need to cut down
00:47:53.520 multitasking you need to find ways to not change what you are doing so if you
00:47:58.880 are coding your coding you don't have like if gmail is low you should not open a new browser tab but without just gonna
00:48:06.240 browse a second your day's gone so what i've done for example i had these
00:48:12.560 these uh tiny arduino plugged into my computer so if someone send me an im message and
00:48:19.359 they are in a white list i would get a light that says you need to answer them because it's your boss or someone from
00:48:24.960 your team if it's not like you can answer whatever you have time so you need to find ways to not
00:48:32.839 multitask another important thing is don't work all the time when i started working remotely i said like yeah i need
00:48:40.480 to make sure i don't play video games all the time and i started working all the time and i would never stop so you
00:48:46.720 need to find a good balance between one thing and the other you should also spend time with others like don't spend
00:48:53.920 all the time in a computer like just working mindless like find time to spend
00:48:58.960 time with other people and also find time to learn new stuff like challenge yourself in cold wars do
00:49:06.240 some ken academy stuff like you need to have a good balance in your life to make
00:49:11.280 sure your work is works well and everything goes fine yep that's it thank
00:49:16.880 you so much
00:49:43.119 you