We believe in Trust, Quality, Responsblility and Teamwork

Read in 1 min

This is how we do it

News /

Java & Spring for modern containerized microservices in the backend

If you start to think about building modern middleware there are a lot of decisions that you need to take from the first moment.

Starting from the architecture if you feel that you need to go with microservices to be ready for containerization / clouds / horizontal scaling then you immediately wonder how to organize communication or manage transactions in such distributed environment or what kind of API expose (Restful / GraphQL / gRPC) and how to protect it.
The next important decision is a technology stack to use which will allow you to focus maximally on the business domain and not on implementing repetitive elements required from modern platforms.

In TWG we like to build backends based on Java & Spring with Full Reactive Stack including:

  1. Web reactive – Spring WebFlux
  2. MongoDB reactive driver
  3. Reactor

Additional in such distributed setup we are usually introducing:

  1. Distributed, correlated logs and tracing – Micrometer Tracing (former Spring-Sleuth), combined with Zipkin or Jaeger.
  2. Integration with many different logging systems: LOKI, AWS Cloud Watch, ELK Stack.
  3. Metrics exposure and monitoringprometheus

• for basic statistics (uptime, start time, JVM statistics – memory, JVM statistics – GC)
• for REST API (inbound / outbound HTTP requests)
• for Spring data repositories (MongoDB) & mongoDB driver commands
Consumed by: PrometheusVictoria Metrics or Datadog
Grafana as visualization and analytics solution

  • Sophisticated security supporting oAuth2 / OpenID Connect often combined with keycloak as oAuth server (to not build by our own AAA and user management and use proven, easily extendable solution in java which is additional benefit as complete backend can be Done in a single language)
  • Support for event driven systems / Spring AMQP and Spring for Apache Kafka
  • Support for externalized configuration with Spring Cloud config  and different backends as configuration storage (git, vault etc)
  • Support for GraphQL as yet another presentation layer
  • API Gateways, to expose solid API and hide internal distributed infrastructure, with standard gateways capabilities like: rate limiting, circuit breaker etc, based on spring components or kubernetes ingress controllers like Traefik
  • Automatic REST API documentation generation in OpenAPI Standard – Swagger Specification successor openapis.orgspringdoc.org
  • Easy containerization thanks intelligent spring-boot concept and big players involvements, providing hardened base images like Amazon Corretto

Pros

  1. Production-grade, scalable and reliable distributed platforms build in a very fast way
  2. Happy developers doing great things 🙂

Cons

Complicated ecosystem

Statement

Have you already practiced a similar approach?