Implementation of a simple HTTP server fibonacci-service
that returns the n-th fibonacci sequence number, serving it as a
GET method at http://localhost:8000/fib?n=<N>
where N
is the n-th number to obtain.
Requests with result are published to a Kafka topic, which is consumed by a java application fibonacci-consumer
.
Create a Dockerfile with Kafka in order to deploy it alongside fibonacci-service
and fibonacci-consumer
to a Kubernetes load balanced cluster.
- Kafka
2.13-3.1.0
is installed at/opt/kafka_2.13-3.1.0
- Java 8 is in the
$PATH
- Start Kafka zookeeper and broker
> cd /opt/kafka_2.13-3.1.0/
> bin/zookeeper-server-start.sh config/zookeeper.properties
> bin/kafka-server-start.sh config/server.properties
- Create kafka topic
> kafka-topics.sh --bootstrap-server localhost:9092 --topic fibonacci_numbers --create --partitions 3 --replication-factor 1
- Build application, assuming the project is cloned ad
$HOME/fibonacci-kafka-kubernetes
:
> cd $HOME/fibonacci-kafka-kubernetes
> ./gradlew build
- Run the
fibonacci-service
> java -jar fibonacci-service/build/libs/fibonacci-service-2.jar
- Run the
fibonacci-consumer
in another console
> java -jar fibonacci-consumer/build/libs/fibonacci-consumer-2.jar
- User the provided never ending script that makes requests to the service.
> ./stress_test.sh localhost:8000 30
Logs showing the computation of the numbers and the consumption of the messages from kafka are shown in the console.
Copyright (c) 2022 Octavio Calleya Garcia.
This project is free software under GNU GPL version 3 license. The license is here LICENSE