Top Banner
Automatic Discovery of Service Metadata Martina Iglesias [email protected] September 2016
43

Automatic Discovery of Service Metadata for Systems at Scale

Jan 19, 2017

Download

Technology

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: Automatic Discovery of Service Metadata for Systems at Scale

Automatic Discovery of Service Metadata

Martina Iglesias

[email protected]

September 2016

Page 2: Automatic Discovery of Service Metadata for Systems at Scale

Spotify scale

Page 3: Automatic Discovery of Service Metadata for Systems at Scale

Spotify Users

100M Active Users

40MPaid Subscribers 59 Countries

Page 4: Automatic Discovery of Service Metadata for Systems at Scale

Spotify tech

● +800 tech employees

● 120 teams

● Microservices architecture (scale and work

independently)

Page 5: Automatic Discovery of Service Metadata for Systems at Scale
Page 6: Automatic Discovery of Service Metadata for Systems at Scale

Artist page

Number of streams

Page 7: Automatic Discovery of Service Metadata for Systems at Scale

Artist page

Artist Discography

Page 8: Automatic Discovery of Service Metadata for Systems at Scale

Artist page

Artist Playlists

Page 9: Automatic Discovery of Service Metadata for Systems at Scale

Artist page

Merchandise

Page 10: Automatic Discovery of Service Metadata for Systems at Scale

Example: aggregating service

Artist

Discography Playcount Playlists Merch

Page 11: Automatic Discovery of Service Metadata for Systems at Scale

Spotify infrastructure

● +1000 services

● The number of services grows as we add new

features

Page 12: Automatic Discovery of Service Metadata for Systems at Scale

Spotify officesStockholm

BostonNew York

San Francisco

Gothenburg

Page 13: Automatic Discovery of Service Metadata for Systems at Scale

Previous situation

● Each team had doc. in different places

● README.mk

● Markdown files in doc/

● Wiki

● Link to a document somewhere else

Page 14: Automatic Discovery of Service Metadata for Systems at Scale
Page 15: Automatic Discovery of Service Metadata for Systems at Scale

System Z

Page 16: Automatic Discovery of Service Metadata for Systems at Scale

System Z

● 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 17: Automatic Discovery of Service Metadata for Systems at Scale
Page 18: Automatic Discovery of Service Metadata for Systems at Scale
Page 19: Automatic Discovery of Service Metadata for Systems at Scale

artist

playcount

discography

merch

playlist

loadbalancer

Page 20: Automatic Discovery of Service Metadata for Systems at Scale

System Map

● Generated from runtime and declared

dependencies

● Uses graphviz

Page 21: Automatic Discovery of Service Metadata for Systems at Scale

DNS

System Z overview

Register artist serviceARTIST SERVICE:

DNS: _artist._http

OWNER: martina

SYSTEM Z(backend)

artist-1.spotify.com

Lookup machines

HTTP req to

/meta/0/

Page 22: Automatic Discovery of Service Metadata for Systems at Scale

Apollo and apollo-meta

Page 23: Automatic Discovery of Service Metadata for Systems at Scale

Apollo

● Java libraries for writing microservices

● Open Source

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

● In production since 2014

Page 24: Automatic Discovery of Service Metadata for Systems at Scale

APOLLO SERVICE

MODULES

OKHTTP-CLIENTJETTY-HTTP-SERVER

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

SERVICE LOGIC

interacts

uses

Apollo service overview

Page 25: Automatic Discovery of Service Metadata for Systems at Scale

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 26: Automatic Discovery of Service Metadata for Systems at Scale

Example: Creating a route

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

request-> getArtist(request))

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

)

Page 27: Automatic Discovery of Service Metadata for Systems at Scale

Endpoints exposed by apollo meta

1. Instance information2. Configuration3. Endpoints4. Call Information

Page 28: Automatic Discovery of Service Metadata for Systems at Scale

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 29: Automatic Discovery of Service Metadata for Systems at Scale

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 30: Automatic Discovery of Service Metadata for Systems at Scale

2. Apollo-meta: configuration

● The current loaded config of the service, possibly

filtered

Page 31: Automatic Discovery of Service Metadata for Systems at Scale

2. Apollo-meta: config

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

Page 32: Automatic Discovery of Service Metadata for Systems at Scale

3. Apollo-meta: endpoints

● Lists the endpoints of the service

Page 33: Automatic Discovery of Service Metadata for Systems at Scale

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 34: Automatic Discovery of Service Metadata for Systems at Scale

4. Apollo-meta: call info

● Lists services that make incoming requests

● Lists all other services we make requests to

Page 35: Automatic Discovery of Service Metadata for Systems at Scale

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 36: Automatic Discovery of Service Metadata for Systems at Scale

4. Apollo-meta: call info

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

Page 37: Automatic Discovery of Service Metadata for Systems at Scale

Apollo meta <-> System Z

● System Z calls these endpoints

● Displays a merged version of all the data

Page 38: Automatic Discovery of Service Metadata for Systems at Scale

Conclusions

Page 39: Automatic Discovery of Service Metadata for Systems at Scale

● Quicker access to relevant information

● Know immediately where to go when solving an

incident

● Less interruptions

● Less boring work

Situation now

Page 40: Automatic Discovery of Service Metadata for Systems at Scale

● Think about growth and scaling

● Automate all boring tasks that you can

● Put all the information related in one, easy to

access, place

● All related links in one place

Learnings

Page 41: Automatic Discovery of Service Metadata for Systems at Scale

● apollo

● swagger.io

● raml.org (jax-rs)

Documentation generators

Page 42: Automatic Discovery of Service Metadata for Systems at Scale

Blog: labs.spotify.com

Jobs: spotify.com/jobs

Martina [email protected]

Page 43: Automatic Discovery of Service Metadata for Systems at Scale

Blog: labs.spotify.com

Jobs: spotify.com/jobs

Martina [email protected]

Questions?