Top Banner
SCALING GILT From Monolith Ruby App to Distributed Scala Micro-Services #NYCTECHTALKS Lead Engineer - GILT Podium => http://bit.ly/podiumapp Yoni (Jonathan) Goldberg
60

Scaling Gilt: from monolith ruby app to micro service scala service architecture

Sep 08, 2014

Download

Technology

Gilt Tech Talks

Gilt Lead Software Engineer Yoni Goldberg delivered this presentation at the NYC Tech Talks' January 14, 2014 meetup at Gilt.
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: Scaling Gilt: from monolith ruby app to micro service scala service architecture

SCALING GILTFrom Monolith Ruby App

to

Distributed Scala Micro-Services

#NYCTECHTALKS

Lead Engineer - GILT Podium => http://bit.ly/podiumapp

Yoni (Jonathan) Goldberg

Page 2: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ABOUT ME- Leading the Popeye Team

- Sale Personalization, Loyalty, SEO Post-purchase, Login/Registration flows

- MIT CS BS/Meng | Google | IBM | IDF

- Brooklyn | Coffee | Arduino | Running | Kite Surfing |Online Collaboration | Poker

Excited to be part of the NYC Tech community

Page 3: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THE LESSONS AND CHALLENGES THATWE HAD/HAVE WITH

MICRO-SERVICE ARCHITECTURE

Page 4: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 5: Scaling Gilt: from monolith ruby app to micro service scala service architecture

Flash Sales Business Founded in 2007

Top 50 Internet-Retailer~150 Engineers

WHAT IS GILT?

Page 6: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 7: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ANOTHER WAY TO LOOK AT GILT

Three day traffic pattern

Page 8: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THE CLASSICSTARTUP STORY

Page 9: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THE EARLY DAYS2007 - Ruby on Rails the hottest new thing

The goal was to get to market fast

Page 10: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 11: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WE WERE ABLE TO HANDLE OURTRAFFIC PRETTY WELL

Page 12: Scaling Gilt: from monolith ruby app to micro service scala service architecture

UNTIL LOUBOUTIN CAME TO GILT

Page 13: Scaling Gilt: from monolith ruby app to micro service scala service architecture

TECHNOLOGY PAIN POINTS - 2009Spike required to launch 1,000s of ruby processesPostgres was overloadedRouting traffic between ruby processes sucked

|Note to self| - hide from the ruby fan boys

Page 14: Scaling Gilt: from monolith ruby app to micro service scala service architecture

DEV PAIN POINTS1000 Models/Controllers, 200K LOC, 100s of jobsLots of contributors + no ownershipDifficult deployments with long integration cyclesHard to identify root causes

Page 15: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WE NEEDED TO SOLVETHE PROBLEM FAST

Page 16: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THREE THINGS HAPPENEDStarted the transition to the JVMM(a/i)cro-Service Era StartedDedicated data stores

Page 17: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WHY JVM?Widely adoptedStableBetter support for concurrencyBetter GC vs MRI

Page 18: Scaling Gilt: from monolith ruby app to micro service scala service architecture

FIRST 10 SERVICES

Page 19: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 20: Scaling Gilt: from monolith ruby app to micro service scala service architecture

We solved 90% of our arch scaling problemBut not the Dev points

Page 21: Scaling Gilt: from monolith ruby app to micro service scala service architecture

PAIN POINTSSpike required to launch 1,000s of ruby processesPostgres was overloadedRouting traffic between ruby processes suckedNew services became semi-monolithic1000 Models/Controllers, 200K LOC, 100s of jobsLots of contributors + no ownershipDifficult deployments with long integration cycles

Page 22: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WHY WE DOUBLED DOWN ON MICRO-SERVICES

Empower teams and ownershipSmaller scopeSimpler and Easier deployments and rollbacks

Page 23: Scaling Gilt: from monolith ruby app to micro service scala service architecture

MICRO SERVICE ARCHITECTURESTARTED TO GET TRACTION

Page 24: Scaling Gilt: from monolith ruby app to micro service scala service architecture

AS OF LAST WEEK WE HAVE MORETHAN

450 SERVICES

Page 25: Scaling Gilt: from monolith ruby app to micro service scala service architecture

APP BOOTSTRAPrake bootstrap:admin-web # Bootstrap a admin-web service rake bootstrap:babylon-docs # Bootstrap a babylon-docs service rake bootstrap:client-server-core # Bootstrap a client-server-core service rake bootstrap:jersey-java # Bootstrap a jersey-java service rake bootstrap:jersey-scala # Bootstrap a jersey-scala service rake bootstrap:play # Bootstrap a play service rake bootstrap:play-ui-build # Bootstrap a play-ui-build service rake bootstrap:sbt-library # Bootstrap a sbt-library service rake bootstrap:schema # Bootstrap a schema service

Page 26: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WE BEGAN THE TRANSITION TO SCALAAND PLAY

LOSA - Lots Of Small AppsSame motivation and benefits of Micro-Service

Architecture

Page 27: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 28: Scaling Gilt: from monolith ruby app to micro service scala service architecture

NEW CHALLENGESDev/Integration EnvironmentsWho owns this service!?MonitoringDeployments and Testing (Functional/Integration)

