Skip to content

A demo project for a JAX-RS REST service designed to run on kubernetes. Showcasing spf4j functionality, jax-rs actuator, avro rest, avro logging, avro configuration...

Notifications You must be signed in to change notification settings

zolyfarkas/jaxrs-spf4j-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

jaxrs-spf4j-demo

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:

  1. A stack trace gives you a good/complete picture of what went wrong.

  2. Profiling the monolith presents a complete picture.

  3. Refactoring is a lot easier.

  4. 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:

  1. Distributed stack traces between REST services. Know what is the root cause right away.

  2. DEBUG on ERROR. Debug logs attached to the service error response, of all the services involved!

  3. PROFILE detail on slow requests. (continuous profiling)

  4. Timeout Propagation.

  5. Execution context available everywhere in the JAX_RS context. (Timeout, other baggage...)

  6. JAX-RS Rest client with retry and hedged execution support.

  7. Continuous profiling, with context enrichment see for more detail.

  8. On demand profiling and tracing.

  9. Binary (for efficiency), Json (for humans) support everywhere, CSV for excel wizards.

  10. Deprecation support, clients will be notified when using deprecated endpoints or deprecated objects/attributes via HTTP Warning headers.

  11. Actuator endpoints for logs, health, info, swagger docs, jmx, profiles, metrics. (see)

  12. 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):

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):

About

A demo project for a JAX-RS REST service designed to run on kubernetes. Showcasing spf4j functionality, jax-rs actuator, avro rest, avro logging, avro configuration...

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published