An example of two microservice architectures: a synchronous, coupled request/response approach and an asynchronous, less-coupled event-driven approach.
For more:
- π Read the corresponding blog post/talk for more detail on why/how this exists
- πΊ Watch the video walkthrough of this demo to see how it works
- Tools needed to run this whole thing
- Bazelisk for the Go backend
- Minikube setup for the events broker
- Frontend tools for the webapp
- How to build and run
- Clean up and destroy everything
Set up bazelisk
:
brew tap bazelbuild/tap
brew install bazelisk
Verify that bazel
points to bazelisk
:
$ which bazel
/usr/local/bin/bazel
melinda at mmbp in ~/events on ml-add-bazel*
$ ls -l /usr/local/bin/bazel
lrwxr-xr-x 1 melinda admin 34 May 11 11:33 /usr/local/bin/bazel -> ../Cellar/bazelisk/1.6.1/bin/bazel
Install minikube, make Hyperkit the default driver, and give it more than the default amount of RAM:
brew install minikube
minikube config set driver hyperkit
minikube config set memory 2048 # 2 GB
To start minikube:
minikube start
To stop minikube:
minikube stop
Install Yarn and Node if you don't have them.
Then install the dependencies for the frontend app:
# from the js/ directory
yarn install
This deploys a clean version (nothing specific to this demo) of Kafka and Zookeeper to Kubernetes.
kubectl apply -f deployments/kafka.yaml
kubectl exec -it kafka-0 -- bash
# from kafka/local/topics.sh
/opt/kafka/bin/kafka-topics.sh --create --partitions 2 --replication-factor 1 --zookeeper zookeeper:2181 --topic order.order
bazel run //go/services/order-sync:api
bazel run //go/services/payment:api
bazel run //go/services/delivery:api
bazel run //go/services/order-async:api
bazel run //go/workers/payment:worker
bazel run //go/workers/delivery:worker
To build the breakfast-webapp
app:
# from the js/ directory
yarn build
To actually serve the breakfast-webapp
app (won't work unless you build first):
# from the js/ directory
yarn start
minikube delete