Page 29: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ON DEV/INTEGRATION ENVIRONMENTSThe hardware is not strong enoughNo one wants to compile 20 services

Page 30: Scaling Gilt: from monolith ruby app to micro service scala service architecture

EACH TEAM HAS A STAGING ENVSERVICE_PORTS=[ 4001, #listing-service 8235, #svc-user-set 9420, #svc-free-fall 7895, #svc-Loyalty 8155, #web-loyalty 9410, #web inventory status 7898, #admin-loyalty 7899, #notification 7102, #rouge 9530, #svc-component 6802, #svc-waitlist-submit 4066, #svc-action-sale ....

PORT_FORWARD_ARGS=SERVICE_PORTS.map { |port| ['-L', "#{port}:localhost:#{port}"] }

exec(*[%w{ssh -a -C -N -n}, PORT_FORWARD_ARGS, GW_HOST].flatten)

Page 31: Scaling Gilt: from monolith ruby app to micro service scala service architecture

STAGING DIFFICULTIES:Hard to keep all the services up to dateMaxed our staging env capacitiesRequires to have internet connection for some of theservices (e.g LOSA-apps)

Page 32: Scaling Gilt: from monolith ruby app to micro service scala service architecture

The Future

Page 33: Scaling Gilt: from monolith ruby app to micro service scala service architecture

DOCKERAn extension to Linux Containers (LXC)

DecentralizationSimple ConfigurationsMuch lighter than a VMImmutableSupports services and platforms

Page 34: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ON OWNERSHIP "code stays much longer than people" - SB

Page 35: Scaling Gilt: from monolith ruby app to micro service scala service architecture

CODE OWNERSHIP

Page 36: Scaling Gilt: from monolith ruby app to micro service scala service architecture

CURRENT APPROACHCode Review!Code Review!Code Review!Team owns services, not individual developersOwnership transfer

Page 37: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 38: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 39: Scaling Gilt: from monolith ruby app to micro service scala service architecture

DATA OWNERSHIP

Page 40: Scaling Gilt: from monolith ruby app to micro service scala service architecture

WE TRANSITIONED TO MICRO-DBSThird of the services have their own

MongoDB

Postgres

Voldemort

Page 41: Scaling Gilt: from monolith ruby app to micro service scala service architecture

MANAGE MICRO-RELATIONAL DBS SCHEMA EVOLUTION MANAGER

https://github.com/gilt/schema-evolution-manager

Page 42: Scaling Gilt: from monolith ruby app to micro service scala service architecture

PRINCIPLES OF SCHEMA EVOLUTION MANAGER

Can manage the schema evolutions in a Git repoSchema changes are deployed as tar fliesNo rollbacksSchema changes are required to be incremental

Page 43: Scaling Gilt: from monolith ruby app to micro service scala service architecture

echo "create table releases (id integer)" > new.sql sem-add ./new.sql #Created a git commit sem-dist # generates the tar e.g schema-ion-cannon0.0.2.tar.gz # Scp and untar on your server cd schema-ion-cannon-0.0.2 sem-apply host --localhost --name ion-cannon --user ion-cannon

Page 44: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ON MONITORING

Page 45: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 46: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THE TOOLS WE USE

graphite / openTSDB

Page 47: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 48: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 49: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 50: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 51: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 52: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ON DEPLOYMENTS AND TESTING

(FUNCTIONAL/INTEGRATION) "Testing is HARD" - the dev that sits on your left

Page 53: Scaling Gilt: from monolith ruby app to micro service scala service architecture

THE CHALLENGES THAT WE FACED:Hard to execute functional tests between servicesFrustrating to deploy semi-manually (Capistrano)Scary to deploy other teams services

Page 54: Scaling Gilt: from monolith ruby app to micro service scala service architecture

SBTMotivation: Scala adaptionComplex Scala syntaxCool features: ~test, shell, consoleHard to debug

Page 55: Scaling Gilt: from monolith ruby app to micro service scala service architecture

GILT-SBT-BUILDSimple config for all the servicesPulls many plugins: [nexus, testing, RPMs, run scripts, Monitoring,SemVer, ...]Custom commands (e.g 'sbt release')

Page 56: Scaling Gilt: from monolith ruby app to micro service scala service architecture

object Build extends ClientServerCoreProject with Dependencies { val name = 'svc-sale-activation' val coreDeps = .... val serverDeps = ... val clientDeps = ...

override val ioncannonTrack = IonCannon.FastTrack }

Page 57: Scaling Gilt: from monolith ruby app to micro service scala service architecture

ION-CANNON + SBTRun functional/Selenium tests on dedicated EnvSupports Canary releasesEasy rollbacksIntegrated health checks

Page 58: Scaling Gilt: from monolith ruby app to micro service scala service architecture
Page 59: Scaling Gilt: from monolith ruby app to micro service scala service architecture

MAIN TAKEAWAYSSimplicity - Do you really need it?We feel that it was the right choice for usMicroServices promise works for most casesAs of 2014 - You will need to invest in Tools!

Page 60: Scaling Gilt: from monolith ruby app to micro service scala service architecture

Keep in touch: [email protected]

PODIUM TIMEWe are hiring...

www.yonigoldberg.com