from a monolith to microservices + rest the evolution of linkedin’s service architecture by steven...

43
From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Upload: gerardo-henshall

Post on 14-Dec-2015

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

From a monolith to microservices + RESTThe evolution of LinkedIn’s service architecture

by Steven Ihde and Karan Parikh (LinkedIn)

Page 2: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)
Page 3: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)
Page 4: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Leo

● Our original codebase● Java, Servlets, JSP, JDBC

Leo

Oracle4

Page 5: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Remote Graph

● Graph: member-to-member connection graph

● Complex graph traversal problems not suited to SQL queries

● RPC was used to keep it separate from Leo● Our first service

5

Page 6: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Remote Graph

Leo

Oracle

GraphRPC

JDBC

Databus

6

Page 7: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Mid/Back Tier Services

● “Back” tier services encapsulate data domains

● “Mid” tier services provide business logic● We applied the service pattern to many

domains, e.g. member profiles, job postings, group postings

7

Page 8: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Front Tier Services

● “Front” tier services aggregate data from many domains

● Transform the data through templates to present to the client

● Should be stateless for scaling purposes

8

Page 9: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Service Explosion

● Over 100 services by 2010● Most new development occurring in

services, not Leo● Site release every two weeks

9

Page 10: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Architectural Challenges

● Test failures● Incompatibilities● Complex orchestration● Rollback difficult or impossible● Complex dependencies between services

10

Page 11: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Microservices?

● Services were fine grained● But monolithic build and release process

did not allow us to realize the benefits of microservice architecture

11

Page 12: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Solutions

● Continuous delivery● Break apart the code base● Devolution of control● Strict backwards compatibility● Better defined boundaries between tiers

12

Page 13: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Continuous Delivery

● Shared trunk● Pre- and post-commit automated testing● Easy promotion of builds to production

environment

13

Page 14: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Decentralize Codebase

● Separate, independently buildable repositories

● Shared trunk within each repository● Versioned binary dependencies between

repositories

14

Page 15: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Devolution of Control

● Service owners control release schedule, release criteria

● Service owners are responsible for backwards compatibility

● Services must release independently

15

Page 16: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Backwards compatibility

● Insulates teams from each other at runtime● Allows service owners to deploy on their

own schedule without impacting clients

16

Page 17: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Boundaries Between Tiers

● Limit aggregation to the front tier● Limit crosstalk in the back tier:

“superblocks”

17

Page 18: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Boundaries Between Tiers

18

Page 19: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Java RPC

● Difficult to maintain backwards compatibility● Verb-centric APIs● Use case specific APIs● Difficult to navigate the proliferation of APIs

19

Page 20: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Rest.li plus Deco equals Microservices at LinkedIn

Page 21: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

What is Rest.li?

“Rest.li is an open source REST framework for building robust, scalable RESTful architectures using type-safe bindings and asynchronous, non-blocking I/O.”

Primarily JSON over HTTP.

21

Page 22: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Why Rest.li?

● Polyglot (frontend) ecosystem - Java, Scala, Python, Node.js, Objective-C

● Uniform service interfaces (REST)

22

Page 23: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

The Rest.li stack

Rest.li Data layer and RESTful operations

D2 Dynamic discovery and load balancing

R2 Network Communication

23

Page 24: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Request Response (R2)

● REST abstraction that can send messages over any application layer protocol (HTTP, PRPC (old custom LinkedIn protocol))

● Client - fully asynchronous Netty● Server - Jetty, Netty (experimental)

Rest.liD2R2

24

Page 25: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Dynamic Discovery (D2)

● Apache ZooKeeper● Dynamic server discovery● Client side software load balancing● D2 service

Rest.li

R2D2

25

Page 26: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Rest.li

● Data using PDSCs (Pegasus Data Schemas)

● RESTful API that developers use to build services

● CRUD + finders + actions● API and data backwards

compatibility checkingR2D2

Rest.li

26

Page 27: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

830 Rest.li resources.

90 billion Rest.li calls/day across

multiple datacenters. 65% service-to-service calls.

Page 28: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

What is deco?

28

Page 29: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Aside: Normalized Domain Models● Links over inclusion (denormalization)● URNs are fully qualified

foreign keysInfluencerPost

Long idString title

String contentURN author

Member

Long idString firstNameString lastNameString summaryURN company

urn:li:member:123

29

Page 30: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

What is Deco?

● URN resolution library● What data you want, not how you want it

Time1

23

30

Page 31: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Deco Example: Influencer Post

Dummy Postby Karan Parikh

at LinkedIn

Hi QCon!

/influencerPosts

/influencerPosts

/companies

/profiles

31

Page 32: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Deco Example: Influencer Post

deco://influencerPosts/123?projection=(title, content, author~(firstName, lastName, company~(companyName)))

32

Page 33: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Three services.One client call.Deco.

Page 34: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Rest.li plus Deco equals Microservices at LinkedIn

Page 35: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

How Rest.li enables Microservices

● Rest.li + D2 facilitate domain specific services

● Services can easily configure clients via D2● D2 helps us scale the architecture

35

Page 36: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

How Deco enables Microservices

● Deals with service explosion● Abstracts away services from clients

36

Page 37: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Challenges

● Coordinating a massive engineering effort. (LiX to the rescue!)

● Ensuring uniform RESTful interfaces● Performance

Rest.li API Hub37

Page 38: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Wins

● All languages talk to the same service● Developer productivity● Reduction of hardware load balancers● Ability to expose APIs directly to third

parties

38

Page 39: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)
Page 40: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)
Page 41: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

LinkedIn Microservices

Page 42: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

Questions?

Page 43: From a monolith to microservices + REST The evolution of LinkedIn’s service architecture by Steven Ihde and Karan Parikh (LinkedIn)

References and links● Rest.li: http://rest.li/● Rest.li API Hub: https://github.com/linkedin/rest.li-api-hub ● Rest.li user guide: https://github.com/linkedin/rest.li/wiki/Rest.li-User-Guide● Modeling resources with Rest.li:

https://github.com/linkedin/rest.li/wiki/Modeling-Resources-with-Rest.li● LinkedIn engineering blog posts about Rest.li:

http://engineering.linkedin.com/architecture/restli-restful-service-architecture-scale http://engineering.linkedin.com/restli/linkedins-restli-moment

● LinkedIn’s GitHub projects http://linkedin.github.io/

43