[9]-Administration-Tuning Presto & Properties Reference

 

原文

https://prestodb.io/docs/current/admin/tuning.html

Tuning Presto

默认的配置在大多数工作负载下均可正常执行,如果遇到一些特殊集群性能问题吗,下面的信息将有所帮助

Config Properties

See Properties Reference.

 

JVM Settings

下面内容将有助于帮助诊断GC问题:

-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCCause
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-XX:+PrintReferenceGC
-XX:+PrintClassHistogramAfterFullGC
-XX:+PrintClassHistogramBeforeFullGC
-XX:PrintFLSStatistics=2
-XX:+PrintAdaptiveSizePolicy
-XX:+PrintSafepointStatistics
-XX:PrintSafepointStatisticsCount=1

Properties Reference

下面的一些配置properties 将有助于Presto调优,当需要时改变它的性能

General Properties

distributed-joins-enabled

  • Type:boolean
  • Default value:true

使用hash分布式joins代替 broadcast joins,Distributed joins需要将所有的表根据join key的hash进行重新分布,

这(有时实际)会比broadcast joins慢,但允许更大数据量的joins。Broadcast joins

需要所有的右表过滤后可以放在每个节点node的内存中,而distributed joins 只需要可以放在在所有节点的分布式内存中即可。

【提示】该配置也可以在每次查询中使用 distributed_join session property 进行配置

redistribute-writes

  • Type: boolean
  • Default value: true

该项配置使能写数据之前的数据再分布(redistribution),

这有助于减小集群中跨节点的hash写数据时的数据倾斜影响。如果已知数据非倾斜,可以失能,避免所有数据跨网络的的redistribution

【提示】该配置也可以在每次查询中使用  redistribute_writes session property 进行配置

resources.reserved-system-memory

  • Type: data size
  • Default value: JVM max memory * 0.4

预保留的JVM memory,用于内部计算,用于一些不直接作用于用户查询、被用户查询控制的事务。

例如:output buffers, code caches等,同时包含一些不被内存跟踪监控系统tracked的内存

该property主要用于避免JVM的OOM,默认的参数适合小JVM heap sizes 和 集群高并发查询,

如果以大heap运行很少的查询,可以设置一个更小的参数。一般参数越大JVM OutOfMemoryError概率越小

Spilling Properties

experimental.spill-enabled

  • Type: boolean
  • Default value: false

尝试向磁盘spilling memory 避免查询出现超memory限制( exceeding memory limits)

Spilling通过向磁盘卸载(offloading)memory 来工作,这个过程允许占用大内存的查询得以运行,

当然这是以减慢执行为代价的。目前spilling支持 aggregations and joins (inner and outer),

该property不会减少window functions, sorting and other join types的内存使用

【提示】

  • 这是一个实验测试阶段的特性,使用时要格外关注
  • 可以通过spill_enabled session property配置
  • 使能后必须同时使能experimental.spiller-spill-path 

 

experimental.spiller-spill-path

  • Type:string
  • No default value. Must be set when spilling is enabled

spilled内容 写入的目录,可以是一个逗号分隔的list,同步到多个directories,

这有助于使用系统中多个drives

不建议向 system drives中spill,更重要的是不要向drive中spill,drive中是JVM logs写入,

如果磁盘应用超负荷,会导致JVM长期停滞,进而查询失败

experimental.spiller-minimum-free-space-threshold

  • Type: double
  • Default value: 0.9

如果磁盘空间利用率超以上值, spill path 变为不可用

experimental.spiller-threads

  • Type: integer
  • Default value: 4

spiller threads数,如果默认参数不能使得潜在spilling device (for example, when using RAID)饱和,增加这个值

experimental.max-spill-per-node

  • Type: data size
  • Default value: 100 GB

单个node上所有查询可利用的最大spill space空间

experimental.query-max-spill-per-node

  • Type: data size
  • Default value: 100 GB

单个node上单个查询可利用的最大spill space空间

experimental.aggregation-operator-unspill-memory-limit

  • Type: data size
  • Default value: 4 MB

单个aggregation operator instance 用于 unspilling的限制空间

Exchange Properties

Exchanges 为一个查询中不同stages跨节点transfer数据,调整一下properties有利于解决节点间的通信问题或提高网络利用率

exchange.client-threads

  • Type: integer
  • Minimum value: 1
  • Default value: 25

exchange clients用于从其他节点fetch data 的线程数,

更高的数值有利于提供大集群的性能(或者集群有高并发查询时有利于提高性能)

但值过大由于context切换和额外的内存使用将导致性能降低

exchange.concurrent-request-multiplier

  • Type: integer
  • Minimum value: 1
  • Default value: 3

Multiplier决定这可利用buffer memory 的并发请求数,

The maximum number of requests is determined using a heuristic of the number of clients that can fit into available buffer space based on average buffer usage per request times this multiplier.

