3. About Me
• Currently working as Software
Engineer (Data Platform) at
Allegiance Software Inc.
• Passion for Distributed
System, Data visualizations.
• Masters in Distributed
Systems.
• abhishek376.wordpress.com
8. Elasticsearch 101
• Document oriented search engine Json based, apache
lucene under covers.
• Schema free.
• Its distributed, supports aggregations similar to group by .
• Uses bit sets to efficiently cache.
• It’s fast. Super fast.
• Its has REST and Java based API’s
9. Elasticsearch CRUD
Index a person:
curl -XPUT ‘localhost:9200/person/1’ -d '{
"first_name" : "Abhishek",
"last_name" : "Andhavarapu"
}’
Get a person:
curl -XGET 'localhost:9200/person/1'
Delete a person:
curl -XDELETE ‘localhost:9200/person/1’
Update a person:
curl -XPOST 'localhost:9200/person/1/_update' -d '{
"doc" : {
"first_name" : "Abhi"
}
}'
12. More nodes..
Node1 Node2
S0 S1
Node3 Node4
S1 S0
Blue - Replica
Red - Primary
13. Node down
Node1 Node2
S0 S1
Node3 Node4
S1 S0
Blue - Replica
Red - Primary
14. Node1
S0
Node down
Node3 Node4
A1 S1
S0
Blue - Replica
Red - Primary
S1
Re-replicated
Promoted to Primary
15. Elasticsearch 101
• Lucene is under covers.
• Each index (like a database) is made up of multiple
shards(lucene instance).
• Shards are distributed amongst all nodes in the
cluster.
• In case of failure or the addition of new nodes
shards are automatically moved from one to
another.
16. How is it Fast ?
Distributed execution
Client
Node 2
Node 1
S0 S1 S0 S1
Query
Red - Primary
Blue - Replica
17. DEMO
• Import data from SQL database
in to Hive. (Extract)
• Run the necessary
computations using
Hadoop/Hive. (Transform)
• Push the data in to
Elasticsearch. (Load)
• Run queries against
Elasticsearch.
18. Current Elasticsearch Cluster
• 9 bare metal boxes
• 128 GB RAM
• 2X SSD
• 10 GB Ethernet
• 2X 10 core Xeon Processors
• 2X 30GB Elasticsearch instances per box
• 1 Elasticsearch load balancing instance to handle index requests
21. Concurrency
• More replication for more currency. Updates are costly.
• More shards much faster.
• SQL 3 to 5k per minute
22. Filter Cache
• All the filters have a cache flag that controls if they
are cached or not.
• Once the filter cache is warmed, all the requests are
served from the memory.
• Defaults - 10% for the filter cache.
• LRU.
• Bit Sets.
23. Field Data
• For sorting, aggegration etc.. all the field values are
loaded in to memory called field data.
• By default its unbounded.
• Expensive to build, its recommended to hold this in
memory.
• They are circuit breakers to protect against this.
• If the query is gonna use more than 60% of the JVM
heap it will kill the query.
24. JVM memory - Friend or Foe ?
to replicate which are still serving requests causing additional heap
26. Elasticsearch Cons
• Not commodity hardware 6K (Hadoop) vs 10K (SSD)
• GC issues.
• Circuit breakers doesn’t protect you against everything.
• No built in security. Use ngnix proxy with authentication.
• Learning curve.
• Lot of updates hurt. Filter cache should be rebuilt, merges etc..
27. Thank you
• abhishek376.wordpress.com
• abhishek376@gmail.com
• Twitter : abhishek376
We are Hiring !!
Editor's Notes
I would like to thank all my sponsors. With out whose suppose this wouldn’t have been possible,
Timed the session it took me about 40 mins.
Stop me any time. Interactive session,
Demo - Pushing data from SQL to Hadoop and Hadoop to elasticsearch.
Allegiance the company I work for - Voice of customer space
We provide tools for analytics over the customer data.
Every night CUBE is tore down, takes about 6 to 12 hours to rebuild. Multi tenant environment
Not scalable, very expensive hard to manage
SQL - Master System of record. Plans to use HBase. Still prototyping.
ETL process runs every hours which pushes the data from SQL to Hadoop and hadoop to es.
Hadoop for ETL (Converts SQL in to NoSQL docs)
Elasticsearch for Reporting
If you want to more about it or how we use it in our product. Come see me in the experts room. They are a lot of sessions.
Demo our architecture.
its a batch processing engine which run on commodity hardware and is highly scalable.
Aggregations -It is similar to GROUP BY in SQL, but much more powerful.
I have slides to show how fast it is.
Craig has a session about intro to elasticsearch
How the documents are stored in elasticsearch.
Index are like SQL databases.
The data of an index is distributed across multiple shards.
Elasticsearch makes sure that a single node doesn’t have both the primary and replica.
All the write requests hit the primary shards.
All the search requests can hit either primary or replica.
Routing for inserts and updates are handled by elasticsearch.
Shards are automatically moved to the new nodes.
Shards are distributed among the nodes.
A query is executed simultaneously across multiple nodes and results are aggregated back to the client.
More nodes faster response times. More replication, costlier the updates are.
Queries that took 100s now take 1s. By using aggregations.
ES distributed - designed to handle some thing like this. More shards more concurrent.
Filter cache and Field Data is what uses the memory in elasticsearch. The reason why its is so fast.
If not careful, can very fast use all the JVM heap. Leading to more gc and can lead of OOM and then cascading failure of the cluster.
In the fast we have seen that 500gb of filter cache filling up and crashing the cluster in 4 sec due to lots of nodes and SSD with the help of file system cache.
Memory is why elasticsearch is so fast. It can also be a foe if not carefull.
These graphs show common symptoms of stop the world gc. While its running nothing else is allowed to run. We would like to keep this to minimum as possible. Talk about cascading failure.
There are two generations, young and old when the objects are created they are put in young generation and after they survive couple of gc its moved to old.
When we added more indexes, healthy graph become something like this.
GC have hard time catching up.
2 elasticsearch instances per box as we are not io/cpu/bandwidth limited. Just memory
Real time. People are OK with AWS. But for us real time analytics. So no commodity hardware.
Still working on stability. We saw a single query can get down the entire cluster
If you like what you saw you should come work with us. Come talk to me.
We have a booth if you are interested please submit your resume.
Email me if you have any questions. You can also find me in the experts room.