Illustration of a warehouse conveyor line moving boxes between storage racks

Optimising Data Engineering Workloads on Kubernetes

kubernetes Nov 27, 2026

Halodoc is a data-driven organisation, and our data platform builds the reports that teams across the company use for decisions every day. Most of our data workloads run as Apache Spark jobs on EMR on EKS, from writing ingested data into our processed zone to building the dimension and fact tables that power analytics. In our previous blogs, we covered how we right-size Spark jobs using historical metrics and how Apache YuniKorn brought application-aware scheduling and bin-packing to our cluster. Both of these focused on the Spark applications and how they are placed on the cluster.

However, the nodes running these applications were not carrying only Spark workloads. They also carried system pods, EMR job submitter pods, DaemonSets and logging sidecars, and the way Karpenter provisioned nodes during our scheduled bursts left many of them partially utilised. Some nodes could not be removed even after the jobs running on them had completed.

This blog covers the five changes that cut our data platform’s compute cost by about 33%.

Background

Most of our data engineering jobs are scheduled through Apache Airflow. Each job runs as a Spark application with one driver and multiple executors, and the resources it needs depend on the data source and the schedule of the job. Since many jobs are scheduled at the same time as part of nightly ETL, a large number of pods are created within a short window, followed by periods of low activity.

Our cluster runs on the following setup:

  • EMR on EKS: Spark applications are submitted as EMR on EKS jobs on ARM64 (Graviton) nodes, with drivers running on on-demand nodes.
  • Apache YuniKorn: Handles application-aware scheduling, with gang scheduling, hierarchical queues and bin-packing based node sorting.
  • Karpenter: Provisions nodes based on pending pods. Consolidation of under-utilised nodes is disabled, so a node is removed only once it becomes completely empty.

With bin-packing enabled, YuniKorn places pods tightly onto the existing nodes. But when we looked at utilisation at the node level, we found that a share of every node's capacity was reserved by pods that were not part of the Spark application, and that many nodes were not becoming empty after their jobs had finished.

Challenges in the Existing Setup

  • Lack of Workload Isolation: System pods were scheduled on the same nodes as Spark workloads. Since these pods run continuously, any node hosting one of them could never become empty, and Karpenter could not remove it.
  • Fragmentation from Job Submitter Pods: Every EMR on EKS job creates a job submitter pod. These pods were placed across the same nodes as drivers and executors, leaving small gaps of capacity that could not be used.
  • Provisioning During Bursts: Karpenter's batch idle duration was set to 1 second, while our scheduled jobs create pods over a window of around 30 seconds. Nodes were being provisioned for small groups of pods instead of the complete burst.
  • Logging Sidecars: Every EMR pod had an EMR fluentd logging sidecar attached to it, adding to the resource requests of every driver and executor, along with the NAT cost of shipping those logs.

Optimisations We Implemented

Separating System Pods into a Dedicated Nodepool

To isolate system workloads, we created a separate nodepool for system pods and moved them out of the nodepools used by Spark workloads. This nodepool runs on two on-demand t4g.medium nodes.

With this change, nodes in the Spark nodepools only host Spark-related pods. Once the jobs on a node complete, the node becomes empty and is removed by Karpenter, instead of being kept alive by a single system pod.

Consolidating EMR Job Submitter Pods

For every job submitted to EMR on EKS, a job submitter pod is created. It is responsible for bringing up the driver and handling the logging of the job. Since drivers run on on-demand nodes, the submitter pods were also being placed across these nodes, taking up capacity meant for drivers and adding to the fragmentation.

We moved all job submitter pods into a dedicated nodepool. Submitter pods are pinned to it with a node selector:

nodeSelector that pins EMR job submitter pods to the job submitter nodepool

We also checked the DaemonSets on these nodes. Their requests were already small, so there was little to reclaim there.

Before: system pods, job submitter pods and Spark pods share the same nodes
Nodepool Layout Before
After: system pods and job submitter pods run in dedicated nodepools
Nodepool Layout After

Organising Workloads with YuniKorn Queues

In our previous blog, we introduced YuniKorn's hierarchical queues to control how resources are shared between workloads. As part of this work, we organised our Spark workloads into queues based on job category, such as dimension jobs, fact jobs and hourly reporting jobs, with a separate queue for the remaining workloads.

Each queue has its own resource boundaries, so a heavy batch of jobs in one category cannot consume the capacity required by the others.

Tuning Karpenter Batch Duration

Karpenter does not provision a node for every pending pod individually. Instead, it collects pending pods into a batch and makes a single provisioning decision for the whole batch. This behaviour is controlled by two settings:

  • batchIdleDuration: The time Karpenter waits for a new pending pod before closing the batch.
  • batchMaxDuration: The maximum time a batch can stay open, even if new pods keep arriving.

