如何解决为什么Impala扫描节点的速度很慢RowBatchQueueGetWaitTime?
此查询通常在10秒内返回,但有时需要40秒或更长时间。
群中有两个执行者节点,两个节点的配置文件之间没有显着差异,以下是其中之一:
<p>Lorem ipsum dolor sit amet,ocurreret tincidunt philosophia in sea,at pro postea ullamcorper. Mea ei aeque feugiat,cum ut utinam conceptam,in pro partem veritus molestiae. Omnis efficiantur an eum,te mel quot perpetua. Ad duo autem dolore,vocent
lucilius te cum,ut duo quem singulis.</p>
<p>Has ex idque repudiandae,an mei munere philosophia. Sale molestie id eos,eam ne blandit adipisci. Ei eam ipsum dissentiunt. Ei vel accusam dolores efficiantur.</p>
<div class="hole">
<p>There is an <span class="hole-text">HOLE</span> here</p>
</div>
我们可以注意到 HDFS_SCAN_NODE (id=0):(Total: 39s818ms,non-child: 39s818ms,% non-child: 100.00%)
- AverageHdfsReadThreadConcurrency: 0.07
- AverageScannerThreadConcurrency: 1.47
- BytesRead: 563.73 MB (591111366)
- BytesReadDataNodeCache: 0
- BytesReadLocal: 0
- BytesReadRemoteUnexpected: 0
- BytesReadShortCircuit: 0
- CachedFileHandlesHitCount: 0 (0)
- CachedFileHandlesMissCount: 560 (560)
- CollectionItemsRead: 0 (0)
- DecompressionTime: 1s501ms
- MaterializeTupleTime(*): 11s685ms
- MaxCompressedTextFileLength: 0
- NumColumns: 9 (9)
- NumDictFilteredRowGroups: 0 (0)
- NumDisksAccessed: 1 (1)
- NumRowGroups: 56 (56)
- NumScannerThreadMemUnavailable: 0 (0)
- NumScannerThreadReservationsDenied: 0 (0)
- NumScannerThreadsStarted: 4 (4)
- NumScannersWithNoReads: 0 (0)
- NumStatsFilteredRowGroups: 0 (0)
- PeakMemoryUsage: 142.10 MB (149004861)
- PeakScannerThreadConcurrency: 2 (2)
- PerReadThreadRawHdfsThroughput: 151.39 MB/sec
- RemoteScanRanges: 1.68K (1680)
- RowBatchBytesEnqueued: 2.32 GB (2491334455)
- RowBatchQueueGetWaitTime: 39s786ms
- RowBatchQueuePeakMemoryUsage: 1.87 MB (1959936)
- RowBatchQueuePutWaitTime: 0.000ns
- RowBatchesEnqueued: 6.38K (6377)
- RowsRead: 73.99M (73994828)
- RowsReturned: 6.40M (6401849)
- RowsReturnedRate: 161.27 K/sec
- ScanRangesComplete: 56 (56)
- ScannerThreadsInvoluntaryContextSwitches: 99 (99)
- ScannerThreadsTotalWallClockTime: 1m10s
- ScannerThreadsSysTime: 630.808ms
- ScannerThreadsUserTime: 12s824ms
- ScannerThreadsVoluntaryContextSwitches: 1.25K (1248)
- TotalRawHdfsOpenFileTime(*): 9s396ms
- TotalRawHdfsReadTime(*): 3s789ms
- TotalReadThroughput: 11.70 MB/sec
Buffer pool:
- AllocTime: 1.240ms
- CumulativeAllocationBytes: 706.32 MB (740630528)
- CumulativeAllocations: 578 (578)
- PeakReservation: 140.00 MB (146800640)
- PeakUnpinnedBytes: 0
- PeakUsedReservation: 33.83 MB (35471360)
- ReadIoBytes: 0
- ReadIoOps: 0 (0)
- ReadIoWaitTime: 0.000ns
- WriteIoBytes: 0
- WriteIoOps: 0 (0)
- WriteIoWaitTime: 0.000ns
很高,差不多40秒,但是我不知道为什么,承认RowBatchQueueGetWaitTime
花了9秒而TotalRawHdfsOpenFileTime
花了近4秒,我仍然无法解释其他27秒花在哪里。
您能提出可能的问题,我该如何解决?
解决方法
扫描节点中的线程模型非常复杂,因为有两层用于扫描和I / O的工作线程-我将它们称为扫描器和I / O线程。我将自上而下,指出一些潜在的瓶颈以及如何识别它们。
RowBatchQueueGetWaitTime高表示扫描所消耗的主线程花费大量时间等待扫描程序线程产生行。差异的一个主要来源可能是扫描程序线程的数量-如果系统处于资源压力之下,则每个查询可以获得的线程数更少。因此,请密切注意AverageScannerThreadConcurrency,以了解其是否有所变化。
扫描程序线程将花费时间进行各种操作。大部分时间是
- 由于操作系统安排了其他线程而未在运行。
- 等待I / O线程从存储系统读取数据
- 解码数据,评估谓词,其他工作
使用#1,您会发现ScannerThreadsInvoluntaryContextSwitches和ScannerThreadsUserTime / ScannerThreadsSysTime的值比ScannerThreadsTotalWallClockTime低得多。如果ScannerThreadsUserTime比MaterializeTupleTime低很多,那将是另一个症状。
使用#2,您会看到较高的ScannerThreadsUserTime和MaterializeTupleTime。看来这里有大量的CPU时间要用,但不是大部分时间。
要确定#3,我建议查看片段配置文件中的TotalStorageWaitTime,以了解线程实际上在等待I / O上花费了多少时间。我还在最新的Impala版本中添加了ScannerIoWaitTime,由于它位于扫描仪配置文件中,因此更加方便。
如果存储等待时间很慢,则需要考虑一些事项
- 如果TotalRawHdfsOpenFileTime高,则可能是打开文件成为瓶颈。这可以在包括HDFS在内的任何存储系统上发生。参见Why Impala spend a lot of time Opening HDFS File (TotalRawHdfsOpenFileTime)?
- 如果TotalRawHdfsReadTime高,则从存储系统读取可能会很慢(例如,如果数据不在OS缓冲区高速缓存中,或者是像S3这样的远程文件系统)
- 其他查询可能正在争用I / O资源和/或I / O线程
在您的情况下,我怀疑根本原因既是此查询的打开速度慢的文件,又是其他查询的打开速度慢的文件,这导致扫描程序线程被占用。可能启用文件句柄缓存将解决此问题-通过这样做,我们已经看到了生产部署性能的显着提高。
另一个值得一提的可能性是,内置JVM正在执行垃圾回收-这可能会阻止某些HDFS操作。我们有一些暂停检测功能,可以在JVM暂停时记录消息。您还可以查看/ memz调试页面,我认为该页面具有一些GC统计信息。或连接其他Java调试工具。
, ScannerThreadsVoluntaryContextSwitches: 1.25K (1248)
意味着在1248种情况下,扫描线程被“卡住”,等待某些外部资源,然后进入sleep()。
该资源最有可能是磁盘IO。这将解释平均读取速度(TotalReadThroughput: *11.70 MB*/sec
)很低,而每次读取的吞吐量(PerReadThreadRawHdfsThroughput: 151.39 MB/sec
)却“正常”的情况。
编辑
要提高性能,您可能需要尝试:
- 启用short circuit reads(
dfs.client.read.shortcircuit=true
) - 配置HDFS缓存和alter Impala table to use cache
(请注意,这两种方法都适用于针对HDFS运行Impala而非某种对象存储的情况。)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。