104
PuppetDB (°°)*:・゚2014

PuppetDB: One Year Faster - PuppetConf 2014

Embed Size (px)

DESCRIPTION

PuppetDB: One Year Faster - Deepak Giridharagopal, Puppet Labs

Citation preview

Page 1: PuppetDB: One Year Faster - PuppetConf 2014

PuppetDB (ノ°ヮ°)ノ*:・゚✧2014✧

Page 2: PuppetDB: One Year Faster - PuppetConf 2014

RUNPDB

Page 3: PuppetDB: One Year Faster - PuppetConf 2014

deepak giridharagopal deepak @puppetlabs.com

@grim_radical

Page 4: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master

facts

PuppetDBPuppetDB

Page 5: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master

facts

PuppetDBPuppetDB

Page 6: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBfacts PuppetDB

Page 7: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master

facts

PuppetD

B

PuppetDB

Page 8: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master

facts

PuppetDBPuppetDB

Yum!

Page 9: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

Page 10: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

catalogcatalog

Page 11: PuppetDB: One Year Faster - PuppetConf 2014

catalog

Puppet agent

Puppet master PuppetDBPuppetDB

catalog

Page 12: PuppetDB: One Year Faster - PuppetConf 2014

catalog

Puppet agent

Puppet master

PuppetD

B

PuppetDB

catalog

Page 13: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

catalog

Puppet master

facts

PuppetDBPuppetDB

Yum!

Page 14: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

catalog

Page 15: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

report

Page 16: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

report

Page 17: PuppetDB: One Year Faster - PuppetConf 2014

report

Puppet agent

Puppet master PuppetDBPuppetDB

Page 18: PuppetDB: One Year Faster - PuppetConf 2014

report

Puppet agent

Puppet master

PuppetD

B

PuppetDB

Page 19: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master

facts

PuppetDBPuppetDB

Yum!

Page 20: PuppetDB: One Year Faster - PuppetConf 2014

Puppet agent

Puppet master PuppetDBPuppetDB

Page 21: PuppetDB: One Year Faster - PuppetConf 2014
Page 22: PuppetDB: One Year Faster - PuppetConf 2014

Puppet master

catalog

PuppetDB

catalog

Page 23: PuppetDB: One Year Faster - PuppetConf 2014

Puppet master

catalogPuppetDB

catalog

Page 24: PuppetDB: One Year Faster - PuppetConf 2014

Puppet master PuppetDB

catalog

Page 25: PuppetDB: One Year Faster - PuppetConf 2014

catalog

Puppet master PuppetDB

catalog

Page 26: PuppetDB: One Year Faster - PuppetConf 2014

Puppet master PuppetDB

catalog

Page 27: PuppetDB: One Year Faster - PuppetConf 2014

catalog

Puppet master PuppetDB

catalog

Page 28: PuppetDB: One Year Faster - PuppetConf 2014

Puppet master PuppetDBcatalog

Page 29: PuppetDB: One Year Faster - PuppetConf 2014

catalog

Puppet master PuppetDBcatalog

Page 30: PuppetDB: One Year Faster - PuppetConf 2014

Software should be self-regulating

Page 31: PuppetDB: One Year Faster - PuppetConf 2014

goo.comfoo.com bar.com

STOR

AGE

bar.com

Self-regulating catalog & fact storage!

Page 32: PuppetDB: One Year Faster - PuppetConf 2014

goo.comfoo.com bar.com

STOR

AGE

bar.combar.combar.combar.com

Self-regulating report storage!

Page 33: PuppetDB: One Year Faster - PuppetConf 2014

goo.comfoo.com bar.com

STOR

AGE

Self-regulating node storage!

Page 34: PuppetDB: One Year Faster - PuppetConf 2014

goo.comfoo.com bar.com

STOR

AGE

bar.com

Deduplication of catalogs!foo.com goo.com

Page 35: PuppetDB: One Year Faster - PuppetConf 2014

/commands MQ Parse

Delayed

Dead Letter Office

Process

UUID

Page 36: PuppetDB: One Year Faster - PuppetConf 2014

Querying

Page 37: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/resources

Page 38: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/resources/Service

Page 39: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/resources/Service/foo

Page 40: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/nodes/foo.com/resources

Page 41: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/nodes/foo.com/resources /Package

Page 42: PuppetDB: One Year Faster - PuppetConf 2014

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

baz.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

goo.com

/v4/nodes/foo.com/resources /Package/foo

Page 43: PuppetDB: One Year Faster - PuppetConf 2014

