real-time searching of big data with solr and hadoop

36
1 © 2015 Rogue Wave Software, Inc. All Rights Reserved. Real-time searching of big data with Solr and Hadoop Rod Cope, CTO

Upload: rogue-wave-software

Post on 13-Apr-2017

454 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Real-time searching of big data with Solr and Hadoop

1© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Real-time searching of big data withSolr and HadoopRod Cope, CTO

Page 2: Real-time searching of big data with Solr and Hadoop

2© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Agenda

• Introduction• The problem• The solution• Top 10 lessons• Final thoughts• Q&A

Page 3: Real-time searching of big data with Solr and Hadoop

3© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Rod Cope, CTORogue Wave Software

Agenda

Page 4: Real-time searching of big data with Solr and Hadoop

4© 2015 Rogue Wave Software, Inc. All Rights Reserved.

The problem

• “Big data”– All the world’s open source software– Metadata, code, indexes– Individual tables contain many terabytes– Relational databases aren’t scale-free

• Growing every day• Need real-time random access to all data• Long-running and complex analysis jobs

Page 5: Real-time searching of big data with Solr and Hadoop

5© 2015 Rogue Wave Software, Inc. All Rights Reserved.

The solution• Hadoop, HBase, and Solr

– Hadoop – distributed file system, map/reduce– HBase – “NoSQL” data store – column-oriented– Solr – search server based on Lucene– All are scalable, flexible, fast, well-supported, and used in

production environments• And a supporting cast of thousands…

– Stargate, MySQL, Rails, Redis, Resque,– Nginx, Unicorn, HAProxy, Memcached,– Ruby, JRuby, CentOS, …

Page 6: Real-time searching of big data with Solr and Hadoop

6© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Solution architecture

Internet Application LAN Data LAN *Caching and load balancing not shown

Page 7: Real-time searching of big data with Solr and Hadoop

7© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Getting big data out of Hbase

• HBase NoSQL– Think hash table, not relational database

• How do find my data if primary key won’t cut it?• Solr to the rescue

– Very fast, highly scalable search server with built-in sharding and replication – based on Lucene

– Dynamic schema, powerful query language, faceted search, accessible via simple REST-like web API w/XML, JSON, Ruby, and other data formats

Page 8: Real-time searching of big data with Solr and Hadoop

8© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Getting big data out of Hbase• Sharding

– Query any server – it executes the same query against all other servers in the group

– Returns aggregated result to original caller• Async replication (slaves poll their masters)

– Can use repeaters if replicating across data centers• OpenLogic

– Solr farm, sharded, cross-replicated, fronted with HAProxy• Load balanced writes across masters, reads across masters and slaves• Be careful not to over-commit

– Billions of lines of code in HBase, all indexed in Solr for real-time search in multiple ways

– Over 20 Solr fields indexed per source file

Page 9: Real-time searching of big data with Solr and Hadoop

9© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Solr implementation – shading + replication

Page 10: Real-time searching of big data with Solr and Hadoop

10© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Write flow

Page 11: Real-time searching of big data with Solr and Hadoop

11© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Read flow

Page 12: Real-time searching of big data with Solr and Hadoop

12© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Delete flow

Page 13: Real-time searching of big data with Solr and Hadoop

13© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Write flow – failover

Page 14: Real-time searching of big data with Solr and Hadoop

14© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Read flow – failover

Page 15: Real-time searching of big data with Solr and Hadoop

15© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Loading big data

• Experiment with different Solr merge factors– During huge loads, it can help to use a higher factor for load

performance• Minimize index manipulation gymnastics• Start with something like 25

– When you’re done with the massive initial load/import, turn it back down for search performance

• Minimize number of queries• Start with something like 5• Note that a small merge factor will hurt indexing performance if you

need to do massive loads on a frequent basis or continuous indexing

Page 16: Real-time searching of big data with Solr and Hadoop

16© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Loading big data (cont.)

