Large-scale applications often process millions of events per second (e.g., IoT systems, log processing pipelines, or financial transaction monitors). Traditional monolithic architectures struggle to meet these demands due to scalability bottlenecks and cost inefficiencies.
- High Throughput Event Processing: Kafka acts as the central message broker, decoupling producers and consumers for asynchronous, high-speed communication.
- Dynamic Auto-Scaling: Kubernetes manages containerized services and can auto-scale based on resource usage or queue depth.
- Cost-Efficient Serverless Execution: Modular microservices allow fine-grained resource allocation, reducing overhead and enabling possible migration to FaaS platforms (like OCI Functions).
- Low-Latency Responses: Services communicate over lightweight REST endpoints, and Kafka ensures real-time event delivery with minimal delay.
This system is designed with scalability, modularity, and performance in mind—ideal for event-driven architectures operating at scale.
- Google Cloud Load Balancer / Ingress exposes the producer API securely.
- GKE (Google Kubernetes Engine) runs all microservices (producer, consumer, alerting).
- Apache Kafka runs on GKE (or optionally Google Pub/Sub as a managed alternative).
- Alerting is handled by a dedicated microservice (or can be migrated to Cloud Functions).
- Cloud SQL (PostgreSQL) stores persistent event data.
- Google Cloud Logging & Monitoring provide observability across services.
The system is designed as a cloud-native, event-driven architecture and can be deployed both locally and on Google Cloud Platform (GCP).
Due to resource and cost constraints, the primary implementation and testing were performed locally using Docker and Kubernetes. However, the architecture is fully compatible with GCP services and can be deployed with minimal changes.
| Local Component | GCP Equivalent |
|---|---|
| Kafka (Docker) | Kafka on GKE / Google Pub/Sub |
| PostgreSQL (Docker) | Cloud SQL (PostgreSQL) |
| Kubernetes (local) | GKE (Google Kubernetes Engine) |
| Docker Images | Artifact Registry |
| Port Forwarding | LoadBalancer / Ingress |
The current system simulates the cloud architecture using local tools:
| Component | Technology Used |
|---|---|
| Producer Service | Java Spring Boot + KafkaTemplate |
| Kafka Broker | Dockerized Apache Kafka |
| Consumer Service | Java Spring Boot + KafkaListener |
| Alerting Service | Java Spring Boot (simulates real-time alerting) |
| Database | PostgreSQL (Docker) |
| Monitoring & Logs | STDOUT logs |
| Kubernetes | Local cluster / Minikube |
- Kafka runs locally instead of managed Pub/Sub
- Alerting runs as a microservice instead of serverless function
- Kubernetes runs locally instead of GKE
- APIs are tested using curl/Postman instead of external load balancers
The same architecture can be deployed on GCP using:
- GKE for container orchestration
- Artifact Registry for Docker images
- Cloud SQL (PostgreSQL) for persistent storage
- LoadBalancer / Ingress for external access
- Optional: Pub/Sub as a managed Kafka alternative
Refer to k8s/gcp/ for deployment scripts.
VCC-EVENT-PROCESSING-SYSTEM/
├── alerting-service/
├── consumer-service/
├── producer-service/
├── diagram/
├── k8s/
│ ├── hpa/
│ │ ├── producer-hpa.yaml
│ │ ├── consumer-hpa.yaml
│ │ └── alerting-hpa.yaml
│ ├── gcp/ # NEW FOLDER
│ │ ├── deploy-gcp.sh # GCP deploy script
│ │ ├── producer-deployment.yaml # updated with Artifact Registry image
│ │ ├── consumer-deployment.yaml # updated with Cloud SQL proxy
│ │ ├── alerting-deployment.yaml # updated with Artifact Registry image
│ │ └── producer-service.yaml # LoadBalancer instead of ClusterIP
│ ├── alerting-deployment.yaml # original local
│ ├── consumer-deployment.yaml # original local
│ ├── kafka-deployment.yaml # original local
│ ├── postgres-deployment.yaml # original local
│ ├── producer-deployment.yaml # original local
│ ├── producer-ingress.yaml
│ ├── zookeeper-deployment.yaml
│ └── deploy-all.sh # original local script
├── performance.sh
├── run-all.sh
└── README.md
Make sure the following tools are installed:
- Docker
- Kubernetes
- Maven
- Java 17+
- Curl
git clone <repository-url>
cd event-processingRun the following inside each microservice directory:
cd producer-service
mvn clean install
docker build -t producer-service:latest .
cd ../consumer-service
mvn clean install -Dspring.profiles.active=test
docker build -t consumer-service:latest .
cd ../alerting-service
mvn clean install
docker build -t alerting-service:latest .-
Clone the repository containing the deployment scripts.
-
Navigate to the root directory containing
run-all.sh. -
Make the script executable:
chmod +x run-all.sh
-
Run the deployment script:
./run-all.sh
The script performs the following actions:
- Cleans up any existing containers
- Creates a shared Docker network
- Deploys Zookeeper and waits for it to become available
- Deploys Kafka and waits for it to become available
- Deploys PostgreSQL
- Builds Docker images for the Producer, Consumer, and Alerting services
- Deploys all three services
- Provides a command to test the system
-
Container Startup Failure
-
Check logs for the failing container:
docker logs <container-name>
-
Ensure there is sufficient system memory and disk space.
-
-
Network Connectivity Issues
-
Verify the network was created:
docker network ls | grep event-net -
Inspect network details:
docker network inspect event-net
-
-
Zookeeper Issues
-
Check Zookeeper logs:
docker logs zookeeper
-
Verify port accessibility:
nc -zv localhost 2181
-
-
Kafka Issues
-
Check Kafka logs:
docker logs kafka
-
Verify Kafka can reach Zookeeper:
docker exec kafka ping zookeeper -
Check broker status:
docker exec -it kafka kafka-topics.sh --bootstrap-server localhost:9092 --list
-
-
PostgreSQL Issues
-
Check PostgreSQL logs:
docker logs postgres
-
Test database connection:
docker exec -it postgres psql -U postgres -d eventdb -c "SELECT 1"
-
-
Service Container Issues
-
Check service logs:
docker logs producer-service docker logs consumer-service docker logs alerting-service
-
Verify connections to Kafka:
docker exec producer-service curl -v telnet://kafka:9092
-
-
Image Build Failures
-
Manually attempt to build the images:
cd producer-service && docker build -t producer-service:latest .
-
Check for Docker build errors in the console output.
-
From the root directory:
cd k8s
chmod +x deploy-all.sh
./deploy-all.shThe script performs the following actions:
- Creates a namespace called
event-systemif it doesn't exist - Cleans up any existing deployments
- Deploys Zookeeper and waits for it to be ready
- Deploys Kafka and PostgreSQL
- Deploys the Producer, Consumer, and Alerting services
- Applies Horizontal Pod Autoscaler (HPA) configurations for automatic scaling
- Sets up port forwarding for local testing
kubectl get pods
kubectl logs <pod-name>You should see logs from the services interacting with Kafka.
-
Namespace Issues
-
Verify the namespace exists:
kubectl get namespace event-system
-
Check namespace status:
kubectl describe namespace event-system
-
-
Resource Status
-
Check the status of all pods:
kubectl get pods -n event-system
-
View detailed information about a specific pod:
kubectl describe pod <pod-name> -n event-system
-
-
Pod Crash or Startup Failures
-
Check pod logs:
kubectl logs <pod-name> -n event-system
-
Check events for a pod:
kubectl describe pod <pod-name> -n event-system | grep -A 10 Events
-
-
Zookeeper Issues
-
Check Zookeeper pod status:
kubectl get pods -l app=zookeeper -n event-system
-
Check Zookeeper logs:
kubectl logs -l app=zookeeper -n event-system
-
-
Kafka Issues
-
Check Kafka pod status:
kubectl get pods -l app=kafka -n event-system
-
Check Kafka logs:
kubectl logs -l app=kafka -n event-system
-
Verify Kafka can reach Zookeeper:
kubectl exec -it $(kubectl get pod -l app=kafka -n event-system -o jsonpath='{.items[0].metadata.name}') -n event-system -- ping zookeeper-service
-
-
PostgreSQL Issues
-
Check PostgreSQL pod status:
kubectl get pods -l app=postgres -n event-system
-
Check database service:
kubectl get svc postgres-service -n event-system
-
Test database connection:
kubectl exec -it $(kubectl get pod -l app=postgres -n event-system -o jsonpath='{.items[0].metadata.name}') -n event-system -- psql -U postgres -d eventdb -c "SELECT 1"
-
-
Service Pod Issues
-
Check service pods status:
kubectl get pods -l app=producer-service -n event-system kubectl get pods -l app=consumer-service -n event-system kubectl get pods -l app=alerting-service -n event-system
-
Check service logs:
kubectl logs -l app=producer-service -n event-system kubectl logs -l app=consumer-service -n event-system kubectl logs -l app=alerting-service -n event-system
-
-
Service Connectivity
-
Check service endpoints:
kubectl get endpoints -n event-system
-
-
HPA Issues
-
Check HPA status:
kubectl get hpa -n event-system
-
Check detailed HPA information:
kubectl describe hpa producer-hpa -n event-system
-
Verify metrics are being collected:
kubectl top pods -n event-system
-
-
Port Forwarding Issues
-
Verify service exists:
kubectl get svc producer-service -n event-system
-
Try alternative port forwarding:
kubectl port-forward deployment/producer-deployment 8080:8080 -n event-system
-
- ProducerService: Publishes user-defined events to a Kafka topic.
- ConsumerService: Listens to the Kafka topic and processes the events.
- AlertingService: Triggers alerts based on event type/threshold.
Below are the key GCP CLI commands required to deploy this system on Google Cloud.
gcloud auth login
gcloud projects create event-processing-system
gcloud config set project event-processing-systemWhat it does:
- Logs into GCP
- Creates a new project
- Sets it as the active project
gcloud services enable container.googleapis.com \
artifactregistry.googleapis.com \
sqladmin.googleapis.com \
cloudbuild.googleapis.comWhat it does:
- Enables GKE (Kubernetes)
- Enables Artifact Registry (Docker images)
- Enables Cloud SQL (database)
- Enables Cloud Build (optional builds)
gcloud artifacts repositories create event-processing-system \
--repository-format=docker \
--location=us-central1What it does:
- Creates a private Docker image repository on GCP
docker build -t <REGION>-docker.pkg.dev/<PROJECT_ID>/event-processing-system/producer-service .
docker push <REGION>-docker.pkg.dev/<PROJECT_ID>/event-processing-system/producer-serviceWhat it does:
- Builds Docker image
- Uploads it to GCP Artifact Registry
gcloud container clusters create event-processing-system-cluster \
--zone=us-central1-a \
--num-nodes=2What it does:
- Creates a Kubernetes cluster on GCP
gcloud container clusters get-credentials event-processing-system-cluster \
--zone=us-central1-a
kubectl get nodesWhat it does:
- Connects your local machine to GKE
- Verifies cluster is running
gcloud sql instances create event-db \
--database-version=POSTGRES_14 \
--tier=db-f1-micro \
--region=us-central1What it does:
- Creates managed PostgreSQL database on GCP
cd k8s/gcp
./deploy-gcp.shWhat it does:
- Deploys all services to GKE using Kubernetes manifests
kubectl get pods -n event-system
kubectl get svc -n event-systemWhat it does:
- Checks if services are running correctly
Use Postman or CURL to send test events to the /publish endpoint of the producer service (usually exposed via a NodePort or Ingress).
Example:
curl -X POST http://<node-id>:<nodeport>/publish -H "Content-Type: application/json" -d -d '{"type":"TEMP","value":"ALERT:90"}'Expected:
-
consumer-servicelogs the event to DBkubectl exec -it $(kubectl get pod -l app=postgres -n event-system -o jsonpath='{.items[0].metadata.name}') -n event-system -- psql -U postgres -d eventdb -c "SELECT * FROM EVENTS"
-
alerting-serviceprints alert to consolekubectl logs -l app=alerting-service -n event-system
- This system simulates a cloud-native event-driven architecture using local infrastructure.
- The architecture is fully compatible with GCP services such as GKE, Cloud SQL, and Artifact Registry.
- Kafka setup uses Dockerized Confluent/Bitnami images.
- Recommended for development and testing environments.




