Skip to main content

Size each component,
prioritize each workload.

How TDP Kubernetes lets you size the components, scale the workers, and distribute the workloads according to the company's priorities.

A company may need to expand BI queries in Trino during the monthly close, run batch loads in Spark and keep event ingestion in Kafka throughout the day.

TDP Kubernetes offers resource, replica and placement settings to organize these demands.

The serving capacity results from the combination of these settings, the resources available in the cluster and the behavior of the applications.

The resource and scheduling mechanisms belong to Kubernetes. The values identified as default and the autoscaling integrations described here are choices of the TDP Kubernetes charts. The business scenarios illustrate how these resources can be combined and sized for each customer.

Topics on this page

Resources per component​

Each component declares how much it requests from the cluster and how much it can consume at most.

Kubernetes uses two values per container.

The request is the amount considered in scheduling: Kubernetes looks for a node with enough allocatable capacity for the Pod requests, considering what the other workloads have already requested.

The limit is the ceiling: above the CPU limit, the container is throttled. Above the memory limit, it can be terminated.

With both defined, the CPU and memory consumption of each component is bounded, which helps size the cluster.

Full sizing also includes disk, network, storage and shared services.

The CPU request corresponds to shared processing capacity. Dedicating physical cores depends on a specific node configuration.

Default

Initial settings

The Trino coordinator and each worker have CPU and memory requests and limits defined in tdp-trino.coordinator.resources and tdp-trino.worker.resources. Each JupyterHub user server, in tdp-jupyter.singleuser.cpu and tdp-jupyter.singleuser.memory. These values can be adjusted to the workload profile.

Configurable

Requests and limits in the values file

The charts allow adjusting the CPU and memory of the main Pods of each component, without changing the rest of the configuration.

Concept

QoS class

Kubernetes classifies each Pod by the relationship between requests and limits. When a node runs out of memory, the kubelet chooses the Pods to evict considering whether consumption exceeds the request, the Pod priority and consumption relative to the request.

Guaranteed

All containers have requests equal to limits, for both CPU and memory. Since they do not exceed the request, these Pods are among the last to be evicted.

Burstable

At least one request or limit defined, without meeting the Guaranteed criterion. The Pod can use more than its reservation when the node has spare capacity.

BestEffort

No request or limit. Any consumption exceeds the request, so these Pods are among the first to be evicted under memory pressure.

Scenario: per-user analysis environments​

Situation: a company offers JupyterHub notebooks so that analysts from different areas can explore the data.

Each user receives their own server.

What TDP does: the JupyterHub chart defines an initial CPU and memory profile for each server: the request in singleuser.cpu.guarantee and singleuser.memory.guarantee, the limit in singleuser.cpu.limit and singleuser.memory.limit, as in the example below.

values.yaml (excerpt)
tdp-jupyter:
singleuser:
cpu:
guarantee: 2
limit: 4
memory:
guarantee: 4G
limit: 8G

Effect: the consumption of each server is bounded, and the number of simultaneous users can be planned: the total requested is the sum of the requests of all running servers, in addition to the resources of the Hub and the other components. With requests below the limits, these servers are in the Burstable QoS class.

Usage above the requests, up to the limits, also enters the planning of the total capacity and of the operational margin of the cluster.

Resources in the values file

Structure of resources and how to apply the values file: General configuration.

Replicas​

Each component grows according to the role of its instances.

Each component declares its instances in the values file.

Processing workers, event brokers and storage nodes have different functions: the growth of each one follows its own mechanisms for distributing work and data.

Kubernetes schedules the new instances on the nodes that meet the resource and placement requirements.

Trino

The query workers are scaled out through tdp-trino.server.workers or through autoscaling. The coordinator remains the coordination component of the cluster.

Spark

The workers are adjusted through spark.worker.replicaCount or through the optional HPA. The application drivers and executors are also sized to make use of the available resources.

Kafka

The number of nodes is declared in nodePool.replicas. Expanding the cluster includes distributing the partitions and the data replicas.

Ozone

New Datanodes, declared in tdp-ozone.datanode.replicas, add resources to the storage layer. The volume size and the data replication enter this sizing.

NiFi

Additional nodes are declared in nifiCluster.nodes. The distribution of processing across the nodes depends on the flow configuration.

Hive Metastore

The serving instances are declared in tdp-hive-metastore.metastore.replicas, in line with the capacity and the connections of the shared PostgreSQL.

Hive Metastore replicas and PostgreSQL connections

Each Hive Metastore replica opens its own connection pools to PostgreSQL.

When increasing the replicas, the database connection limit must keep up.

With the embedded PostgreSQL, the chart rejects a combination of replicas and pool that exceeds this limit.

Autoscaling​

The number of workers follows the observed metrics, within a planned range.

The Kubernetes HPA (Horizontal Pod Autoscaler) can adjust the number of replicas by CPU, memory or other configured metrics. In the TDP charts described here, the CPU and memory targets use utilization relative to the request.

KEDA extends this mechanism to metrics from other sources, such as Prometheus queries, and allows an idle workload to be scaled down to zero replicas.

These mechanisms adjust the worker Pods.

For the new Pods to start, the nodes need available capacity, or the cluster needs to be integrated with an infrastructure expansion mechanism.

Quotas, permissions and scheduling rules must also allow these new Pods.

