Node.js on the Road: David Alexander

Node.js on the Road is an event series aimed at sharing Node.js production user stories with the broader community. Watch for key learnings, benefits, and patterns around deploying Node.js.

SPEAKER:
David Alexander Lead Software Engineer
Koko FitClub

Alright, so without any more waiting, I'm David Alexander, Lead Software Engineer at Koko FitClub, and I'm here today to talk to you how Koko is using Node in the digital gym. So, before we get going, has anyone here heard of Koko before, Koko FitClub? Excellent, excellent. Anyone here a member, actual member.

We've got an actual member. Great! So, for the rest of you, I'm going to give a brief introduction of what Koko is, play a little video, give you taste of what's it's like inside a club, then I'll start talking about how we combine fitness and technology, and then we'll go into where Node fits in, specifically how we're using it, and our observations. So here's the video.

It's a total body workout. The computer allows me to be more precise in my workouts. I was able to lose 10 pounds, and take two inches off my waist, and I've kept that off for three years now, and I just feel great. So, I owe that all to Koko. It's really a full integration of the most current exercise science melded with current technology, to help make sure we're removing all the obstacles that get in people's way, their fitness, and help people to get the best workouts they can get in limited time, and customized for their body.

It tells you the weight, it tells you where the settings are, it has little demos, the 15 minute cardio workouts are such a great way to get that in everyday. I feel like the statement is that if I'm doing it after four years, and I work full time, and I have kids, that it's something that works with your life. And that's what I was never able to find an another gym.

When I arrive at Koko, I grab my key and then I pick one of the Koko smart trainer machines, and I put the key in, and then the machine guides me through the workout from start to finish. I don't have to think about what I'm going to do. It takes care of it for me. Our goal here is to make sure that everyone is successful through the workout,

everyone that walks in the door. We've found a way to use technology to get people the results that they could get through working one-on-one with a personal trainer, but without the cost, without some of the time commitment. It's really a unique and incredibly effective way to workout. The people here are great, it's a total community.

I like to come to the gym. It feels like a place that you want to stay a part of so you're getting the exercise, but you're also part of your community. Koko is completely different than any gym I've been to. It is so tailored to you and your specific needs. I find that since I've been working out at Koko, I've been here for about a year and a half, that I see that I can lift more weight, I'm getting stronger than I've ever been before, and in the least amount of time.

I truly feel I am in the best shape of my life ever, and that is a true testament to Koko and their philosophy.

So that gives you a little taste
of what Koko is. So the video alluded to how we are combining fitness and technology. If you were to walk into one of our clubs, you'd see three types of devices.

One for cardio, or as we say in Boston cahdio, strength, and body composition. So, if you're drill and look at these more closely, our body comp device is actually a sophisticated scale, we call it FitCheck. It measures eight aspects of your body composition, everything from your total percent body fat, % body fat in your right arm, or your legs.

The key data points we're interested in, and that we use to measure people's progress is % body fat and lean muscle level. The next device, our strength device, we call it the smart trainer. It looks like a fancy home gym with a computer screen on it, but that screen's actually doing two important things. First, it's tracking what you do. We've got a sensor on the weight stack, so we know where you put the pin, we know how much weight you're lifting.

We've also got sensors on the cables, so we know how fast those cables are moving and how far, and you combine that with prescription, as they talked about in the video, when a member comes in they tell us their goal, and that machine will prescribe a workout to help the member achieve their goal. It will tell them what exercises to do, how much weight to lift, how fast to lift the weight and for how long, and how many reps and sets, and when you combine the tracking with the prescription we can measure, we tell you what to do and we can measure how well you do it, and that lets us do some pretty interesting things, we'll talk about in a minute.

Next up is our cardio device, and like the Smart Trainer it's collecting data as you workout. It's collecting your speed, your incline. If you're on an elliptical machine, it's collecting your resistance and your heart rate. So we know how hard you're working. It's also prescribing exercise like the Smart Trainer. When a member gets on the machine, and selects a workout, an audio track will play with a personal trainer coaching you through that workout.

He's motivating you, he's telling you what settings to make and when, and he's trying to paint a mental picture of an experience of not being on that treadmill, but being outside hiking up a hill or climbing a mountain. And we reinforce that audio track with a visual experience, we've got pace bars on the screen that reinforce where your settings are supposed to be, and will cycle images in the background to help transport you into that different experience.

So those are the devices in the club, and they're collecting all this data. What do we do with it all? So it gets backed up in the cloud, to mykokofitclub.com, which is a site our members can log into, and they can get real time feedback on how they're doing. They can see, are they in the zone, are they not in the zone. For example the 27.8 gauge there, is telling that member that their body mass index is in the ideal zone, and that they're doing a good job.

They can see if they're improving over time, so the graph on the bottom left hand side is showing a member who's undergone a significant reduction in their percent body fat and has been able to maintain that over time. On the right side of that graph is showing a member that's increased their strength.

They can also see what they've been doing for workouts, and what's coming up next. They can also look at their accomplishments, so the image on the right hand side, you can see how many pounds you've lifted all time, or how many calories you've burned, or how far you've gone in cardio. We're also, like I mentioned in the previous slide, showing people how much leaner they've gotten and how much stronger.

But more important than all that, there's a gamification layer built into this. As I mentioned earlier, we're telling you what to do and we're measuring how well you do it, and depending on how well you do it, you get a certain number of Koko points and these points add up over time, and similar to the belt system in Karate, you can get different color lanyards for your Koko key. And what we found is that really helps drive engagement and keeps our members coming back to the clubs.

There's also a script development on the site as well. When a member comes in and tells us what their fitness goal is, we prescribe a nutrition plan for them, we recommend what to eat and how much to eat. For example in the image on the left, this member is on our burn plan so they want to burn body fat.

