You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jx...@apache.org on 2013/01/05 20:32:38 UTC

svn commit: r1429365 - in /hbase/branches/0.94/src/main: java/org/apache/hadoop/hbase/rest/Main.java resources/hbase-default.xml

Author: jxiang
Date: Sat Jan  5 19:32:38 2013
New Revision: 1429365

URL: http://svn.apache.org/viewvc?rev=1429365&view=rev
Log:
HBASE-7498 Make REST server thread pool size configurable

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java
    hbase/branches/0.94/src/main/resources/hbase-default.xml

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java?rev=1429365&r1=1429364&r2=1429365&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java Sat Jan  5 19:32:38 2013
@@ -44,6 +44,7 @@ import org.mortbay.jetty.Server;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.thread.QueuedThreadPool;
 
 import com.sun.jersey.spi.container.servlet.ServletContainer;
 
@@ -139,6 +140,17 @@ public class Main implements Constants {
 
     server.addConnector(connector);
 
+    // Set the default max thread number to 100 to limit
+    // the number of concurrent requests so that REST server doesn't OOM easily.
+    // Jetty set the default max thread number to 250, if we don't set it.
+    //
+    // Our default min thread number 2 is the same as that used by Jetty.
+    int maxThreads = servlet.getConfiguration().getInt("hbase.rest.threads.max", 100);
+    int minThreads = servlet.getConfiguration().getInt("hbase.rest.threads.min", 2);
+    QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
+    threadPool.setMinThreads(minThreads);
+    server.setThreadPool(threadPool);
+
     server.setSendServerVersion(false);
     server.setSendDateHeader(false);
     server.setStopAtShutdown(true);

Modified: hbase/branches/0.94/src/main/resources/hbase-default.xml
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/resources/hbase-default.xml?rev=1429365&r1=1429364&r2=1429365&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/resources/hbase-default.xml (original)
+++ hbase/branches/0.94/src/main/resources/hbase-default.xml Sat Jan  5 19:32:38 2013
@@ -899,4 +899,27 @@
     default log cleaners in the list as they will be overwritten in hbase-site.xml.
     </description>
   </property>
+  <property>
+    <name>hbase.rest.threads.max</name>
+    <value>100</value>
+    <description>
+        The maximum number of threads of the REST server thread pool.
+        Threads in the pool are reused to process REST requests. This
+        controls the maximum number of requests processed concurrently.
+        It may help to control the memory used by the REST server to
+        avoid OOM issues. If the thread pool is full, incoming requests
+        will be queued up and wait for some free threads. The default
+        is 100.
+    </description>
+  </property>
+  <property>
+    <name>hbase.rest.threads.min</name>
+    <value>2</value>
+    <description>
+        The minimum number of threads of the REST server thread pool.
+        The thread pool always has at least these number of threads so
+        the REST server is ready to serve incoming requests. The default
+        is 2.
+    </description>
+  </property>
 </configuration>