The problem
Most tutorials stop when the service answers a request. What goes wrong later is different: a rollout that drops requests, a container killed for memory the app never reported, a consumer group that quietly falls behind. I built a small Spring Boot service and took it through build, container, deploy, pipeline and streaming, and ran an experiment at each stage.
The path
- Build. A Spring Boot app with a
/helloendpoint and Actuator health checks, built with Maven. - Containerise. A two-stage Dockerfile: Maven and the full JDK build the JAR, and only the JAR is copied into a JRE-only image. The final image is about 138 MB, runs as a non-root user, and caches dependencies so code changes do not trigger a full re-download.
- Deploy. A Helm chart on a local kind cluster with rolling updates, three probes and graceful shutdown.
- Automate. A GitHub Actions pipeline that builds, tests, checks the chart and publishes the image.
- Stream. A Kafka lab on keys, partitions, consumer groups and lag.
Experiment 1: memory limits
I ran the same image in a 256 MB container with two heap settings.
| Heap setting | Result |
|---|---|
Fixed -Xmx512m (bigger than the container) | OOMKilled=true, exit code 137, and no OutOfMemoryError in the app logs. The container was killed from outside. |
-XX:MaxRAMPercentage=75 | Ran normally and answered requests. |
Nothing in the application logs pointed at memory. The only clue was the container status. That is why the heap is set as a percentage of the container limit: it scales with the limit and leaves room for non-heap memory.
Experiment 2: zero-downtime rollouts
A client called the service five times a second while I rolled out a new version. I ran it twice with the same code, changing only whether the chart's safe-rollout settings were on.
| Chart setting | Requests | Failed |
|---|---|---|
| Probes and preStop on | 289 | 0 |
| Probes and preStop off | 114 | 18 (about 1 in 6) |
Without the probes, traffic reached pods before Java had finished starting, and old pods stopped while requests were still arriving. The safe version combines these settings:
maxSurge: 1andmaxUnavailable: 0, so a new pod must be ready before an old one is removed.- Startup, readiness and liveness probes, all pointed at Spring Boot Actuator. The startup probe gives Java time to start before other checks begin.
- A 10-second
preStoppause so the load balancer stops sending traffic before the pod shuts down, and Spring Boot finishes requests already in progress. helm upgrade --install --atomic, which rolls back automatically if the new version never becomes ready.
The pipeline
Every push and pull request builds the app, runs the tests, and checks the Helm chart with helm lint and helm template (lint only checks structure, so the template step matters). Only pushes to main publish an image, tagged with the commit ID and latest, so untested code never reaches the registry. The pipeline gets the smallest permissions it needs, caches Maven libraries between runs, and cancels older runs when a newer push arrives.
Moving to Amazon ECR instead of GitHub's registry is a sign-in change: an IAM role trusted through OIDC for the repository and branch, with no stored keys. The build, test and tagging steps stay the same.
Experiment 3: Kafka partitions and lag
A trades topic with 3 partitions, using the bond ID as the message key so every trade for one bond stays in order.
| Test | Result |
|---|---|
300 trades sent while the risk group was not reading | risk lag grew to 300 while reporting stayed at 0. Each group keeps its own offsets. |
risk started reading again | Lag returned to 0, continuing from its last offset with nothing missed or read twice. |
| 4 consumers in one group, 3 partitions | One consumer was assigned 0 partitions. Partitions set the maximum parallelism. |
| 3 bond keys | All three hashed to partition 0, so one partition took all the traffic. |
| 12 bond keys, 120 trades | Spread 70 / 20 / 30 across the partitions. Better, but still uneven. |
With few keys, or a few very busy ones, one partition can take most of the load. Lag should be watched per partition, not only in total.
What this does not cover
This runs on a local kind cluster, not a managed one, and the Kafka lab uses a single broker. For production I would use a replication factor of 3, min.insync.replicas=2 and acks=all, so a broker can fail without losing data. Every result above is written up in the repository with the commands to reproduce it.