版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 Spinnaker Labs, Inc.Google Cluster Computing Faculty Training Workshop Module V: Hadoop Technical Review Spinnaker Labs, Inc.Overview Hadoop Technical Walkthrough HDFS Databases Using Hadoop in an Academic Environment Performance tips and other toolsYou Say, “tomato”Google calls it:Hadoop equivalen
2、t:MapReduceHadoopGFSHDFSBigtableHBaseChubby(nothing yet but planned) Spinnaker Labs, Inc.Some MapReduce Terminology Job A “full program” - an execution of a Mapper and Reducer across a data set Task An execution of a Mapper or a Reducer on a slice of data a.k.a. Task-In-Progress (TIP) Task Attempt A
3、 particular instance of an attempt to execute a task on a machine Spinnaker Labs, Inc.Terminology Example Running “Word Count” across 20 files is one job 20 files to be mapped imply 20 map tasks + some number of reduce tasks At least 20 map task attempts will be performed more if a machine crashes,
4、etc. Spinnaker Labs, Inc.Task Attempts A particular task will be attempted at least once, possibly more times if it crashes If the same input causes crashes over and over, that input will eventually be abandoned Multiple attempts at one task may occur in parallel with speculative execution turned on
5、 Task ID from TaskInProgress is not a unique identifier; dont use it that way Spinnaker Labs, Inc.MapReduce: High Level Spinnaker Labs, Inc.Node-to-Node Communication Hadoop uses its own RPC protocol All communication begins in slave nodes Prevents circular-wait deadlock Slaves periodically poll for
6、 “status” message Classes must provide explicit serialization Spinnaker Labs, Inc.Nodes, Trackers, Tasks Master node runs JobTracker instance, which accepts Job requests from clients TaskTracker instances run on slave nodes TaskTracker forks separate Java process for task instances Spinnaker Labs, I
7、nc.Job Distribution MapReduce programs are contained in a Java “jar” file + an XML file containing serialized program configuration options Running a MapReduce job places these files into the HDFS and notifies TaskTrackers where to retrieve the relevant program code Wheres the data distribution? Spi
8、nnaker Labs, Inc.Data Distribution Implicit in design of MapReduce! All mappers are equivalent; so map whatever data is local to a particular node in HDFS If lots of data does happen to pile up on the same node, nearby nodes will map instead Data transfer is handled implicitly by HDFS Spinnaker Labs
9、, Inc.Configuring With JobConf MR Programs have many configurable options JobConf objects hold (key, value) components mapping String a e.g., “mapred.map.tasks” 20 JobConf is serialized and distributed before running the job Objects implementing JobConfigurable can retrieve elements from a JobConf S
10、pinnaker Labs, Inc.What Happens In MapReduce?Depth First Spinnaker Labs, Inc.Job Launch Process: Client Client program creates a JobConf Identify classes implementing Mapper and Reducer interfaces JobConf.setMapperClass(), setReducerClass() Specify inputs, outputs JobConf.setInputPath(), setOutputPa
11、th() Optionally, other options too: JobConf.setNumReduceTasks(), JobConf.setOutputFormat() Spinnaker Labs, Inc.Job Launch Process: JobClient Pass JobConf to JobClient.runJob() or submitJob() runJob() blocks, submitJob() does not JobClient: Determines proper division of input into InputSplits Sends j
12、ob data to master JobTracker server Spinnaker Labs, Inc.Job Launch Process: JobTracker JobTracker: Inserts jar and JobConf (serialized to XML) in shared location Posts a JobInProgress to its run queue Spinnaker Labs, Inc.Job Launch Process: TaskTracker TaskTrackers running on slave nodes periodicall
13、y query JobTracker for work Retrieve job-specific jar and config Launch task in separate instance of Java main() is provided by Hadoop Spinnaker Labs, Inc.Job Launch Process: Task TaskTracker.Child.main(): Sets up the child TaskInProgress attempt Reads XML configuration Connects back to necessary Ma
14、pReduce components via RPC Uses TaskRunner to launch user process Spinnaker Labs, Inc.Job Launch Process: TaskRunner TaskRunner, MapTaskRunner, MapRunner work in a daisy-chain to launch your Mapper Task knows ahead of time which InputSplits it should be mapping Calls Mapper once for each record retr
15、ieved from the InputSplit Running the Reducer is much the same Spinnaker Labs, Inc.Creating the Mapper You provide the instance of Mapper Should extend MapReduceBase One instance of your Mapper is initialized by the MapTaskRunner for a TaskInProgress Exists in separate process from all other instanc
16、es of Mapper no data sharing! Spinnaker Labs, Inc.Mapper void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter) Spinnaker Labs, Inc.What is Writable? Hadoop defines its own “box” classes for strings (Text), integers (IntWritable), etc. All values are instances of
17、 Writable All keys are instances of WritableComparable Spinnaker Labs, Inc.Writing For Cache Coherencywhile (more input exists) myIntermediate = new intermediate(input);myIcess();export outputs; Spinnaker Labs, Inc.Writing For Cache CoherencymyIntermediate = new intermediate (junk);wh
18、ile (more input exists) myIntermediate.setupState(input);myIcess();export outputs; Spinnaker Labs, Inc.Writing For Cache Coherency Running the GC takes time Reusing locations allows better cache usage Speedup can be as much as two-fold All serializable types must be Writable anyway, s
19、o make use of the interfaceGetting Data To The Mapper Spinnaker Labs, Inc.Reading Data Data sets are specified by InputFormats Defines input data (e.g., a directory) Identifies partitions of the data that form an InputSplit Factory for RecordReader objects to extract (k, v) records from the input so
20、urce Spinnaker Labs, Inc.FileInputFormat and Friends TextInputFormat Treats each n-terminated line of a file as a value KeyValueTextInputFormat Maps n- terminated text lines of “k SEP v” SequenceFileInputFormat Binary file of (k, v) pairs with some addl metadata SequenceFileAsTextInputFormat Same, b
21、ut maps (k.toString(), v.toString() Spinnaker Labs, Inc.Filtering File Inputs FileInputFormat will read all files out of a specified directory and send them to the mapper Delegates filtering this file list to a method subclasses may override e.g., Create your own “xyzFileInputFormat” to read *.xyz f
22、rom directory list Spinnaker Labs, Inc.Record Readers Each InputFormat provides its own RecordReader implementation Provides (unused?) capability multiplexing LineRecordReader Reads a line from a text file KeyValueRecordReader Used by KeyValueTextInputFormat Spinnaker Labs, Inc.Input Split Size File
23、InputFormat will divide large files into chunks Exact size controlled by mapred.min.split.size RecordReaders receive file, offset, and length of chunk Custom InputFormat implementations may override split size e.g., “NeverChunkFile” Spinnaker Labs, Inc.Sending Data To Reducers Map function receives
24、OutputCollector object OutputCollector.collect() takes (k, v) elements Any (WritableComparable, Writable) can be used Spinnaker Labs, Inc.WritableComparator Compares WritableComparable data Will call WritableCpare() Can provide fast path for serialized data JobConf.setOutputValueGroupingComparator()
25、 Spinnaker Labs, Inc.Sending Data To The Client Reporter object sent to Mapper allows simple asynchronous feedback incrCounter(Enum key, long amount) setStatus(String msg) Allows self-identification of input InputSplit getInputSplit()Partition And Shuffle Spinnaker Labs, Inc.Partitioner int getParti
26、tion(key, val, numPartitions) Outputs the partition number for a given key One partition = values sent to one Reduce task HashPartitioner used by default Uses key.hashCode() to return partition num JobConf sets Partitioner implementation Spinnaker Labs, Inc.Reduction reduce(WritableComparable key, I
27、terator values, OutputCollector output, Reporter reporter) Keys & values sent to one partition all go to the same reduce task Calls are sorted by key “earlier” keys are reduced and output before “later” keys Spinnaker Labs, Inc.Finally: Writing The Output Spinnaker Labs, Inc.OutputFormat Analogo
28、us to InputFormat TextOutputFormat Writes “key valn” strings to output file SequenceFileOutputFormat Uses a binary format to pack (k, v) pairs NullOutputFormat Discards output Spinnaker Labs, Inc.HDFS Spinnaker Labs, Inc.HDFS Limitations “Almost” GFS No file update options (record append, etc); all
29、files are write-once Does not implement demand replication Designed for streaming Random seeks devastate performance Spinnaker Labs, Inc.NameNode “Head” interface to HDFS cluster Records all global metadata Spinnaker Labs, Inc.Secondary NameNode Not a failover NameNode! Records metadata snapshots fr
30、om “real” NameNode Can merge update logs in flight Can upload snapshot back to primary Spinnaker Labs, Inc.NameNode Death No new requests can be served while NameNode is down Secondary will not fail over as new primary So why have a secondary at all? Spinnaker Labs, Inc.NameNode Death, contd If Name
31、Node dies from software glitch, just reboot But if machine is hosed, metadata for cluster is irretrievable! Spinnaker Labs, Inc.Bringing the Cluster Back If original NameNode can be restored, secondary can re-establish the most current metadata snapshot If not, create a new NameNode, use secondary t
32、o copy metadata to new primary, restart whole cluster ( ) Is there another way? Spinnaker Labs, Inc.Keeping the Cluster Up Problem: DataNodes “fix” the address of the NameNode in memory, cant switch in flight Solution: Bring new NameNode up, but use DNS to make cluster believe its the original one S
33、econdary can be the “new” one Spinnaker Labs, Inc.Further Reliability Measures Namenode can output multiple copies of metadata files to different directories Including an NFS mounted one May degrade performance; watch for NFS locks Spinnaker Labs, Inc.Databases Spinnaker Labs, Inc.Life After GFS Str
34、aight GFS files are not the only storage option HBase (on top of GFS) provides column-oriented storage mySQL and other db engines still relevant Spinnaker Labs, Inc.HBase Can interface directly with Hadoop Provides its own Input- and OutputFormat classes; sends rows directly to mapper, receives new
35、rows from reducer But might not be ready for classroom use (least stable component) Spinnaker Labs, Inc.MySQL Clustering MySQL database can be sharded on multiple servers For fast IO, use same machines as Hadoop Tables can be split across machines by row key range Multiple replicas can serve same ta
36、ble Spinnaker Labs, Inc.Sharding & Hadoop Partitioners For best performance, Reducer should go straight to local mysql instance Get all data in the right machine in one copy Implement custom Partitioner to ensure particular key range goes to mysql-aware Reducer Spinnaker Labs, Inc.Academic Hadoo
37、p Requirements Spinnaker Labs, Inc.Server Profile UW cluster: 40 nodes, 80 processors total 2 GB ram / processor 24 TB raw storage space (8 TB replicated) One node reserved for JobTracker/NameNode Two more wouldnt cooperate But still vastly overpowered Spinnaker Labs, Inc.Setup & Maintenance Too
38、k about two days to setup and configure Mostly hardware-related issues Hadoop setup was only a couple hours Maintenance: only a few hours/week Mostly rebooting the cluster when jobs got stuck Spinnaker Labs, Inc.Total Usage About 15,000 CPU-hours consumed by 20 students Out of 130,000 available over
39、 quarter Average load is about 12% Spinnaker Labs, Inc.Analyzing student usage patterns Spinnaker Labs, Inc.Not Quite the Whole Story Realistically, students did most work very close to deadline Cluster sat unused for a few days, followed by overloading for two days straight Spinnaker Labs, Inc.Anal
40、yzing student usage patternsLesson: Resource demands are NOT constant! Spinnaker Labs, Inc.Hadoop Job Scheduling FIFO queue matches incoming jobs to available nodes No notion of fairness Never switches out running job Run-away tasks could starve other student jobs Spinnaker Labs, Inc.Hadoop Security
41、 But on the bright (?) side: No security system for jobs Anyone can start a job; but they can also cancel other jobs Realistically, students did not cancel other student jobs, even when they should Spinnaker Labs, Inc.Hadoop Security: The Dark Side No permissions in HDFS either Just now added in 0.1
42、6 One student deleted the common data set for a project Email subject: “Oops” No students could test their code until data set restored from backup Spinnaker Labs, Inc.Job Scheduling Lessons Getting students to “play nice” is hard No incentive Just plain bad/buggy code Cluster contention caused prob
43、lems at deadlines Work in groups Stagger deadlines Spinnaker Labs, Inc.Another Possibility Amazon EC2 provides on-demand servers May be able to have students use these for jobs “Lab fee” would be $150/student Simple web-based interfaces exist R HadoopOnDemand (HOD) coming soon Injects new nodes into
44、 live clusters Spinnaker Labs, Inc.More Performance & Scalability Spinnaker Labs, Inc.Number of Tasks Mappers = 10 * nodes (or 3/2 * cores) Reducers = 2 * nodes (or 1.05 * cores) Two degrees of freedom in mapper run time: Number of tasks/node, and size of InputSplits See /lu
45、cene-hadoop/HowManyMapsAndReduces Spinnaker Labs, Inc.More Performance Tweaks Hadoop defaults to heap cap of 200 MB Set: mapred.child.java.opts = -Xmx512m 1024 MB / process may also be appropriate DFS block size is 64 MB For huge files, set dfs.block.size = 134217728 mapred.reduce.parallel.copies Set to 1550; more data = more copies Spinnaker Labs, Inc.Dead Tasks Student jobs would “run away”, admin restart needed Very often stuck in huge shuffle process Students did not know about Partitioner class, may have had non-unifor
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年安徽省安全员《A证》考试题库及答案
- 2025年陕西省安全员-A证考试题库附答案
- DB45T-木材加工企业安全规范编制说明
- 学前教育管理学 课件
- 单位管理制度展示汇编人员管理
- 半导体行业分析:AI需求推动运力持续增长互联方案重要性显著提升
- 2022年河北省张家口市第二十中学中考模拟英语试题(原卷版)
- 《本胃癌腹腔镜》课件
- 2025年中国糖果市场深度评估及投资方向研究报告
- 电影投资行业竞争格局及投资价值分析报告
- 护理查房股骨骨折
- 举办活动的申请书范文
- 瑶医目诊图-望面诊病现用图解-目诊
- 2022年四级反射疗法师考试题库(含答案)
- 新《安全生产法》培训测试题
- 政务礼仪-PPT课件
- 特种涂料类型——耐核辐射涂料的研究
- 化工装置常用英语词汇对照
- 物资采购管理流程图
- 无牙颌解剖标志
- 标准《大跨径混凝土桥梁的试验方法》
评论
0/150
提交评论