We're recommending that they keep based on their own activity level that they limit their caloric intake to about 2700 calories a day, and limit their healthy carb intake to 259 grams a day. So, that's how we're combining fitness and technology, and you're all sitting here thinking, "Great Dave, where does Node fit into all this? You haven't mentioned Node."

Right? So, how many people think we're using it in the cloud, on the site? No one. OK, we got one guy back there. How many people think we're using it somewhere in the club? Two people. How many don't care? All right. Couple of people, great. We're actually using it in the club. What you're looking at is an image of our next generation platform.


We're using Node to power it, to
drive this experience, and I'll drill into specifically how we're doing that in a minute, but first I want to set some context on how we ended up using Node on this device. If you flash back to March of 2012, and you look at the state of the devices in the club. We're on custom-built hardware that was over five years old, we were using an operating system that was no longer supported by the vendor, and easy things,

things that should have been really simple were really difficult to do. There was a lot of friction in our development process. We were on a technology stack that prevented us from delivering the experiences that we wanted to. So we sat down, and we set some requirements for what we wanted this new platform to be.

We wanted something that was open and lasting. Something that we could iterate quickly on, something that would allow us to leverage common skills on the market, something that was easily testable, and something where we didn't have to make compromises on the experiences we wanted to deliver. So our hardware guys were recommending a close to the metal approach, C/OpenGL.

We had some people that were familiar with C# from our .Net compact framework, utilities, and they were recommending Mono, and there were a group of people who were recommending HTML, CSS, and JavaScript. And our hardware guys kind of balked at that. They're like, you want to do HTML, CSS, and JavaScript on the device? It's not going to perform well.

And one of our colleagues at the time recommended we should look at Node. So he did a little spike, came back, and what he demonstrated looked really interesting. So what we actually decided to do was do a full blown proof of concept, and actually develop an application that would talk to the treadmill, and where you could get on it and workout. And we were able to deliver that P.O.C. in less than two months with two developers.

It met all of our requirements, and more importantly, it proved to our hardware guys and everyone else on the team, that HTML, CSS, and JavaScript were actually viable options for an embedded device.

So how are we using Node?
Now let's get into specifics. The devices are still in the club sending data up into the cloud, which is a Rails site by the way. We're using Chef to push updates to the devices, we're working on that right now, and we're using graphite and statsd to collect metrics from the devices and give us some insight into what's going on, so that one guy that raised his hands for we're using in the cloud, we kind of are with statsd.

OK, so back to the screen in our Next Gen platform. If you would look behind the covers of the screen, you would see our Next Gen architecture. OK, we're running a customize version of Ubuntu, and the devices we're talking to in the case of the picture, treadmill, elliptical machine, in the future it would be the Smart Trainer, and FitCheck, those we're doing that communication over serial ports so we're using Node serial ports for that.

The events bubble up from the devices, up into Node, and we do some processing on those messages, and pass them up into a custom single page app framework that we're running in the browser using DNode which wraps socks.js for the communication between Node and the browser. On the same, similarly, for the operating system we're using the standard off-the-shelf Node APIs file process etc. to talk to the operating system, and when a member inserts their key, listen for that event, have it bubble from the operating system up into Node into our single page app framework.

So in a nutshell, very high level, that's how our application works. Now, it was a little difficult getting a treadmill on the train, so you're going to have to settle for a video. And I'm going to play this, but actually before I start playing it, I just want to point out as I said earlier there would be an audio track of a personal trainer coaching you through the workout.

I've muted that track so I can talk about what's going on technically, I didn't want to compete with our trainer. So in a second, you can see my hand come in. I'm going to put USB key into the device, and that's going to bubble up an operating system level event into our app and you'll see a screen transition.

So we're reading the key (screen transition), so next I'm going to select a workout, and then you'll see me hit quick start on the treadmill, and the workout's going to start and that's an event bubbling up from the treadmill into our application. So now you'll start seeing me fiddling around with the speed and incline. I'm pretty slow, so I keep the speed kind of low, and notice the responsiveness of when I push the button and when the numbers are changing on the screen. I'm increasing the incline, so in a second you're going to see me, my hands sneaks underneath the off screen, I'm going to stop the workout.

That's going to raise another event from the treadmill up into our application and the workout, and you'll see a workout result screen. Come on Dave, so here I go, I'm going to hit the stop button. There's our result screen, now I'm going to pull that key out and you'll see an unmount event fire from the Operating System into our app. So that's how Koko is using Node. So let's talk about our experience with it so far.

We went to prod in a limited prod roll out to our Needham and Brookline location in September. So far we've had over 13,000 workouts, and our members are absolutely loving the experience. Overall, Koko's experience with Node, it's got a really small learning curve. It's really easy to get up to speed quickly, and the proof of concept we did, delivering it as fast as we did is a testament to that fact. We had to learn how to talk to the operating system, we had to learn to talk to the treadmill, and still we delivered the proof of concept in less than two months.

It's very easy to work with, and our devs are loving it. One of the things I personally like is, it's got a rich module ecosystem. There's a lot of building blocks you can leverage in building your applications, and all of this leads to faster iterations, and allows us to focus on delivering business value. I struggle to find anything bad to say about Node, but if I had to say one thing, we're a small shop, and this is more our problem, and it's a really nice problem to have, but at times it can be tough to keep up with all the updates. But again, it's a really nice problem to have.

So that's how Koko is using Node in the digital gym, my email is address is there, if anyone's got questions, my Twitter handle is there. We're hiring, so shoot me an email, if anyone wants to come down and see the treadmill, do a workout, shoot me an email. Thanks guys.
:

Sign up now for Instant Cloud Access Get Started