Two scaling paths for Trino workersIn the default path, the Metrics Server provides CPU and memory metrics and the HPA adjusts the desired number of workers according to the utilization targets. In the optional path, the JMX exporter exposes Trino metrics, Prometheus collects them and KEDA uses the configured triggers to adjust the scale. Use one path at a time. New workers need capacity available in the cluster. On scale-down, the worker waits for its tasks within the configured shutdown deadline.DEFAULT · HPAOPTIONAL · KEDAMetrics Serverworker CPU and memoryHPACPU and memory targetsJMX exporterTrino metricsPrometheusmetrics collectionKEDAconfigured triggersTrino workersW1W2++replicas: tdp-trino.server.workersmaximum: autoscaling.maxReplicasGraceful shutdownwaits for tasks until the defined deadlineadjustsadjustson scale-down
Figure 1 - Worker autoscaling alternatives provided in the TDP Kubernetes Trino chart
Trino: workers HPA

In the TDP Kubernetes chart, it is enabled (tdp-trino.server.autoscaling.enabled), with the maximum number of workers in maxReplicas and the utilization targets in targetCPUUtilizationPercentage and targetMemoryUtilizationPercentage. These values are adjustable. The controller calculates the desired count. Scheduling depends on the cluster capacity.

Spark: workers HPA

Available through configuration (spark.worker.autoscaling.enabled). Defines a minimum and a maximum number of workers and the CPU and memory targets.

Trino: KEDA

Available through configuration (tdp-trino.server.keda.enabled). One option documented in TDP uses Trino metrics collected through JMX and Prometheus. KEDA offers other trigger types. The choice requires configuring and validating the integration.

Trino: gradual scale-down

Graceful shutdown is enabled: the worker stops receiving tasks and waits for the running ones within the configured period. This period can be adjusted to the duration of the queries served. Tasks still running at the end of the period may fail.

Scenario: BI queries during the monthly close​

Situation: a company concentrates the issuing of financial reports in the monthly close, with higher query concurrency in Trino.

What TDP does: the Trino chart ships with the workers HPA enabled.

For this period, the range of workers, the targets and the resources are as below:

values.yaml (excerpt)
tdp-trino:
server:
workers: 2
autoscaling:
enabled: true
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 300
scaleUp:
stabilizationWindowSeconds: 0

worker:
jvm:
maxHeapSize: "12G"
resources:
requests:
cpu: "2"
memory: "8Gi"
limits:
cpu: "4"
memory: "16Gi"

The JVM heap, in worker.jvm.maxHeapSize, rises together with the memory limit, in worker.resources.limits.memory: a heap larger than the limit makes the pod get terminated by OOM-kill.

Effect: the total requested by the workers is the sum of the requests of all replicas, in addition to the coordinator and the other services of the environment. The HPA considers both utilization targets and chooses the highest replica recommendation. Therefore, scale-down may wait while CPU or memory still justify the current capacity. The stabilization window (behavior.scaleDown.stabilizationWindowSeconds) considers recent recommendations and helps reduce oscillations when scaling down.

Autoscaling prerequisites

The HPA requires the resource metrics API (metrics.k8s.io) in the cluster (metrics-server. On OpenShift, monitoring) and CPU and memory requests defined for the workers. Without the API, the workers stay at server.workers and the HPA records FailedGetResourceMetric. To turn autoscaling off, use tdp-trino.server.autoscaling.enabled=false.

KEDA must be installed in the cluster. In the Prometheus integration example, the collection of the JMX metrics and the triggers that query them are also configured.

In the Trino chart, the same workers use either the native HPA option or the KEDA option, not both. KEDA manages its own HPA.

Autoscaling with KEDA

KEDA configuration and scaling targets: Trino and Spark.

Separate processing and storage​

Each layer grows at its own pace.

Since Trino and Spark access the data in S3-compatible storage, deployed in its own chart, the workers and the Ozone Datanodes grow independently.

The network and the read and write capacity of the storage are shared by the engines and enter the sizing of the whole.

How the layers are organized

Workload isolation​

Workloads that compete for the same resources can be placed in separate areas and nodes.

Default

One server per user

In JupyterHub, each authenticated user receives their own Pod, with configurable CPU and memory requests and limits.

Configurable

Namespaces

Instances and credentials can be organized by team or purpose. Permissions, quotas and network rules per namespace complete this organization.

Configurable

Dedicated nodes

Node affinity, taints and tolerations, combined, direct components to reserved node groups. Choosing which other workloads can use these nodes is part of the planning.

Separation by namespace is complemented by Kubernetes mechanisms: RBAC for permissions, ResourceQuota and LimitRange for consumption, and NetworkPolicies, enforced by the cluster network plugin (CNI), for traffic between Pods.

Organization of environments by namespace

Scenario: separate ingestion from analytical workloads​

Situation: a company receives order events through Kafka while it runs queries in Trino and batch loads in Spark in the same Kubernetes cluster.

To reduce the competition for CPU and memory between these workloads, the team reserves a group of nodes for the brokers, marked by the cluster administrator with the node-role=kafka label and the dedicated=kafka:NoSchedule taint.

What TDP does: the Kafka chart accepts affinity and tolerations for the brokers.

The affinity takes the brokers to the reserved nodes, and the toleration allows them to be scheduled there:

values.yaml (excerpt)
nodePool:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role
operator: In
values: ["kafka"]
tolerations:
- key: dedicated
operator: Equal
value: kafka
effect: NoSchedule

Effect: the brokers run only on the reserved nodes, and the workloads without the toleration stay off them. The toleration alone allows scheduling on the tainted node, but does not force the Pod to go there: the reservation of the group comes from the combination of the two rules and from controlling which other workloads receive the same toleration.

Using dedicated nodes organizes the CPU and memory capacity. Disk, network and shared storage remain part of the performance assessment.

References for the Kubernetes mechanisms: resources per container, horizontal scaling and isolation between teams.

Platform namespaces

Organization in namespaces. Affinity, tolerations and distribution across nodes in each component: High availability.

Next steps​