impala 无法识别云服务器ssd
|  view  
impala 在读写本地磁盘时会根据系统配置num_threads_per_disk
项决定每个磁盘使用几个线程,如果么有配,默认情况下对于每一个机械磁盘启动1个线程,这样可以避免大量的随机读取,避免大量的磁盘寻道;对于SSD默认情况对于每一块磁盘启动8个线程。
Flag | Description | Default | Current value |
---|---|---|---|
num_io_threads_per_solid_state_disk (int32) | Number of I/O threads per solid state disk. Has priority over num_threads_per_disk. If neither is set, defaults to 8 thread(s) per solid state disk | 0 | 0 |
num_io_threads_per_rotational_disk (int32) | Number of I/O threads per rotational disk. Has priority over num_threads_per_disk. If neither is set, defaults to 1 thread(s) per rotational disk | 0 | 0 |
num_threads_per_disk (int32) | Number of I/O threads per disk | 0 | 0 |
遇到的问题
但是在使用过程中发现,当部署到挂载SSD的云服务器上时,impala 将磁盘识别为机械磁盘,并默认对每个磁盘只使用 1 个线程,影响了性能。
原因
查阅impala源码在 DiskInfo::GetDeviceNames()
中发现 impala 判断磁盘是否为 SSD 的方法是读取系统配置 /sys/block/{diskname}/queue/rotational
// Determine if the disk is rotational or not.
for (int i = 0; i < disks_.size(); ++i) {
// We can check if it is rotational by reading:
// r/<device>/queue/rotational
// If the file is missing or has unexpected data, default to rotational.
stringstream ss;
ss << "/sys/block/" << disks_[i].name << "/queue/rotational";
ifstream rotational(ss.str().c_str(), ios::in);
if (rotational.good()) {
string line;
getline(rotational, line);
if (line == "0") disks_[i].is_rotational = false;
}
if (rotational.is_open()) rotational.close();
}
云服务器中即使使用SSD,该配置也可能是旋转磁盘或者配置为空, 所以impala会将其视作旋转磁盘并默认线程数为 1。
解决方案:
可以手动修改 /sys/block/{diskname}/queue/rotational
为 0
或者如果服务器所有磁盘都是SSD的话可以直接修改配置 num_threads_per_disk=8
这样所有的磁盘都会使用 8 个线程进行读写操作