For example, with an exchange.max-buffer-size of 32 MB and 20 MB already used and average size per request being 2MB, the maximum number of clients is multiplier * ((32MB - 20MB) / 2MB) = multiplier * 6. Tuning this value adjusts the heuristic, which may increase concurrency and improve network utilization.

exchange.max-buffer-size

  • Type: data size
  • Default value: 32MB

exchange client buffer的大小,buffer用于存储从其他节点拉取过来的未被处理的数据,

大的buffer将为大集群增加网络吞吐量,减少查询处理时间,但也减少了其他应用可使用的内存

exchange.max-response-size

  • Type: data size
  • Minimum value: 1MB
  • Default value: 16MB

exchange request 返回的response的最大 size,response将被放在exchange client buffer,

这个buffer被exchange的所有requests共享

如有很高的latency,增加这个值有利于提高网络吞吐量,而对于大集群,

减小该值可能有利于提高查询性能,因为它减少了数据倾斜(exchange client buffer 为更多的tasks持有responses 而不是 从更少的tasks中持有更多的数据)

sink.max-buffer-size

  • Type: data size
  • Default value: 32MB

task data的Output buffer size,task data等到upstream tasks拉取。如果 task output是 hash partitioned,

这个buffer被所有partitioned consumers 共享。如果网络延迟大或者集群中的节点数多,增加这个值数据在stages间转移有利于增加网络吞吐量

Task Properties

task.concurrency

  • Type: integer
  • Restrictions: must be a power of two
  • Default value: 16

例如 joins and aggregations并行operators的本地默认并发数。

该值应该根据查询的并发和 worker resource的利用上下调整

当clusters运行很多并发查询,为了保整所有的查询都可利用集群,选择更小的值。

因此添加更多的concurrency 因为context switching and other overhead 将导致slow downs

当clusters一次只运行很少的查询,选择更大的值

可以通过 task_concurrency session property.在每个查询中单独设置

task.http-response-threads

  • Type:integer
  • Minimum value:1
  • Default value:100

可能用于建立用于处理 HTTP responses的最大线程数,Threads按需构建,

空闲时被清除,如果处理的requests数不大,一个大的值是没有开销的。

当集群有高并发查询或者对于有成百上千workers节点的集群,更多的Threads有助于提供性能

task.http-timeout-threads

  • Type:integer
  • Minimum value:1
  • Default value:3

处理产生HTTP responses带来的超时timeouts事件的线程数。如果所有的线程频繁被使用应该提高这个数值,

这可以通过com.facebook.presto.server:name=AsyncHttpExecutionMBean:TimeoutExecutor JMX object.监控,

如果ActiveCount数和PoolSize接近或等值,应该提高线程数

task.info-update-interval

  • Type:duration
  • Minimum value:1ms
  • Maximum value:10s
  • Default value:3s

控制task information(信息用于scheduling)的过期问题,

大值将减少coordinator CPU负载,但可能导致split scheduling 不能最优化

task.max-partial-aggregation-memory

  • Type:data size
  • Default value:16MB

distributed aggregations的部分聚合结果的最大size。

增加这个值会带来更少的网络传输和更低的CPU使用率,因为更多的groups在被flushed前保持在本地。同时会带来更多的内存使用

task.max-worker-threads

  • Type:integer
  • Default value:Node CPUs * 2

workers处理splits的threads数,如果worker CPU 使用率低、

所有的threads被处于被应用中,增大该值有利于提高吞吐,但会增加heap空间的使用。过大值由于context切换回降低性能。

Sets the number of threads used by workers to process splits. Increasing this number can improve throughput if worker CPU utilization is low and all the threads are in use,可通过com.facebook.presto.execution.executor:name=TaskExecutor.RunningSplits JXM object 的RunningSplits property 设置

task.min-drivers

  • Type:integer
  • Default value:task.max-worker-threads * 2

worker上运行 leaf splits的最大 target number。2是最小值,

因为每个eaf tas保证至少3个运行中的splits。为额防止deadlocks Non-leaf tasks 也必须有保障

小值可以为新tasks提高responsiveness,但导致资源利用率低,大值提高资源利用率,但使用额外的内存

task.writer-count

  • Type: integer
  • Restrictions: must be a power of two
  • Default value: 1

每个query的每个worker的并发写线程数,提高这个值会增加写的速度,

尤其当query不存在I/O瓶颈,可以利用额外的CUP并行写(一些connectors可能因为压缩或者因素的写操作有CPU瓶颈)

设置的值过大使得资源过度使用会导致cluster过载

可通过 task_writer_count session property在每次查询中设置

Node Scheduler Properties

node-scheduler.max-splits-per-node

  • Type:integer
  • Default value:100

splits(可运行在每个 worker node)的总数,

如果查询大批量的提交(如周期性的运行大group)或者为了使得connectors可以很快的完成许多splits

