We have a java servlet that connects to a couple of HBase tables on top of Hadoop via org.apache.hadoop.hbase.client.HTable.HTable.
Invariably the first HTable instantiation will be very slow (~2800ms) while subsequent call will be fast (~60ms).
Reading the HTable class source it indicates that zookeeper connections are shared across HTable instances, hence this could correspond to some zookeeper initialization delay but still I am wondering if others see a similar delay and if there is some configuration option that could speed things up?
After investigation it seems that yes it is normal that the first
HTableinitialization takes several seconds. Several sources recommend usingHTablePoolto share the HTable interfaces accross threads and thus avoid to incur the initialization delay more than once. TheHTableobject itself should not be shared because it is not threadsafe.