Skip to content

josephangbc/confluent-keda-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

confluent-keda-poc

Description

This repo is to:

  • Demo Keda connection to confluent
  • Demo scaling capabilities of Keda

Set up

Kubernetes

Used Minikube To get endpoint for minikube

minikube service dep --url

Go

touch main.go
// Add in basic server codes
go mod init confluent-keda-poc
go mod tidy

Keda

Reference:

helm repo add kedacore https://kedacore.github.io/charts
helm repo update
kubectl create namespace keda
helm install keda kedacore/keda --namespace keda

Observations

Kafka

  1. Spammed produce endpoint
http://127.0.0.1:56825/api/produce
  1. Confluent Cloud Consumer Lag
  • Keda Consumer Lag Setting: lagThreshold: "50" image.png
  1. Scaling up

    image.png image.png

  2. Scaling down

    image.png

  3. Scaling down to below original replicas of 3

  • Keda Consumer Config: minReplicaCount: 1

    image.png

Kafka Total Lag

  • specified to a scaling target of 100 total consumer lag
  1. Total Kafka consumer lag
  • Note that Specific topic scaling is not set for topic_2. This demo shows that KEDA is triggering based on total Kafka Consumer Lag

    image.png

  1. HPA Trigger Scale Up to 2 replicas
  • The name of the external metrics also points to the trigger for total Kafka Consumer Lag

    image.png

  1. 2 Replicas

    image.png

CPU

  1. Hit 20% Average CPU, Scaling up

    image.png

  • cpu scaler need HPAContainerMetrics feature enabled

Cron

  1. Before Cron scaling

    image.png

  2. After Cron scaling

    image.png

  3. CPU Scaling during Cron scaling period

    image.png

Custom KEDA Codes to exclude Partitions stuck due to error

Custom KEDA Codes

Github Link: https://github.com/JosephABC/keda

Changes are in kafka_scaler.go in getLagForPartition function

Demo

  1. Consumer Lag remain the same due to being stuck

    image.png

  2. Custom KEDA code excludes Consumer Lag for these partitions, hence 0 consumer lag shown in HPA

    image.png

KEDA does not trigger scaling of consumer deployment based on these stuck partitions

Issues to think about

Kafka-scaler

  • Message in a partition encounters error and is unable to be consumed and offset cannot be committed.
  • Partition Key specified for topic. Large consumer lag observed on one/few particular partitions. Scaling out will probably have less effect on performance
  • Metric watched is the total consumer lag for Topic or all topics subcribed by the consumer group

CPU-Scaler

  • containerName parameter requires Kubernetes cluster version 1.20 or higher with HPAContainerMetrics feature enabled.

Others

To Observe and kill process on local

netstat -anop | grep -i 5000
pkill <PID>
kill -9 <PID>

To Deploy KEDA to Cluster

IMAGE_REGISTRY=docker.io IMAGE_REPO=josephangbc make publish
IMAGE_REGISTRY=docker.io IMAGE_REPO=josephangbc make deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published