,建议一个大的值。增加这个值因为为了保证workers有足够多的splits并保证充分利用, 可能会增大查询的延迟。

设置值过大会导致内存浪费,因为workers间splits不均衡导致性能降低。

理想情况下,设置为至少有一个split等待处理的一个值,但该值不太大。

node-scheduler.max-pending-splits-per-task

  • Type:integer
  • Default value:10

The number of outstanding splits that can be queued for each worker node for a single stage of a query, even when the node is already at the limit for total number of splits. Allowing a minimum number of splits per stage is required to prevent starvation and deadlocks.

This value must be smaller than node-scheduler.max-splits-per-node, will usually be increased for the same reasons, and has similar drawbacks if set too high.

node-scheduler.min-candidates

  • Type:integer
  • Minimum value:1
  • Default value:10

candidate nodes的最小值,当为一个split选择 target node时node scheduler会评估这个值

设置过小不利于splits跨worker节点的均衡,设置过大会增加查询延迟,增加coordinator中的CUP使用

node-scheduler.network-topology

  • Type: string
  • Allowed values: legacyflat
  • Default value: legacy

Optimizer Properties

optimizer.dictionary-aggregation

  • Type: boolean
  • Default value: false

使能dictionaries中aggregations的优化,每次查询中可通过 dictionary_aggregation session property设置

optimizer.optimize-hash-generation

  • Type:boolean
  • Default value:true

为distribution,joins, and aggregations执行前计算hash code,

为以后的operations共享计算结果,多次重复计算的CPU使用,但增加了hashes的额外网络传输。大多数情况下整体会减少查询时间。

每次查询中可通过optimize_hash_generation session property设置

为了使得执行计划 query plan 易读,在使用 EXPLAIN 时可以失能这个值

optimizer.optimize-metadata-queries

  • Type:boolean
  • Default value:false

用存在metadata中的一些值失能一些聚合aggregations的优化,这使得Presto可以以常数时间执行一些简单的查询。

目前该优化应用于 maxmin and approx_distinct of partition keys and other aggregation insensitive to the cardinality of the input (including DISTINCT aggregates)

主要的缺点是:当connector返回空分区的partition keys 时会产生错误结果

特别是, Hive connector会返回空分区(如果他们是被其他系统创建的,Presto不会创建空分区)

optimizer.optimize-single-distinct

  • Type: boolean
  • Default value: true

The single distinct optimization will try to replace multiple DISTINCT clauses with a single GROUP BY clause, which can be substantially faster to execute.

optimizer.push-aggregation-through-join

  • Type:boolean
  • Default value:true

当聚合实在join之后时,并且join之外的所有columns都在 grouping子句中,

这个聚合会被下推,可通过push_aggregation_through_join session property 设置

This optimization is particularly useful for correlated scalar subqueries, which get rewritten to an aggregation over an outer join. For example:

SELECT * FROM item i
    WHERE i.i_current_price > (
        SELECT AVG(j.i_current_price) FROM item j
            WHERE i.i_category = j.i_category);

Enabling this optimization can substantially speed up queries by reducing the amount of data that needs

to be processed by the join. However, it may slow down some queries that have very selective joins. This can also be specified on a per-query basis using the push_aggregation_through_join session property.

optimizer.push-table-write-through-union

  • Type: boolean
  • Default value: true

当使用UNION ALL写数据时 允许并行写,增加写表速度,可通过 push_table_write_through_union session property.设置

注意当系统本身以过载,再使用该功能可能会减慢查询

Regular Expression Function Properties

The following properties allow tuning the Regular Expression Functions.

regex-library

  • Type:string
  • Allowed values:JONIRE2J
  • Default value:JONI

regular expression functions使用的library,JONI一般会快些,

但对于一些特性 expression patterns 会有额外的时间消耗,RE2J使用特殊的算法保证线性时间,但通常会慢

re2j.dfa-states-limit

  • Type: integer
  • Minimum value: 2
  • Default value: 2147483647

The maximum number of states to use when RE2J builds the fast but potentially memory intensive deterministic finite automaton (DFA) for regular expression matching. If the limit is reached, RE2J will fall back to the algorithm that uses the slower, but less memory intensive non-deterministic finite automaton (NFA). Decreasing this value decreases the maximum memory footprint of a regular expression search at the cost of speed.

re2j.dfa-retries

  • Type: integer
  • Minimum value: 0
  • Default value: 5

The number of times that RE2J will retry the DFA algorithm when it reaches a states limit before using the slower, but less memory intensive NFA algorithm for all future inputs for that search. If hitting the limit for a given input row is likely to be an outlier, you want to be able to process subsequent rows using the faster DFA algorithm. If you are likely to hit the limit on matches for subsequent rows as well, you want to use the correct algorithm from the beginning so as not to waste time and resources. The more rows you are processing, the larger this value should be.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值