HBaseClient端会建立跟HRegionServer或者HMaster的tcp连接,而这个连接在一定时间内没有请求的话,那么这个连接就会被关闭。如果应用请求比较少,加上跨机房的话,tcp连接的建立会比较耗时,导致请求rt稍高,这个时候可以调整tcp连接的存活时间,参数是client端的
this.maxIdleTime = conf.getInt("hbase.ipc.client.connection.maxidletime", 10000);
//10s
具体逻辑在HBaseClient 的Connection.waitForWork里面
HBaseClient
/* wait till someone signals us to start reading RPC response or
* it is idle too long, it is marked as to be closed,
* or the client is marked as not running.
*
* Return true if it is time to read a response; false otherwise.
*/
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
protected synchronized boolean waitForWork() {
} else if (calls.isEmpty()) { // idle connection closed or stopped
markClosed(null);
return false;
}
}