blob: f9b50d0e6417b8e3fab8fd263cc75263af4495e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container;
import com.yahoo.config.provision.Flavor;
import com.yahoo.container.handler.ThreadpoolConfig;
import com.yahoo.search.config.QrStartConfig;
/**
* Tuning of qr-start config for a container service based on the node flavor of that node.
*
* @author balder
*/
public class NodeFlavorTuning implements
QrStartConfig.Producer,
ThreadpoolConfig.Producer
{
private final Flavor flavor;
public NodeFlavorTuning setThreadPoolSizeFactor(double threadPoolSizeFactor) {
this.threadPoolSizeFactor = threadPoolSizeFactor;
return this;
}
public NodeFlavorTuning setQueueSizeFactor(double queueSizeFactor) {
this.queueSizeFactor = queueSizeFactor;
return this;
}
private double threadPoolSizeFactor = 8.0;
private double queueSizeFactor = 8.0;
NodeFlavorTuning(Flavor flavor) {
this.flavor = flavor;
}
@Override
public void getConfig(QrStartConfig.Builder builder) {
builder.jvm.availableProcessors(Math.max(2, (int)Math.ceil(flavor.getMinCpuCores())));
}
@Override
public void getConfig(ThreadpoolConfig.Builder builder) {
// Controls max number of concurrent requests per container
int workerThreads = Math.max(2, (int)Math.ceil(flavor.getMinCpuCores() * threadPoolSizeFactor));
builder.maxthreads(workerThreads);
// This controls your burst handling capability.
// 0 => No extra burst handling beyond you max concurrent requests (maxthreads).
// N => N times max concurrent requests as a buffer for handling bursts
builder.queueSize((int)(workerThreads * queueSizeFactor));
}
}
|