我们常常需要对HDFS或者mapreduce进行一些性能方面的测试,比如测试rpc的性能,测试DFS的IO读写性能,测试DFS的吞吐率性能,测试namenode的benchmark性能,mapreduce的sort性能等等。在hadoop的发行版中,其实已经提供了许多类似的工具,并已经打包成jar,供我们使用。以下是0.20.2中自带的一系列工具列表:
| DFSCIOTest |
Distributed i/o benchmark of libhdfs. |
| DistributedFSCheck |
Distributed checkup of the file system consistency. |
| MRReliabilityTest |
A program that tests the reliability of the MR framework by injecting faults/failures |
| TestDFSIO |
Distributed i/o benchmark. |
| dfsthroughput |
measure hdfs throughput |
| filebench: |
Benchmark SequenceFile(Input|Output)Format (block,record compressed and uncompressed), Text(Input|Output)Format (compressed and uncompressed) |
| loadgen |
Generic map/reduce load generator |
| mapredtest |
A map/reduce test check. |
| minicluster |
Single process HDFS and MR cluster. |
| nnbench |
A benchmark that stresses the namenode. |
| testbigmapoutput |
A map/reduce program that works on a very big non-splittable file and does identity map/reduce |
| testfilesystem |
A test for FileSystem read/write. |
| testrpc |
A test for rpc |
| testsequencefile |
A test for flat files of binary key value pairs. |
| threadedmapbench: |
A map/reduce benchmark that compares the performance of maps with multiple spills over maps with 1 spill |
单独运行每个工具,都会有详细的帮助信息输出到命令行,根据命令行提示,就可以对很多想要进行性能测试的模块进行压力和性能测试。每个工具最终都会输出一个统计结果。若要定制自定义的压力测试工具,可以自己动手编写相应的压力测试程序,然后注册到org.apache.hadoop.test.AllTestDriver中。如想要了解每个benchmark工具的细节,可以从AllTestDriver中找到相应的测试工具的代码。
总结
可以看出,hadoop发行版中的测试环境已经非常丰富,对于模拟集群环境的类,工具等都已经有不少了。这些代码和工具对于程序开发者来说,非常有用。要编写新的测试代码,添加新的测试用例,也都非常方便。对于避免程序修改引起其他的相关问题等,都非常有效。
摘自淘宝数据平台与产品官方博客:http://www.tbdata.org/archives/1133