0


hive线程数详解

参考社区:
https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties
https://issues.apache.org/jira/browse/HIVE-5229

HS2的主要改进是把MetaStoreServer从Hiveserver中剥离出来了,形成一个单独的进程运行。
而且hiveserver和metastore server可以同时服务于多个客户端(Beeline CLI,Hive CLI,HCatalog等)。

hiveserver2最大连接数配置:
hive.server2.thrift.max.worker.threads 默认值500,Maximum number of Thrift worker threads
但是这些连接不能同时发出请求,受以下两个参数的控制。
hive.server2.async.exec.wait.queue.size 默认100,是等待队列的长度,HiveServer2 收到请求后,先放到等待队列里。如果队列已满,则抛出异常。
hive.server2.async.exec.threads 默认100,设置计算线程的数量。计算线程从等待队列中取请求,进行处理。这些请求不一定都提交到集群上,如 show databases。

metastore连接池数量配置:
datanucleus.connectionPool.maxPoolSize 缺省值为10,如果poolSize=100,有3个HMS实例,每个服务器有4个池,则可以容纳1200个连接。
mysql /etc/my.conf max_connections = 3000 默认151,最大用户连接数建议3000

其他优化线程数配置:
hive.metastore.fshandler.threads 缺省值为15,用于在MSCK阶段中扫描分区的线程数。
hive.mv.files.thread 默认值为15,插入数据时线程数,Hive将数据从临时文件夹移动到最终位置,这个移动操作实际上是一个复制+删除操作。
hive.compactor.worker.threads 默认值为0,在这个metastore实例上运行多少个合并工作线程。支持事务时至少在一个Metastore实例上大于0。
hive.load.dynamic.partitions.thread 默认值为15,用于加载动态生成的分区的线程数。加载需要将文件重命名为它的最终位置,并更新关于新分区的一些元数据。当有大量动态生成的分区时,增加这个值可以提高性能。根据服务器配置修改。
hive.exec.input.listing.max.threads 默认值为15,Hive用来监听输入文件的最大线程数。当需要读取大量分区时,增加这个值可以提高性能。根据服务器配置进行调整
hive.driver.parallel.compilation.global.limit 0或负值为无限制,同时编译查询并发。Hive默认同时只能编译一段HiveQL,并上锁。将hive.driver.parallel.compilation设置为true,各个会话可以同时编译查询,提高工作效。否则如果在UDF中执行了一段HiveQL,或者多个用户同时使用的话, 就会锁住。
hive.exec.max.dynamic.partitions 默认值为1000,表示一个动态分区语句可以创建的最大动态分区个数,超出报错。spark-sql需指定 --hiveconf hive.exec.max.dynamic.partitions=10000
hive.exec.max.dynamic.partitions.pernode=100 默认100,一般可以设置大一点,比如1000。表示每个maper或reducer可以允许创建的最大动态分区个数,默认是100,超出则会报错。
hive.exec.max.created.files =10000默认10000,全局可以创建的最大文件个数,超出报错。

如果抛出以下错误,则建议调大 hive.server2.async.exec.wait.queue.size。
rg.apache.hive.service.cli.HiveSQLException: java.lang.RuntimeException: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@6ef9d564 rejected from java.util.concurrent.ThreadPoolExecutor@6e2c02d2[Running, pool size = 100, active threads = 100, queued tasks = 100, completed tasks = 234]
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:300)
at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:286)
at org.apache.hive.jdbc.HiveStatement.runAsyncOnServer(HiveStatement.java:324)
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:265)
at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:497)
at com.baidu.hive.jdbc.MultiThreadStatementTest.execute(MultiThreadStatementTest.java:82)
at com.baidu.hive.jdbc.MultiThreadStatementTest.lambda$parallelExecute

     0 
    
   
     ( 
    
   
     M 
    
   
     u 
    
   
     l 
    
   
     t 
    
   
     i 
    
   
     T 
    
   
     h 
    
   
     r 
    
   
     e 
    
   
     a 
    
   
     d 
    
   
     S 
    
   
     t 
    
   
     a 
    
   
     t 
    
   
     e 
    
   
     m 
    
   
     e 
    
   
     n 
    
   
     t 
    
   
     T 
    
   
     e 
    
   
     s 
    
   
     t 
    
   
     . 
    
   
     j 
    
   
     a 
    
   
     v 
    
   
     a 
    
   
     : 
    
   
     56 
    
   
     ) 
    
   
     a 
    
   
     t 
    
   
     j 
    
   
     a 
    
   
     v 
    
   
     a 
    
   
     . 
    
   
     u 
    
   
     t 
    
   
     i 
    
   
     l 
    
   
     . 
    
   
     c 
    
   
     o 
    
   
     n 
    
   
     c 
    
   
     u 
    
   
     r 
    
   
     r 
    
   
     e 
    
   
     n 
    
   
     t 
    
   
     . 
    
   
     E 
    
   
     x 
    
   
     e 
    
   
     c 
    
   
     u 
    
   
     t 
    
   
     o 
    
   
     r 
    
   
     s 
    
   
  
    0(MultiThreadStatementTest.java:56) at java.util.concurrent.Executors 
   
  
0(MultiThreadStatementTest.java:56)atjava.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Hive连接数详解
HS2连接配置:
配置Hiveserver2的访问协议,http或者tcp
hive.server2.transport.mode
binary
Server transport mode. “binary” or “http”.
对应http协议的访问端口
hive.server2.thrift.http.port
10001
Port number when in HTTP mode.
对应tcp协议的访问端口
hive.server2.thrift.port
10000
Port number when in TCP mode.
对应在http协议下线程池的线程数
hive.server2.thrift.http.min.worker.threads
5
Minimum number of worker threads when in HTTP mode.

hive.server2.thrift.http.max.worker.threads
500
Maximum number of worker threads when in HTTP mode.
对应在tcp协议下的线程池的线程数:
hive.server2.thrift.min.worker.threads
5
Minimum number of worker threads when in TCP mode.

hive.server2.thrift.max.worker.threads
500
Maximum number of worker threads when in TCP mode.
配置异步线程池的线程数
hive.server2.async.exec.threads
100
Number of threads in the async thread pool for HiveServer2
配置异步线程结束的超时时间(超过这个时间HS会退出):
hive.server2.async.exec.shutdown.timeout
10
Time (in seconds) for which HiveServer2 shutdown will wait for async
threads to terminate
配置异步线程的等待超时时间(超过这个值线程会被回收)
hive.server2.async.exec.keepalive.time
10
Time (in seconds) that an idle HiveServer2 async thread (from the thread pool) will wait
for a new task to arrive before terminating

hive.server2.long.polling.timeout
5000L
Time in milliseconds that HiveServer2 will wait, before responding to asynchronous calls that use long polling
配置请求缓冲队列的长度
hive.server2.async.exec.wait.queue.size
100
Size of the wait queue for async thread pool in HiveServer2.
After hitting this limit, the async thread pool will reject new requests.


本文转载自: https://blog.csdn.net/sunxunyong/article/details/139740843
版权归原作者 sunxunyong 所有, 如有侵权,请联系我们删除。

“hive线程数详解”的评论:

还没有评论