Our batch idle duration was set to 1 second. However, our scheduled jobs bring up a large number of pods within around 30 seconds, and these pods do not all arrive at once. With a 1 second idle window, the batch was closing in between pods of the same burst, and Karpenter was provisioning nodes for small groups of pods. This resulted in more nodes being launched, each of them partially utilised.

Karpenter batching of pending pods with a 1 second idle duration versus a longer idle duration
Karpenter Batching During a Scheduled Burst

We raised batchIdleDuration from 1 second to 3 seconds and kept batchMaxDuration at its 10-second default, so Karpenter waits for more of the burst before provisioning.

To choose the value, we collected node creation, pod creation, node deletion and node availability events from our cluster, and used them to simulate Karpenter’s batching at different batchIdleDuration values. 3 seconds was the best fit for our burst pattern. The trade-off is a slight increase in the time it takes for a pod to get a node, which was acceptable for our scheduled batch jobs.

Reducing the Logging Footprint of EMR Pods

Every pod created by EMR on EKS, including drivers and executors, had an EMR fluentd logging sidecar attached to it for shipping logs. Since the sidecar is added to every pod, its resource requests grow with the number of pods, and every executor reserves capacity for logging in addition to the Spark workload itself.

As we were already using a separate observability platform for logging, a lot of this logging was redundant. We disabled executor logging and removed the logging sidecar from executor pods, which make up most EMR pods. The sidecar is still attached to driver pods. With executor logs disabled, less log traffic goes out through the NAT gateway.

Impact and Results

After these changes, the monthly compute cost of our data platform cluster fell by about 33%.

With system pods on their own two-node pool, a Spark node now becomes empty once its jobs finish, and Karpenter removes it instead of keeping it alive for a single system pod. Submitter pods no longer take space on driver nodes. Executors, which make up most EMR pods, no longer reserve capacity for a logging sidecar, so more of each node goes to Spark.

On the provisioning side, the longer batch window lets Karpenter size nodes for a larger part of each scheduled burst rather than for a few pods at a time.

The cost reduction reflects the combined impact rather than any single change.

Lessons Learned

Looking Beyond the Spark Application: Right-sizing and bin-packing only optimise the Spark pods. Pods outside the application, such as system pods and sidecars, can take up a significant share of node capacity and are easy to overlook.

Isolating Long-Running Pods: When nodes are removed only once they are empty, a single long-running pod is enough to keep a node alive. Keeping such pods on their own nodepool allows the Spark nodepools to scale down once their jobs complete.

Tuning Defaults Based on Workload Pattern: Karpenter's defaults work well when pods arrive steadily. Scheduled batch workloads arrive in bursts and benefit from a longer batching window.

Conclusion

The optimisations described in this blog show that the cost of a Spark platform is determined not only by the Spark applications, but also by the workloads that run alongside them. In our case, system pods, EMR job submitter pods and logging sidecars, together with Karpenter’s provisioning behaviour during scheduled bursts, accounted for a significant share of our compute cost.

References

Join us

Scalability, reliability, and maintainability are the three pillars that govern what we build at Halodoc Tech. We are actively looking for engineers at all levels, and if solving hard problems with challenging requirements is your forte, please reach out to us with your resume at careers.india@halodoc.com.

About Halodoc

Halodoc is the number one all-around healthcare application in Indonesia. Our mission is to simplify and deliver quality healthcare across Indonesia, from Sabang to Merauke. Since 2016, Halodoc has been improving health literacy in Indonesia by providing user-friendly healthcare communication, education, and information (KIE). In parallel, our ecosystem has expanded to offer a range of services that facilitate convenient access to healthcare, starting with Homecare by Halodoc as a preventive care feature that allows users to conduct health tests privately and securely from the comfort of their homes; My Insurance, which allows users to access the benefits of cashless outpatient services in a more seamless way; Chat with Doctor, which allows users to consult with over 20,000 licensed physicians via chat, video or voice call; and Health Store features that allow users to purchase medicines, supplements and various health products from our network of over 4,900 trusted partner pharmacies. To deliver holistic health solutions in a fully digital way, Halodoc offers Digital Clinic services including Haloskin, a trusted dermatology care platform guided by experienced dermatologists. We are proud to be trusted by global and regional investors, including the Bill & Melinda Gates Foundation, Singtel, UOB Ventures, Allianz, GoJek, Astra, Temasek, and many more. With over USD 100 million raised to date, including our recent Series D, our team is committed to building the best personalized healthcare solutions — and we remain steadfast in our journey to simplify healthcare for all Indonesians.

Tags

Bhargav M Gowda

Data/AI Engineer @HaloDoc