Groupon’s Global Deal with Node.js

If you want to find a deal, a common place to go is Groupon. This popular coupon portal features more than 425,000 active deals and is available in North America, Europe, Asia and South America. That’s a lot of deals, enticing a lot of users to go on the site every day — whether they are at home browsing or on the go.

A few years back, the company need to expand globally and not just on the web. More and more customers were buying on mobile, and they wanted to make this experience as seamless as possible. In order to accomplish this, the Groupon engineering team decided to change from Ruby to Node.js.

In this Node.js Enterprise Conversation, Mikeal Rogers talks with Adam Geitgey, director of software engineering at Groupon, about why Groupon transitioned to Node.js and how it helped the company expand globally and into areas like mobile over the last few years.

Here’s a transcript of Mikeal’s chat with Adam:

Mikeal Rogers: Hey everybody. Welcome to Enterprise Conversations from the Node.js Foundation.

I’m Mikeal Rogers and with me is Adam Geitgey, director of software engineering at Groupon. Hey Adam, how you do?

Mikeal Rogers: Let’s just get into a little bit about, tell me about your role at Groupon and how you all are using Node.js?

Adam Geitgey: Sure, so I’m a director of engineering at Groupon. I’ve been at Groupon five years. When I first started at Groupon we were totally a Ruby on Rails shop and everything you know as groupon.com was one big monolith. A couple years ago, about three, three, four years ago we decided to rebuild that and we looked at a bunch of software platforms and we decided that for a lot of reasons Node.js was the one we wanted to build with. Since then we’ve rebuilt our entire web layer on top of Node.js.

My job now is I manage the team that builds that platform and builds the framework that the other product teams use to build and ship Node apps in production. We also build and release several open source libraries that we built along the way in that process. We have a couple things like gofer which is an API client library we use to talk to back-end services, a caching library called node cached, and testium which is a Selenium based browser integration testing tool for Node.

Mikeal Rogers: It sounds like you’re really using it all over. You have a back-end back-end and then a kind of front-end back-end tier, as well as testing and front-end. Is there anything that you’re not doing with Node.js?

Adam Geitgey: Yeah, so I would say our heaviest use is definitely on the web tier.

As for architecture, we have a bunch of back-end services, something like 300, we have an API integration layer on top of that, and then we have our client apps. We consider our website one of our client apps. We have iOS, Android, and web. All of the web layer is built in Node. A lot of the back-end is built in the mix of Java. There’s some Ruby and a few other things, but mostly Java.

We use it very heavily for our front-end and then kind of here and there for other uses, a couple back-end purposes, but really the web is our biggest use of Node. We’ve got something like 70 production Node apps right now, and we use that to support traffic in 30 countries and 4 data centers that we run.

Mikeal Rogers: Wow, wow, that’s a really big use case. That’s great. I mean as you moved over to Node, and you mentioned that were built on some other stuff for a while, then you kind of migrated to Node. What were some of the large effects and results that you got when you started moving to Node, both in terms of your team and then also in terms of the infrastructure?

Adam Geitgey: Yeah. Our motivation originally wasn’t so much like a language choice. It was more we had this monolithic app that had worked well for a long time but we outgrew it and it just become hard to maintain. In Groupon’s history we also made a bunch of acquisitions years ago, so we ended up with not just our Rail stack, but with a Java stack in Europe and a PHP stack in South America, and we were looking for something to replace all of those.

The reason we chose Node for that was both because it was JavaScript is as close to a universal language as you can get with the people building on the front-end, so it was the easiest for all of those people to learn and use. Also we tested the performance and scaling of it and Node worked well enough that we were pretty happy with it. Not only did it allow us to unify our development and build with a language that was easy for people to learn or they already knew, but also gave us some performance improvements in some cases, which all together was a win-win for us.

Mikeal Rogers: That’s great. That sounds like a lot of stories that I’ve heard actually. It’s good. Although not all the stories that I hear include multiple acquisitions

