A demo project for a JAX-RS REST service showcasing Avro REST SQL, spf4j profiling, logging, etc... functionality in a SOA (aka micro-services) environment.
This is right now work in progress, need to be brave to try it out :-)
A recent version you can test on GKE at
Some time ago I stumbled upon the statement: "We replaced our monolith with micro services so that every outage could be more like a murder mystery" It did make me laugh, mostly because it is part joke, and part reality.
To clarify my view on this, let me define monolith: a single OS process doing a lot of things. Usually it comes a time when things get too big (applies to a lot of things in CS), and a bit of divide and conquer is needed to break things down into more manageable pieces. In this case a single process will result in a group of processes that communicate with each other via some form on IPC.
A reminder of some of the advantages we will give away when breaking down our monolith:
-
A stack trace gives you a good/complete picture of what went wrong.
-
Profiling the monolith presents a complete picture.
-
Refactoring is a lot easier.
-
Method calls within the process boundary are fast! and reliable (no network issues, etc).
...
This example shows how you can overcome some of the challenges you will face in a distributed architecture:
-
Distributed stack traces between REST services. Know what is the root cause right away.
-
DEBUG on ERROR. Debug logs attached to the service error response, of all the services involved!
-
PROFILE detail on slow requests. (continuous profiling)
-
Timeout Propagation.
-
Execution context available everywhere in the JAX_RS context. (Timeout, other baggage...)
-
JAX-RS Rest client with retry and hedged execution support.
-
Continuous profiling, with context enrichment see for more detail.
-
On demand profiling and tracing.
-
Binary (for efficiency), Json (for humans) support everywhere, CSV for excel wizards.
-
Deprecation support, clients will be notified when using deprecated endpoints or deprecated objects/attributes via HTTP Warning headers.
-
Actuator endpoints for logs, health, info, swagger docs, jmx, profiles, metrics. (see)
-
Serialization compatible DTO schema evolution (see, and see).
See the wiki for more detailed descriptions of the concepts implemented here
This demo is built and published to docker-hub, you can run this service by (install docker):
$ docker pull zolyfarkas/jaxrs-spf4j-demo:1.0.3
$ docker run -p 8080:8080 zolyfarkas/jaxrs-spf4j-demo:1.0.3
open in your browser (use http and port 8080 if you run it locally):
- Hello
- Json avro response
- Binary avro response
- Error response
- Simulate slow request
- See simulated slow request profile
if more adventurous you can try this in kubernetes:
Install kind from
# install kubectl (using mac ports https://www.macports.org)
sudo port install kubectl-1.15
#switch between kubectl versions.
sudo port select --set kubectl kubectl1.15
#create local kubernetes cluster
kind create cluster --config cluster-3n.yml
#install octant(https://github.com/vmware-tanzu/octant) to look at your cluster. (awesome tool for beginners) (need https://brew.sh)
brew install octant
#deploy the app
kubectl create -f ./src/main/kube/kube-rbac.yaml
kubectl create -f ./src/main/kube/kube-config-map.yaml
kubectl create -f ./src/main/kube/kube-deployment.yaml
kubectl create -f ./src/main/kube/kube-service.yaml
kubectl port-forward deployment/jaxrs-spf4j-demo 8080:8080
now you can access the app via localhost:8080.
And try out additionally some cluster endpoints in your browser (use http and localhost8080 for the local app):