Featured Post

How to Check Column Nulls and Replace: Pandas

Here is a post that shows how to count Nulls and replace them with the value you want in the Pandas Dataframe. We have explained the process in two steps - Counting and Replacing the Null values. Count null values (column-wise) in Pandas ## count null values column-wise null_counts = df.isnull(). sum() print(null_counts) ``` Output: ``` Column1    1 Column2    1 Column3    5 dtype: int64 ``` In the above code, we first create a sample Pandas DataFrame `df` with some null values. Then, we use the `isnull()` function to create a DataFrame of the same shape as `df`, where each element is a boolean value indicating whether that element is null or not. Finally, we use the `sum()` function to count the number of null values in each column of the resulting DataFrame. The output shows the count of null values column-wise. to count null values column-wise: ``` df.isnull().sum() ``` ##Code snippet to count null values row-wise: ``` df.isnull().sum(axis=1) ``` In the above code, `df` is the Panda

How to Monitor Kafka-stream's Performance

Kafka Streams API is a part of Kafka, it goes without saying that monitoring your application will require some monitoring of Kafka as well.


The consumer and producer performance is one of the fundamental performance concerns for a producer and consumer.

Stream performance

The Kafka data flow diagram

Kafka data flow diagram

What is lag

For producers, we care mostly about how fast the producer is sending messages to the broker. Obviously, the higher the throughput, the better.

For consumers, we’re also concerned with performance, or how fast we can read messages from a broker.

we care about how much and how fast our producers can publish to a broker, and we simultaneously care about how quickly our consumers can read those messages from the broker. The difference between how fast the producers place records on the broker and when consumers read those messages is called consumer lag

How to check consumer lag

To check for consumer lag, Kafka provides a convenient command-line tool, kafka-consumer-groups.sh, found in the <kafka-install-dir>/bin directory. The script has a few options, but here we’ll focus on the list and describe options. These two options will give you the information you need about consumer group performance.

List command

<kafka-install-dir>/bin/kafka-consumer-groups.sh \ --bootstrap-server localhost:9092 \ --list

Describe command

<kafka-install-dir>/bin/kafka-consumer-groups.sh \ --bootstrap-server localhost:9092 \ --group <GROUP-NAME> \ --describe

How to trace problem

  • A small lag or one that stays constant is OK, but a lag that continues to grow over time is an indication you’ll need to give your consumer more resources. 
  • For example, you might need to increase the partition count and hence increase the number of threads consuming from the topic. Or maybe your processing after reading the message is too heavyweight. After consuming a message, you could hand it off to an async queue, where another thread can pick up the message and do the processing.



Popular posts from this blog

Explained Ideal Structure of Python Class

How to Check Kafka Available Brokers

6 Python file Methods Real Usage