Adam Geitgey: Yeah, it’s kind of a messy history but it’s much much simpler now. There also have been some cool side effects, like sometimes we’ll write code to support a web app in JavaScript like a service client library or a caching library or something, and then we’ll have another use case that’s also in JavaScript and we’ll be able to reuse that same code. We don’t go for that isomorphic JavaScript trying to make everything on the front-end and back-end exactly the same, but we had lots of cases where we could reuse code that was really nice and helpful.

Mikeal Rogers: Yeah, I don’t think anybody really does that. I think that everybody does a little bit of that and the real benefits are just having a unified language and skill set and-

Adam Geitgey: Yeah, exactly

Mikeal Rogers: Looking into the future a little bit, what do you expect to be doing with Node and in Groupon moving forward?

Adam Geitgey: Yeah, we are totally invested in Node for the web platform. We have a lot of people and we’ve tried to standardize on Java for the back-end side. We’ve had a lot of cases where a team is really familiar with Node from building a front-end service and needs to build the back-end service to support that, and they’ve been asking to use Node in the back-end. We’ve seen more and more cases of that, especially for internal tools were we’re looking at kind of expanding the use cases we can use Node for in the company.

We’re also really excited about just the speed that Node itself is improving and we’re pretty much all on Node 4 in production now but we’re really excited about Node 6. As soon as the LTS version is out we plan to switch pretty much everything over to it. One of the nice things about that is it has enough of the new ES2015 features baked into it that we won’t be using any kind of transpiling or anything to write another in JavaScript, which is our developers really like. In the past because of our history with Ruby and some other reasons we’ve been using CoffeeScript a lot, and that’s a great chance for us to finally migrate off of CoffeeScript and pretty much standardize on plain JavaScript, which is also pretty exciting for us.

Another big thing working on now is in moving away from a model where our developers maintain their own servers and deploy their Node app to three or four or 10 servers and moving to a model where we provide them a cluster of servers and their app just runs on it more in like a Heroku model. We’re using Mesos to build up that cluster and we currently have that in production in Europe and we’re looking to expand that for all of our Node services, which I think is a nice sweet spot between a language and framework that’s easy to build in, but also makes operations a lot easier for the app teams that manage it, so we’re pretty excited about that too.

Mikeal Rogers: Right. So you’re moving to an infrastructure that’s more kind of language agnostic?

Adam Geitgey: Yes

Mikeal Rogers: You’re using Mesos and some containers I imagine for all that stuff?

Adam Geitgey: Yeah, the apps will run in Docker containers and the cluster will be managed with a mix of the basic platform for Mesosphere and then some other tooling integrations and load balancer stuff that we built or integrated with it here at Groupon.

Mikeal Rogers: I mean it sounds like the impetus for this is to do some Node stuff, but you can also use other languages, once you build out this infrastructure as well. I mean what do you see as the advantages of using Node inside of that infrastructure?

Adam Geitgey: Well, the reason we started with Node is really because it was our most uniform platform at Groupon. Even though we use Java for a lot of back-end services, the frameworks and ways Java was used was pretty diverse. This gives us a way to move a large chunk of our software onto one platform in one swoop and figure out all the problems that come with that, and especially all the problems of serving traffic directly to the consumers. Then after we tackle that, then the next step we want to do is the remaining stuff like figure out how to host databases on that, or figure out the right way to interface databases with apps running in it. It just gave us a good way to contain the problem, while also freeing up our developers from maintaining their own servers which is a big win for us.

Mikeal Rogers: That sounds awesome, really exciting stuff.

Adam Geitgey: Yeah.

Mikeal Rogers: Yeah, great, that was great man. Thanks for coming on.

Adam Geitgey: Yeah, thanks for having me. This is really fun. Appreciate it.

Mikeal Rogers:Yeah, thanks for your time. Great.

Want to Watch More?

Follow our YouTube channel playlist to keep up with future episodes. And, if you think you have a good topic on this, send us a message via Twitter and we’ll see if it’s a fit.