elasticsearch at affiliatewindow

37
Elasticsearch @Affiliate Window

Upload: yann-cluchey

Post on 25-Jan-2017

138 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Elasticsearch at AffiliateWindow

Elasticsearch@Affiliate Window

Page 2: Elasticsearch at AffiliateWindow

Richard HeTeam Falcon

Page 3: Elasticsearch at AffiliateWindow

A transaction report used by tens of thousands of users every day that took too long to load

Our problem

Page 4: Elasticsearch at AffiliateWindow
Page 5: Elasticsearch at AffiliateWindow

Near real-time latency Really fast aggregations Accessible individual transaction records Flexible Scalable

What we wanted

Page 6: Elasticsearch at AffiliateWindow

The solution - Producing

Page 7: Elasticsearch at AffiliateWindow

The solution - Consuming

Page 8: Elasticsearch at AffiliateWindow

When shit hits the fan

Page 9: Elasticsearch at AffiliateWindow

Next steps

Page 10: Elasticsearch at AffiliateWindow

A good architect maximises the number of decisions NOT made

by Uncle Bob Martin

Page 11: Elasticsearch at AffiliateWindow

New data fields can be added with almost no work Average response time is <200ms Easy to scale by just adding nodes REST API

Why Elasticsearch

Page 12: Elasticsearch at AffiliateWindow

Things that are good to know…

Page 13: Elasticsearch at AffiliateWindow

Transaction Log - Refresh - Flush

Page 14: Elasticsearch at AffiliateWindow
Page 15: Elasticsearch at AffiliateWindow
Page 16: Elasticsearch at AffiliateWindow
Page 17: Elasticsearch at AffiliateWindow
Page 18: Elasticsearch at AffiliateWindow

1.x – fsync every 5 seconds 2.x – on request (default) / fsync every 5 seconds

Transaction log durability

Page 19: Elasticsearch at AffiliateWindow

"refresh_interval" : "-1” "refresh_interval" : ”1s” "refresh_interval" : ”15s"

Refresh intervalA refresh makes data searchable and a refresh interval decides how often that happens

Page 20: Elasticsearch at AffiliateWindow

Filters vs Queries (v 1.7)A filter askes yes / no questions, a query ask how well does this document match

Page 21: Elasticsearch at AffiliateWindow

76ms 1385ms

Page 22: Elasticsearch at AffiliateWindow

Filters vs Queries Disable analysed field if not needed Use a filter if a query is not required

Page 23: Elasticsearch at AffiliateWindow

Doc Values

Set a smaller heap size (4-16G on a 64G machine) More RAM is now available for File System Cache Enabled by default in version 2 Does not work with analysed field

On-disk data structure that allows fast aggregation without JVM Heap overhead

Page 24: Elasticsearch at AffiliateWindow

Aggregations are approximate

Page 25: Elasticsearch at AffiliateWindow
Page 26: Elasticsearch at AffiliateWindow
Page 27: Elasticsearch at AffiliateWindow
Page 28: Elasticsearch at AffiliateWindow

Wrong!

Page 29: Elasticsearch at AffiliateWindow

The solution Size = 0 The cost

Page 30: Elasticsearch at AffiliateWindow

Split Brain

Page 31: Elasticsearch at AffiliateWindow

M

4

52

1

Page 32: Elasticsearch at AffiliateWindow

1

2

3

4 5

Page 33: Elasticsearch at AffiliateWindow

M

2

M

4 5

Page 34: Elasticsearch at AffiliateWindow

M

2

M

4 5

Page 35: Elasticsearch at AffiliateWindow

1

2

M

4

5

Page 36: Elasticsearch at AffiliateWindow

Doc valueshttps://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.htmlhttps://www.elastic.co/guide/en/elasticsearch/guide/current/_deep_dive_on_doc_values.html

Aggregationhttps://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

Update Index settingshttps://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html

Important config changeshttps://www.elastic.co/guide/en/elasticsearch/guide/1.x/_important_configuration_changes.htmlhttps://www.elastic.co/guide/en/elasticsearch/guide/current/translog.htmlhttps://github.com/elastic/elasticsearch/issues/11287

Transaction loghttps://www.elastic.co/guide/en/elasticsearch/guide/current/translog.htmlhttps://github.com/elastic/elasticsearch/issues/11287

Resources

Page 37: Elasticsearch at AffiliateWindow

Questions