• Test your write-focused load balancing– Look for large skews in Solr index size– Note: you may have to commit, optimize, write again, and

commit before you can really tell• Make sure your replication slaves are keeping up

– Using identical hardware helps– If index directories don’t look the same, something is wrong

Page 17: Real-time searching of big data with Solr and Hadoop

17© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Loading big data (cont.)

• Don’t commit to Solr too frequently– It’s easy to auto-commit or commit after every record– Doing this 100’s of times per second will take Solr down,

especially if you have serious warm up queries configured• Avoid putting large values in HBase (> 5MB)

– Works, but may cause instability and/or performance issues– Rows and columns are cheap, so use more of them instead

Page 18: Real-time searching of big data with Solr and Hadoop

18© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Loading big data (cont.)• Don’t use a single machine to load the cluster

– You might not live long enough to see it finish• At OpenLogic, we spread raw source data across many machines

and hard drives via NFS– Be very careful with NFS configuration – can hang machines

• Load data into HBase via Hadoop map/reduce jobs– Turn off WAL for much better performance

• put.setWriteToWAL(false)

– Index in Solr as you go• Good way to test your load balancing write schemes and replication set up

– This will find your weak spots!

Page 19: Real-time searching of big data with Solr and Hadoop

19© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Scripting languages can help

• Writing data loading jobs can be tedious• Scripting is faster and easier than writing Java• Great for system administration tasks, testing• Standard HBase shell is based on JRuby• Very easy Map/Reduce jobs with J/Ruby and Wukong• Used heavily at OpenLogic

– Productivity of Ruby– Power of Java Virtual Machine– Ruby on Rails, Hadoop integration, GUI clients

Page 20: Real-time searching of big data with Solr and Hadoop

20© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Java (27 lines)

Page 21: Real-time searching of big data with Solr and Hadoop

21© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Scripting languages (4 lines)

JRubylist = ["Rod", "Neeta", "Eric", "Missy"]

shorts = list.find_all { |name| name.size <= 4 }

puts shorts.size

shorts.each { |name| puts name }

-> 2

-> Rod

Eric

Groovylist = ["Rod", "Neeta", "Eric", "Missy"]

shorts = list.findAll { name -> name.size() <= 4 }

println shorts.size

shorts.each { name -> println name }

-> 2

-> Rod

Eric

Page 22: Real-time searching of big data with Solr and Hadoop

22© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Cutting edge

• Hadoop– SPOF around Namenode, append functionality

• HBase– Backup, replication, and indexing solutions in flux

• Solr– Several competing solutions around cloud-like scalability

and fault-tolerance, including ZooKeeper and Hadoop integration

– No clear winner, none quite ready for production

Page 23: Real-time searching of big data with Solr and Hadoop

23© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Configuration is key

• Many moving parts– It’s easy to let typos slip through– Consider automated configuration via Chef, Puppet, or similar

• Pay attention to the details– Operating system – max open files, sockets, and other limits– Hadoop and HBase configuration

• http://hbase.apache.org/book.html#trouble– Solr merge factor and norms

• Don’t starve HBase or Solr for memory– Swapping will cripple your system

Page 24: Real-time searching of big data with Solr and Hadoop

24© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Commodity hardware

• “Commodity hardware” != 3 year old desktop• Dual quad-core, 32GB RAM, 4+ disks• Don’t bother with RAID on Hadoop data disks

– Be wary of non-enterprise drives• Expect ugly hardware issues at some point

Page 25: Real-time searching of big data with Solr and Hadoop

25© 2015 Rogue Wave Software, Inc. All Rights Reserved.

OpenLogic’s Hadoop implementation

• Environment– 100+ CPU cores– 100+ Terabytes of disk– Machines don’t have identity– Add capacity by plugging in new machines

• Why not Amazon EC2?– Great for computational bursts– Expensive for long-term storage of big data– Not yet consistent enough for mission-critical usage of HBase

