automatic discovery - microcph · automatic discovery of service metadata martina iglesias...

61
Automatic Discovery of Service Metadata Martina Iglesias Fernández [email protected] May 2017

Upload: others

Post on 28-May-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Automatic Discovery of Service Metadata

Martina Iglesias Fernández

[email protected]

May 2017

Page 2: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify scale

Page 3: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify Users

100M Active Users

50MPaid Subscribers 60 Countries

Page 4: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify tech

● +1000 tech employees

● +120 teams

● Microservices architecture (scale and work

independently)

Page 5: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify teams: squads

● Cross functional team

● Full, end to end ownership of features

● Autonomous

Page 6: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 7: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Artist page

Number of streams

Page 8: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Artist page

Artist Discography

Page 9: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Artist page

Artist Playlists

Page 10: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Artist page

Merchandise

Page 11: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Example: aggregating service

Artist

Discography Playcount Playlists Merch

Page 12: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify infrastructure

● ~1000 services

● The number of services grows as we add new

features

Page 13: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Spotify officesStockholm

BostonNew York

San Francisco

Gothenburg

Page 14: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Previous situation: lack of the big picture

● Microservices are easy to understand in isolation

but it becomes difficult to see the big picture

● Some people knew what was out there

Page 15: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

We all agree that we need some kind of

documentation

Page 16: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Previous situation: doc is spread out

● Each team had doc. in different places

● README.mk

● Markdown files in doc/

● Wiki

● Link to a document somewhere else

Page 17: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 18: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

System Z

Page 19: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

System Z

● Angular based web application

● Internal tool

● Catalogue of all our systems and its parts

● Very well integrated with our apollo services

● Easy to discover and access

Page 20: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

System Z model● Components and Systems

● Components can be different things:

○ Libraries○ Data pipelines○ Views in the client○ Data store○ Service

Page 21: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 22: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 23: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 24: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 25: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 26: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

artist

playcount

discography

merch

playlist

loadbalancer

Page 27: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

System Map

● Generated from runtime and declared

dependencies

● Uses graphviz

Page 28: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

How does System Z work

Page 29: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 30: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

DNS

System Z overview

Register artist serviceService-info.yaml

Component: artistDNS: _artist._httpOWNER: kiwi

SYSTEM Z(backend)

artist-1.spotify.com

Lookup machines

HTTP req to /meta/0/

Page 31: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Apollo and apollo-meta

Page 32: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Apollo

● Java libraries for writing microservices

● Open Source

● https://github.com/spotify/apollo

● In production since 2014

Page 33: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

APOLLO SERVICE

MODULES

OKHTTP-CLIENTJETTY-HTTP-SERVER

APOLLO-CORE(manages lifecycle)APOLLO-API APOLLO-META

SERVICE LOGIC

interacts

uses

Apollo service overview

Page 34: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Apollo-meta

● Metadata module

● Open Source

● https://github.com/spotify/apollo-meta

● Exposes endpoints with metadata of the service

● Runtime generated - source of truth

Page 35: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Example: Creating a route

Route.async("GET", "/v1/artist/<id>",

request-> getArtist(request))

.withDocString("Get the artist page for a specific id.")

)

Page 36: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Endpoints exposed by apollo meta

1. Instance information2. Configuration3. Endpoints4. Call Information

Page 37: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

1. Apollo-meta: instance info

● Collects information about the service: build

version and uptime

● Useful to get the full picture when making rolling

upgrades.

Page 38: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

1. Apollo-meta: instance info

curl http://artist-a1/_meta/0/info =>

{ "result": { "buildVersion": "artist 2.1-SNAPSHOT", "containerVersion": "apollo-standalone 1.1.0", "systemVersion": "java 1.8.0_60", "serviceUptime": 303577.347 }}

Page 39: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

2. Apollo-meta: configuration

● The current loaded config of the service, possibly

filtered

Page 40: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

2. Apollo-meta: config

curl http://artist-a1/_meta/0/config =>{ result: { http: { server: { port: 8080 } } }}

Page 41: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

3. Apollo-meta: endpoints

● Lists the endpoints of the service

Page 42: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

3. Apollo-meta: endpoints

curl http://artist-a1/_meta/0/endpoints =>{ methodName: "/v1/artist/<id>[GET]", uri: "/v1/artist/<id>" method: [ "GET" ], docstring: "Get the artist page for a specific id.", queryParameters: []

},...

Page 43: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

4. Apollo-meta: call info

● Lists services that make incoming requests

● Lists all other services we make requests to

Page 44: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

4. Apollo-meta: call info

curl http://artist-a1/_meta/0/calls =>

incoming: { loadbalancer: { endpoints: [ uri: "/v1/artist/<id>", method: ["GET"], queryParameters: [catalogue, locale] ], }, },..

Page 45: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

4. Apollo-meta: call info

... outgoing: { discography: [], playcount: [], playlist: [], merch: [] } }}

Page 46: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Apollo meta <-> System Z

● System Z calls these endpoints

● Displays a merged version of all the data

Page 47: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

What other things can we do with System Z?

Page 48: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Manage deployments

Page 49: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 50: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Provision hardware

Page 51: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Discover other useful services

Page 52: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Dependency tracking

Page 53: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 54: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Ownership and alerting

Page 55: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users
Page 56: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Conclusions

Page 57: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

● Quicker access to relevant information

● Know immediately where to go when solving an

incident

● Quick way to check who is on-call for a service

● Less interruptions

● Less boring work

Situation now

Page 58: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

● Think about growth and scaling

● Automate documentation generation

● Put all the information related in one, easy to

access, place

● All related links in one place

Learnings

Page 59: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

● apollo

● swagger.io

● raml.org (jax-rs)

Documentation generators

Page 60: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Blog: labs.spotify.com

Martina [email protected]

Page 61: Automatic Discovery - MicroCPH · Automatic Discovery of Service Metadata Martina Iglesias Fernández martina@spotify.com May 2017. Spotify scale. Spotify Users 100M Active Users

Blog: labs.spotify.com

Martina [email protected]

Questions?