• Can query facts, nodes, resources, reports, events, metrics

• Advanced queries via AST-based language

• Aggregates, ordering, paging, streaming, subqueries

Page 44: PuppetDB: One Year Faster - PuppetConf 2014
Page 45: PuppetDB: One Year Faster - PuppetConf 2014

A long time ago in a galaxy far, far away…

!

!

uh, like here a year ago…

Page 46: PuppetDB: One Year Faster - PuppetConf 2014

Just released 1.4.0, Around 11k deployments, Basic streaming support, Other stuff…

Page 47: PuppetDB: One Year Faster - PuppetConf 2014

We’ve been busy!

Page 48: PuppetDB: One Year Faster - PuppetConf 2014

Soft write failures Paging support

Resource containment paths in events

Event aggregates Differential fact storage

Page 49: PuppetDB: One Year Faster - PuppetConf 2014

Differential edge storage Pervasive streaming of query

results 3dfx Voodoo2 and

Soundblaster AWE32 support Improved de-duplication

Page 50: PuppetDB: One Year Faster - PuppetConf 2014

Resource parameter caching PostgreSQL Hot Standby support for faster reads

Debugging of de-duplication algorithm

Full director’s commentary

Page 51: PuppetDB: One Year Faster - PuppetConf 2014

Compressed responses A pony

Certificate chain support Support for puppet

environments Event subqueries

Page 52: PuppetDB: One Year Faster - PuppetConf 2014

Prepared statement caching Direct POST of json data in

terminus Brings Aeris from Final Fantasy VII back to life

Profiling support for terminus

Page 53: PuppetDB: One Year Faster - PuppetConf 2014

Faster message parsing Structured fact storage and

querying Unified query subsystem in v4

API Riker’s beard

Page 54: PuppetDB: One Year Faster - PuppetConf 2014

docs.puppetlabs.com/puppetdb/latest/

release_notes.html

Page 55: PuppetDB: One Year Faster - PuppetConf 2014

We can’t get through that entire list, but I’ll try to highlight a few shiny

bits

Page 56: PuppetDB: One Year Faster - PuppetConf 2014

1. Differential storage

Page 57: PuppetDB: One Year Faster - PuppetConf 2014

goo.comfoo.com bar.com

STOR

AGE

bar.comfoo.com

Page 58: PuppetDB: One Year Faster - PuppetConf 2014

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[zzz]

Exec[echo foo]

Exec[echo bar]

Page 59: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[zzz]

Exec[echo foo]

Exec[echo bar]

Page 60: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[zzz]

Exec[echo foo]

Exec[echo bar]

Page 61: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[zzz]

Exec[echo foo]

Exec[echo bar]

Page 62: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

bar.com

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[zzz]

Exec[echo foo]

Exec[echo bar]

Page 63: PuppetDB: One Year Faster - PuppetConf 2014

• Edges and facts, too • Trades reads for writes,

which is a good tradeoff. • PostgreSQL’s heap-only-

tuples help a lot.

Page 64: PuppetDB: One Year Faster - PuppetConf 2014

~90% fewer writes

Page 65: PuppetDB: One Year Faster - PuppetConf 2014
Page 66: PuppetDB: One Year Faster - PuppetConf 2014

Thanks to the folks at Spotify, the community, etc. that helped us with

this!

Page 67: PuppetDB: One Year Faster - PuppetConf 2014

2. More effective de-duplication

Page 68: PuppetDB: One Year Faster - PuppetConf 2014

Order matters!

Page 69: PuppetDB: One Year Faster - PuppetConf 2014

{"foo" => "goo", "bar" => "baz"}

{"bar" => "baz", "foo" => "goo"}

904d4d…

11c05d…

Page 70: PuppetDB: One Year Faster - PuppetConf 2014

• Restructuring data prior to hashing results in much fewer false negatives

• The fastest way to persist data is to already have it persisted!

Page 71: PuppetDB: One Year Faster - PuppetConf 2014

~60-70% boost for users with ordinarily

low dedupe rates

Page 72: PuppetDB: One Year Faster - PuppetConf 2014

Thanks to the folks at CERN that helped us

debug this!

Page 73: PuppetDB: One Year Faster - PuppetConf 2014

3. Hot standby

Page 74: PuppetDB: One Year Faster - PuppetConf 2014

PuppetDB PostgreSQL

WRITE

READ

Page 75: PuppetDB: One Year Faster - PuppetConf 2014

PuppetDB

PostgreSQL