Page 26: Real-time searching of big data with Solr and Hadoop

26© 2015 Rogue Wave Software, Inc. All Rights Reserved.

OpenLogic’s Hadoop & Solr deployment• Dual quad-core and dual hex-core• Dell boxes• 32-64GB RAM

– ECC (highly recommended by Google)• 6 x 2TB enterprise hard drives• RAID 1 on two of the drives

– OS, Hadoop, HBase, Solr, NFS mounts (be careful!), job code, etc.– Key “source” data backups

• Hadoop datanode gets remaining drives• Redundant enterprise switches• Dual- and quad-gigabit NIC’s

Page 27: Real-time searching of big data with Solr and Hadoop

27© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Public clouds and big data• Amazon EC2

– EBS Storage• 100TB * $0.10/GB/month = $120k/year

– Double Extra Large instances• 13 EC2 compute units, 34.2GB RAM• 20 instances * $1.00/hr * 8,760 hrs/yr = $175k/year• 3 year reserved instances

– 20 * 4k = $80k up front to reserve– (20 * $0.34/hr * 8,760 hrs/yr * 3 yrs) / 3 = $86k/year to operate

– Totals for 20 virtual machines• 1st year cost: $120k + $80k + $86k = $286k• 2nd & 3rd year costs: $120k + $86k = $206k• Average: ($286k + $206k + $206k) / 3 = $232k/year

Page 28: Real-time searching of big data with Solr and Hadoop

28© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Private clouds and big data

• Buy your own– 20 * Dell servers w/12 CPU cores, 32GB RAM, 5 TB disk =

$160k• Over 33 EC2 compute units each

– Total: $53k/year (amortized over 3 years)

Page 29: Real-time searching of big data with Solr and Hadoop

29© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Public clouds are expensive for big data

• Amazon EC2– 20 instances * 13 EC2 compute units = 260 EC2 compute units– Cost: $232k/year

• Buy your own– 20 machines * 33 EC2 compute units = 660 EC2 compute units– Cost: $53k/year– Does not include hosting and maintenance costs

• Don’t think system administration goes away– You still “own” all the instances – monitoring, debugging, support

Page 30: Real-time searching of big data with Solr and Hadoop

30© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Expect things to fail – a lot

• Hardware– Power supplies, hard drives

• Operating System– Kernel panics, zombie processes, dropped packets

• Software Servers– Hadoop datanodes, HBase regionservers, Stargate servers, Solr

servers• Your Code and Data

– Stray map/reduce jobs, strange corner cases in your data leading to program failures

Page 31: Real-time searching of big data with Solr and Hadoop

31© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Not possible without open source

Page 32: Real-time searching of big data with Solr and Hadoop

32© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Not possible without open source• Hadoop, HBase, Solr• Apache, Tomcat, ZooKeeper,

HAProxy• Stargate, JRuby, Lucene, Jetty,

HSQLDB, Geronimo• Apache Commons, JUnit• CentOS• Dozens more

• Too expensive to build or buy everything

Page 33: Real-time searching of big data with Solr and Hadoop

33© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Final thoughts• You can host big data in your own private cloud

– Tools are available today that didn’t exist a few years ago– Fast to prototype – production readiness takes time– Expect to invest in training and support

• Hbase and Solr are fast– 100+ random queries/sec per instance– Give them memory and stand back

• Hbase Scales, Solr scales (to a point)– Don’t worry about out-growing a few machines– Do worry about out-growing a rack of Solr instances

• Look for ways to partition your data other than “automatic” sharding

Page 34: Real-time searching of big data with Solr and Hadoop

34© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Q&A

Page 35: Real-time searching of big data with Solr and Hadoop

35© 2015 Rogue Wave Software, Inc. All Rights Reserved.

Rod [email protected]

See us in action:www.roguewave.com

Page 36: Real-time searching of big data with Solr and Hadoop

36© 2015 Rogue Wave Software, Inc. All Rights Reserved.