Posts

The Lifecycle of a Thread in Java: Exploring Creation, Execution, and Termination

  Introduction Threads are an essential part of concurrent programming in Java, enabling the execution of multiple tasks concurrently. Understanding the lifecycle of a thread is crucial for effective thread management and synchronization. In this blog post, we will explore the lifecycle of a thread in Java, from its creation to execution and eventual termination. Through code examples, we will demonstrate the various stages and methods associated with thread management in Java. Thread Creation A thread in Java can be created by extending the `Thread` class or implementing the `Runnable` interface. Let's consider an example where we create a thread by extending the `Thread` class: public class MyThread extends Thread {     public void run() {         // Code to be executed by the thread     } } Thread Initialization Once a thread class is defined, an instance of the class is created. This is done by in...

How to scale down a Pinot cluster without downtime on Kubernetes?

Image
  I have been using Apache pinot lately for an analytics project at my company for a bit now. We deployed it on Kubernetes and on the test environment, the infra that was setup was too large for the traffic we had. So, I had to learn how to downsize a pinot cluster that has data on it, without affecting the application or losing the data. So, the way we do that is by rebalancing the servers on which the tables are hosted. Below are the steps I did manually in order to scale down the k8s cluster.  Some context about my setup - Kubernetes cluster with 5 pinot servers. The pods were named as pinot-server-0 till pinot-server-4. - 1 table which had 10 segments distributed across the 5 servers. My target - Downsize the number of pinot-servers from 5 to 4. Steps: 1. First step is to make sure this setting is `pinot.set.instance.id.to.hostname=true` enabled on the cluster. 2. Since we are running on K8s, the cluster names are starting from pinot-server-0 to pinot-server-4. When we dow...