Top Banner
I-Tier: Node.js at Groupon Sean McCullough @mcculloughsean Enterprise Node.js Developer at Groupon
58

Transitioning Groupon to Node.js - EmpireJS 2014

Aug 19, 2014

Download

Engineering

Sean McCullough

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Transitioning Groupon to Node.js - EmpireJS 2014

I-Tier: Node.js at Groupon

Sean McCullough

@mcculloughsean

Enterprise Node.js Developer at Groupon

Page 2: Transitioning Groupon to Node.js - EmpireJS 2014

This Presentation is About...

• how Groupon's platform stopped working

• how we rewrote a part of it

• what went well and what didn't

Page 3: Transitioning Groupon to Node.js - EmpireJS 2014

Problems

Page 4: Transitioning Groupon to Node.js - EmpireJS 2014

Simple Start

• Monolithic Ruby on Rails app

• Sustained business through hyper-growth

• Small engineering team

• Simple product

Page 5: Transitioning Groupon to Node.js - EmpireJS 2014

Acquisitions

• CityDeal.de (Germany, most of EU)

• SoSata (India)

• Needish (South America)

Ran as separate platforms

Page 6: Transitioning Groupon to Node.js - EmpireJS 2014

One Monolithic Application

Page 7: Transitioning Groupon to Node.js - EmpireJS 2014

Actually, two separate monoliths

Page 8: Transitioning Groupon to Node.js - EmpireJS 2014

Move to Mobile

• ~50% of global transactions

• Streamlined user experience

• Mobile uses REST API

Page 9: Transitioning Groupon to Node.js - EmpireJS 2014

Two Facets of the Same Monolith

Page 10: Transitioning Groupon to Node.js - EmpireJS 2014

Two Facets X Two Monoliths

Page 11: Transitioning Groupon to Node.js - EmpireJS 2014

Business was Stuck

• Could not build features fast enough

• Wanted to build features worldwide

• Mobile and web lacked feature parity

• Could not change look and feel

• Difficult to internationalize

Page 12: Transitioning Groupon to Node.js - EmpireJS 2014

Platform was Broken

• Required cdn cached deal page

• Monolith was hard to scale

• Entire site would go down

• Couldn't support growth

Page 13: Transitioning Groupon to Node.js - EmpireJS 2014

The Plan

Page 14: Transitioning Groupon to Node.js - EmpireJS 2014

Start with the Frontend

• Unify global look and feel

• REST API already built for mobile

• Backend services are more complicated to unite

Page 15: Transitioning Groupon to Node.js - EmpireJS 2014

Design Goals

• Decouple teams

• Deploy apps on team schedule

• Allow for global design changes

• I18n/L13n

• Be small, do the minimum

Page 16: Transitioning Groupon to Node.js - EmpireJS 2014
Page 17: Transitioning Groupon to Node.js - EmpireJS 2014
Page 18: Transitioning Groupon to Node.js - EmpireJS 2014

Bakeoff

• Node

• MRI Ruby/Rails, MRI Ruby/Sinatra

• JRuby/Rails, Sinatra

• MRI Ruby + Sinatra + EM

• Java/Play, Java/Vertx

• Python+Twisted

• PHP

Page 19: Transitioning Groupon to Node.js - EmpireJS 2014

Why Node.js?

• Vibrant community

• NPM!

• Frontend developers know javascript

• Performant enough

• Easy scaling (process model)

Page 20: Transitioning Groupon to Node.js - EmpireJS 2014

Why Node.js Javascript?

• Front-end devs know Javascript

• Leverage existing knowledge on server

Page 21: Transitioning Groupon to Node.js - EmpireJS 2014

Stack

• CoffeeScript (hi haters!)

• Express

• Mustache & custom view engine

• Custom asset pipeline

Page 22: Transitioning Groupon to Node.js - EmpireJS 2014

Boundaries

• Apps only talk to REST API and Memcached

• Layout is in a separate application

• Shared common asset bundle

Page 23: Transitioning Groupon to Node.js - EmpireJS 2014

Design Goals

• Simple controllers

• Render from the server

• Skip fancy performance optimizations

• Make the API a bottleneck

• Resilience when services fail

Page 24: Transitioning Groupon to Node.js - EmpireJS 2014

Simple Design

module.exports = main: ( {attributes, renderCallback} ) -> # Presenter that sets the layout view = presenters.page 'subscribe', attributes

# Grab the list of all the divisions grouponAPI.fetch { endpoint: 'divisions' }, (err, {divisions}, details) ->

# If there’s an error, bail and pass the error along return renderCallback err if err?

divisionsPresenter = presenters.divisions divisions, { currentDivision: attributes.query?.division_p }

