Return-Path: Delivered-To: apmail-hadoop-hbase-user-archive@minotaur.apache.org Received: (qmail 8950 invoked from network); 16 Jan 2010 01:32:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jan 2010 01:32:52 -0000 Received: (qmail 47725 invoked by uid 500); 16 Jan 2010 01:32:51 -0000 Delivered-To: apmail-hadoop-hbase-user-archive@hadoop.apache.org Received: (qmail 47667 invoked by uid 500); 16 Jan 2010 01:32:51 -0000 Mailing-List: contact hbase-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-user@hadoop.apache.org Delivered-To: mailing list hbase-user@hadoop.apache.org Received: (qmail 47656 invoked by uid 99); 16 Jan 2010 01:32:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jan 2010 01:32:51 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jbalakrishnan@docomolabs-usa.com designates 216.98.102.228 as permitted sender) Received: from [216.98.102.228] (HELO fridge.docomolabs-usa.com) (216.98.102.228) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jan 2010 01:32:44 +0000 Received: from dcl-ex.dcml.docomolabs-usa.com (viruswall.docomolabs-usa.com [172.21.96.230]) by fridge.docomolabs-usa.com (Postfix) with ESMTP id EAD1C1B848 for ; Fri, 15 Jan 2010 17:32:23 -0800 (PST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: HBase as DB tier for Tomcat - best practices to instantiate HTables? Date: Fri, 15 Jan 2010 17:35:04 -0800 Message-ID: <2FD61F37AFF16D4DB46149330E4273C7029DCE9A@dcl-ex.dcml.docomolabs-usa.com> In-Reply-To: <7c962aed1001151647k12d5aff4r51f91997596a423c@mail.gmail.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: HBase as DB tier for Tomcat - best practices to instantiate HTables? Thread-Index: AcqWRfHr97ZTdM74S/aYYWOY0CmxHwABKPAg References: <7c962aed1001110930jc8c37ai2eb1765a47283b41@mail.gmail.com> <7c962aed1001121020n61dc1710g168a4ca99b7ffdb7@mail.gmail.com> <7c962aed1001131523r57d1291fo5ca4aa665b5933ff@mail.gmail.com> <7c962aed1001151048l7f55d107n7bdc26e5f198d7b6@mail.gmail.com> <7c962aed1001151647k12d5aff4r51f91997596a423c@mail.gmail.com> From: "Jeyendran Balakrishnan" To: What's the best way to instantiate HTables when the HBase cluster is being accessed from client code running inside a Tomcat web app? The web app dooes the typical CRUD operations [but no table alteration].=20 I read from the lists some time ago that instantiating a HTable in servlet request is not advisable, since instantiating HTable is a bit slow [accesses the meta regions?].=20 So is the best practice for web apps to instantiate a HTable once at startup and cache in the servlet context, and re-use it every request?=20 In that case, is this thread safe [since each request spawns a different thread]? On the other hand, syncing on the single HTable instance at the web application level also slows down requests when contending for this one instance.=20 Also, is holding on to a single HTable instance in a long-running web app a reliable approach?=20 Or is it better to bite the bullet and instantiate an HTable per request after all? Finally, has anybody looked into or have some kind of HTable pool [like DB connection pools], which is a sort of medium between one HTable per web app and one HTable per request? Any advice on best practices from the community would be greatly appreciated. Thanks, Jeyendran