WRITE

READ

PostgreSQLstandby

REPLICATION

Page 76: PuppetDB: One Year Faster - PuppetConf 2014

Less I/O contention for reads and writes yields

better throughput

Page 77: PuppetDB: One Year Faster - PuppetConf 2014

3. Environment support

Page 78: PuppetDB: One Year Faster - PuppetConf 2014

STORAGE

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

Page 79: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

Page 80: PuppetDB: One Year Faster - PuppetConf 2014

STORAGEFile[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

All Files, please!

Anything for you! !

Page 81: PuppetDB: One Year Faster - PuppetConf 2014

STORAGE

File[/foo]

File[/bar] Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

WTF?!

I’m trying my best! !

Page 82: PuppetDB: One Year Faster - PuppetConf 2014

STORAGE

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

All Files forenv TEST, plz!

Anything for you! !

File[/foo]

Page 83: PuppetDB: One Year Faster - PuppetConf 2014

STORAGE

File[/foo]

File[/bar]

Package[foo]

Package[bar]

Service[foo]

Service[bar]

Exec[echo foo]

Exec[echo bar]

foo.comTEST

bar.com

PROD

Thanks!

We’re friends again! ❤️

Page 84: PuppetDB: One Year Faster - PuppetConf 2014

• Any reception or transmission of data now includes the environment where possible

• Queries can be isolated to a single environment

Page 85: PuppetDB: One Year Faster - PuppetConf 2014

3. Unified query engine

Page 86: PuppetDB: One Year Faster - PuppetConf 2014

PuppetDB

Parse Map valid fields

Map valid operators

Compile to SQL

PostgreSQL

Parse Map valid fields

Map valid operators

Compile to SQL

Parse Map valid fields

Map valid operators

Compile to SQL

Parse Map valid fields

Map valid operators

Compile to SQL

Facts

Resources

Nodes

Reports

Parse Map valid fields

Map valid operators

Compile to SQLEvents

QUERY

Page 87: PuppetDB: One Year Faster - PuppetConf 2014

PuppetDB

Parse to AST Term rewriting

Apply operators

Compile to SQL

PostgreSQL

QUERY

Page 88: PuppetDB: One Year Faster - PuppetConf 2014

• Common query engine underpinning v4 API

• Operators are available uniformly across all v4 endpoints

• We can add new endpoints and fields much faster

Page 89: PuppetDB: One Year Faster - PuppetConf 2014

4. Structured/Trusted

fact support

Page 90: PuppetDB: One Year Faster - PuppetConf 2014

{ "cpus" : { "cpu1" : { "bogomips": 6000, } }, "networking" : { "eth0" : { "ipaddresses" : [ "1.1.1.5" ], "macaddresses" : [ "aa:bb:cc:dd:ee:00" ] } } }

Page 91: PuppetDB: One Year Faster - PuppetConf 2014

["=", "path", ["networking", "eth0", "macaddresses", 0]]

Page 92: PuppetDB: One Year Faster - PuppetConf 2014

["~>", "path", ["networking", "eth.*", "macaddresses", ".*"]]

Page 93: PuppetDB: One Year Faster - PuppetConf 2014

!

• PostgreSQL’s pg_trgm index • Trusted facts

Page 94: PuppetDB: One Year Faster - PuppetConf 2014

So where are we now?

Page 95: PuppetDB: One Year Faster - PuppetConf 2014

More features, but also more speed

Page 96: PuppetDB: One Year Faster - PuppetConf 2014

Language bindings: Ruby, Python,

JavaScript, C/C++, Go, Clojure, Java…

Page 97: PuppetDB: One Year Faster - PuppetConf 2014

Trapperkeeper https://github.com/puppetlabs/trapperkeeper

Page 98: PuppetDB: One Year Faster - PuppetConf 2014

Puppetboard https://github.com/nedap/puppetboard

Page 99: PuppetDB: One Year Faster - PuppetConf 2014

Puppet Explorer https://github.com/spotify/puppetexplorer

Page 100: PuppetDB: One Year Faster - PuppetConf 2014

A new deployment every 10 minutes

Page 101: PuppetDB: One Year Faster - PuppetConf 2014

Coming soon: more efficient GC

Page 102: PuppetDB: One Year Faster - PuppetConf 2014

Coming soon: simplified query syntax

Page 103: PuppetDB: One Year Faster - PuppetConf 2014

Coming soon: historical data

Page 104: PuppetDB: One Year Faster - PuppetConf 2014

Thanks!