view.set { divisions: divisionsPresenter }

render.pageHtml view, renderCallback

Page 25: Transitioning Groupon to Node.js - EmpireJS 2014
Page 26: Transitioning Groupon to Node.js - EmpireJS 2014

Subscribe Page

• Simple application

• Partial implementation

• Proved out the concept

Page 27: Transitioning Groupon to Node.js - EmpireJS 2014
Page 28: Transitioning Groupon to Node.js - EmpireJS 2014

Growing Pains

• Max sockets

• Breaking our infrastructure

Page 29: Transitioning Groupon to Node.js - EmpireJS 2014
Page 30: Transitioning Groupon to Node.js - EmpireJS 2014

New problems

• User authentication

• More service calls

• Complicated routing

• More traffic

• Share look and feel

Page 31: Transitioning Groupon to Node.js - EmpireJS 2014
Page 32: Transitioning Groupon to Node.js - EmpireJS 2014
Page 33: Transitioning Groupon to Node.js - EmpireJS 2014

grout

Switchboard for incoming requests to I-Tier applications

• domain

• locale

• country

• experiments

Page 34: Transitioning Groupon to Node.js - EmpireJS 2014

grout

• groupon.com/deals/my-awesome-deal

• itier-deal-page-vip.snc1/deals/my-awesome-deal

• groupon.de/browse/berlin

• itier-browse-page-vip.lup1/browse/berlin

Page 35: Transitioning Groupon to Node.js - EmpireJS 2014

grout

• Experiments between different applications on the same URL

• Testing between alternative implementations (including the legacy monoliths!)

Page 36: Transitioning Groupon to Node.js - EmpireJS 2014
Page 37: Transitioning Groupon to Node.js - EmpireJS 2014
Page 38: Transitioning Groupon to Node.js - EmpireJS 2014

gconfig

• Configuration as a service

• Some config can change on the fly

• Config can be promoted from uat -> staging -> prod

Page 39: Transitioning Groupon to Node.js - EmpireJS 2014
Page 40: Transitioning Groupon to Node.js - EmpireJS 2014

Layout

• Distribute layout as library

• Use ESIs for top/bottom of page

• Apps are called through a “chrome service”

• Fetch templates from service

Page 41: Transitioning Groupon to Node.js - EmpireJS 2014

Layout Service

• Independent rollouts

• Changes can be shipped without re-deploying all apps

• Easy to use in development

Page 42: Transitioning Groupon to Node.js - EmpireJS 2014

Layout Service

• Uses semantic versioning

• Roll forward with bug fixes

• Stay locked on a specific version

• Enable site-wide experiments

Page 43: Transitioning Groupon to Node.js - EmpireJS 2014
Page 44: Transitioning Groupon to Node.js - EmpireJS 2014
Page 45: Transitioning Groupon to Node.js - EmpireJS 2014

Rewrite All The Things!

Page 46: Transitioning Groupon to Node.js - EmpireJS 2014

Rewrite

• Get the whole company to move at once

• Supporting two platforms is hard

• Transition from June 2013 to September 1, 2013

Page 47: Transitioning Groupon to Node.js - EmpireJS 2014

Rewrite

• ~150 developers

• Global effort

• Feature freeze – A/B testing against mostly the same features

Page 48: Transitioning Groupon to Node.js - EmpireJS 2014

What Went Well

Page 49: Transitioning Groupon to Node.js - EmpireJS 2014

It worked!

Page 50: Transitioning Groupon to Node.js - EmpireJS 2014

Webpages got faster

Page 51: Transitioning Groupon to Node.js - EmpireJS 2014

Sustained record traffic

Page 52: Transitioning Groupon to Node.js - EmpireJS 2014
Page 53: Transitioning Groupon to Node.js - EmpireJS 2014

What Didn't Go Well

Page 54: Transitioning Groupon to Node.js - EmpireJS 2014

Negatives of SOA

• Increased testing burden

• Tooling needs to catch up

• Increased operational overhead

Page 55: Transitioning Groupon to Node.js - EmpireJS 2014

Culture Problems

• Changed team workflow

• Teams are silos

• Code quality varies

Page 56: Transitioning Groupon to Node.js - EmpireJS 2014

Next Steps

• Better resiliency to outages

• Distributed tracing

• International (launching now)

• Open Source - Testium

Page 57: Transitioning Groupon to Node.js - EmpireJS 2014

tl;dr

• Kill web monolith

• Federated frontend

• Service oriented architecture

• grout

• gconfig

• Layout service

Page 58: Transitioning Groupon to Node.js - EmpireJS 2014

Thanks!@mcculloughsean

empirejs 2014