This document provides an overview of developing and deploying microservices using Spring Cloud at a financial institution. It discusses the challenges of monolithic applications and how microservices address scalability and modularity. The development process includes tools for source control, builds, testing, and code quality. Deployment utilizes a PaaS for consistent environments. Operations are supported by a dashboard for monitoring services and centralized logging/auditing. Overall microservices require addressing technical challenges of distributed systems within an enterprise environment.
2. Preface
Team
Spring I/O
2016
Toni Jara
Software engineer with more than 10 years of experience
involved in complex architecture projects as Technical Team
Lead and Senior Architect.
With more than 8 years of experience working with Spring
(mainly Core Framework, MVC and Webflow), lately he’s
been working on microservices architectures with Spring
Cloud.
Jordi Gil
Jordi is a Software Architect with over 18 years of experience
in application development, mainly in information systems for
banking and insurance industries. He focuses on the definition
of architectures for heterogeneous environments and with high
performance, interoperability and availability requirements.
In everis he is leading the innovation group where new
technologies, patterns and architecture models are assessed
for applicability in final customers.
Currently his main areas of interest are MicroServices
Architectures and Cloud PaaS platforms.
6. Introduction
Monolithic applications
Spring I/O
2016
• Easy to Develop & Deploy & Scale
• Can Be Intimidating to New
Developers
• Modularity Dependent Upon
Language / Frameworks
• Change Cycles Tightly Coupled /
Obstacle to Frequent Deploys
• Inefficient Scaling
• Obstacle to Scaling Development
• Requires Long-Term Commitment to
Technical Stack
HTML JavaScript MVC
Service Service
Data Access
Browser
Relational
Database
Monolithic Application
7. Introduction
Monolithic applications 2.0
Spring I/O
2016
• SOA approach
• ESBs used to integrate monolithic
applications
• ESB Tightly Couples Services
• Centralized governance models that
actively inhibit change
• ESB becomes the biggest monolith
Service Service
SOA - ESB
Service Service Service
Service Service
8. Introduction
Microservices architecture
Spring I/O
2016
• Modularity Based on Component
Services
• Change Cycles Decoupled / Enable
Frequent Deploys
• Efficient Scaling
• Individual Components Less
Intimidating to New Developers
• Enables Scaling of Development
• Eliminates Long-Term Commitment
to Technical Stack
• Complexity associated to distributed
systems
• Operational burden
API
Service
Storage
Microservice 1
API
Service
Storage
Microservice 2
API
Service
Storage
Microservice 3
API
Service
Storage
Microservice 4
9. Introduction
Microservices in a bank
Spring I/O
2016
• API Gateway as the single entry
point for all clients
• Critical core business services
managed through SOA model
• Backends accessed exclusively
through Business Services
API Gateway
Front App Front App
Mainframe
Business Service Business Service
Backends
Business Services - SOA
Microservices
10. Introduction
Challenges
Spring I/O
2016
Discovery /
Reuse
Scope definition
Productivity
Homogenization
Versioning
Integration
Messaging
formats
Error
management
Testing
Distributed
tracing
Service
Discovery
Load Balancing
Fault Tolerance
Centralized
Configuration
Dynamic
Routing
API Gateway
Technical
challenges
derived from
implementing
distributed
systems
Challenges
derived from
enterprise
environment
Spring Cloud
Procedures &
custom
components
Enterprise-ready
framework
11. Introduction
Technical model
Spring I/O
2016
Operation
SpringCloud
Infrastructure services
SpringCloud
Service Registry
Eureka
Server
Configuration
Config
Server
Git
Service execution framework
SpringCloud
SpringBoot
Service
Discovery
Eureka
Client
Fault Tolerance /
Resilience
Hyxtrix
Load Balancer
Feign
Security
Spring Cloud
Security
Embedded
servlet container
Tomcat, Jetty,
Undertow
Monitoring &
Management
Actuator
Endpoints
IPC – Inter Process Communication
Runtime
Gateway
Zuul
Monitoring
Dashboard
Hystrix +
Turbine
Log
Management
Central logging
Microservices SOA
Integration
Database
Core
Messages Error mgmt Config
Audit &
Log
HTTP
cache
15. Development
Design
Spring I/O
2016
• Key aspect for building a successful microservices architecture.
• No Silver Bullet, but some techniques may help…
Business
Area
Business
Domain
Service
Domain
Existing reference architectures in some industries
– Banking – BIAN (Banking Industry Architecture
Network)
– Insurance - Acord
Functional decomposition based on Verbs (e.g. Checkout) or Nouns (e.g. Product) of
your application RESTful APIs
Domain Driven Design divides a complex domain up
into multiple bounded contexts and maps out the
relationships between them.
Discovery Design Build QA Deployment Operations
16. Development
Build tools
Spring I/O
2016
IDE
Source code
management
GIT / SVN
Lifecycle
automations
Apache
Maven
Testing
Unit testing
Code
Coverage
Code quality
Findbugs PMD Checkstyle SonarQube
To increase productivity, it’s very important to define a standard tool set.
Find the essential tools and plugins hierarchy below:
Discovery Design Build QA Deployment Operations
17. Development
Source code management tools
Spring I/O
2016
Discovery Design Build QA Deployment Operations
Source code management with Atlassian Bitbucket
(GIT):
• One project for each team
• One repository for each Microservice
• Collaborative development and revisions with pull
requests & merges (Gitflow)
Master
Official version
Hotfix
Official fixings
Develop
Integration
Feature
Functionality
Release
Candidate version
Gitflow documentation: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
18. Development
Maven archetype
Spring I/O
2016
Maven
archetype
Java sources
& tests
Maven
Dependencies
Config files
Basic project
structure
Naming
conventions
• Internal and
external core
dependencies
Starter
parent
(POM)
• Spring Data
support
• JAX-WS
access to SOA
Business layer
Integrations
(JAR)
Discovery Design Build QA Deployment Operations
19. Development
Versioning
Spring I/O
2016
Modification type
New
Major
New
Minor
New
Fix
New
Qualifier
No interface modification NO NO YES YES
Interface modification and backwards compatible NO YES YES YES
Interface modification not backwards compatible YES YES YES YES
Pain point: synchronize Maven (pom.xml) and Spring Cloud version (FeignClient)
Manual Automatic
MAJOR.MINOR.FIX-QUALIFIER
Discovery Design Build QA Deployment Operations
20. Development
Messaging
Spring I/O
2016
HTTP / JSON
Automatic actions in microservices execution:
Pre-
execution
Execution
Post-
execution
Headers
Body
Messages
HTTP headers
or payload
Functional
message
Header name Message
HEADER.TRACKING_ID Request /
Response
HEADER.* Request
HEADER.STATUS Response
EXCEPTION Response (error)
+ Code
+ Type
+ Severity
+ Description
+ Cause
Discovery Design Build QA Deployment Operations
21. Development
Integrations
Spring I/O
2016
Discovery Design Build QA Deployment Operations
Development:
1. [MS/SOA] Client JAR (Feign/JAX-WS)
uploaded to Artifactory
2. Consumer adds Maven
dependencies:
• [MS/SOA] Client JAR
• [DB] JDBC driver
3. [DB] Implement Spring Data domain
and repository classes
4. Implement integration logic
• [MS/SOA] @Autowire client
class
• [DB] @Autowire Spring Data
repository
[MS/SOA] Execution:
1. On-the-fly configurations
2. Propagate architecture headers
Client JAR
upload
Add Maven
dependencies
Data model
Integration
logic
22. Development
Performance enhancements
Spring I/O
2016
Discovery Design Build QA Deployment Operations
HTTP 1.1 caching RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
Spring MVC Cache Control: https://github.com/foo4u/spring-mvc-cache-control
• HTTP 1.1 Caching RFC 2616 compatible with
all web browsers
• Cache Control and ETag HTTP header support
HTTP cache
• Partial requests: optional input parameters
• Partial responses: query params “fields” and
“fieldsExcluded” to filter output messages
Partial resources
• GZip compression in Spring Boot and Feign
GZip
compression
23. Development
Unit & integrated testing
Spring I/O
2016
Discovery Design Build QA Deployment Operations
Continuous Integration
Integrated
testing
Unit testing
Testing
frameworks
Granularity: for each class
Naming convention: *Test.java
Approach: TDD
Mock: external class
dependencies
Granularity: for each Microservice
Naming convention: *IT.java
Approach: BDD
Mock: Microservice external
systems
24. Development
Source code quality
Spring I/O
2016
Discovery Design Build QA Deployment Operations
• IDE plugins:
Findbugs,
Checkstyle, PMD,
Code Coverage
and SonarQube
plugins
Development
• Maven plugins:
SonarQube (quality
reports), Surefire
(unit testing) and
Jacoco (Code
Coverage)
Build
27. Deployment
Infrastructure (I)
Spring I/O
2016
Discovery Design Build QA Deployment Operations
• PaaS is the perfect fit for Microservices, providing features that simplify
microservices development and deployment.
Polyglot languages and frameworks
Consistent testing environments
Scaling
Instant Rollback and Versioning
Self Service
30. Operation
Spring Cloud Dashboard
Spring I/O
2016
Discovery Design Build QA Deployment Operations
• Simple GUI to administrate Spring Cloud applications infrastructure
• Fork of Spring Boot Admin to manage applications registered in service
registry (like Eureka).
Features for every register service
• Show name/id and version number
• Show health status
• Show details, like
• Java System / Environment / Spring
properties
• JVM & memory metrics
• Counter & gauge Metrics
• Datasource Metrics
• Easy logger level management
• Interact with JMX-Beans
• View Threaddump
• Application registry history ( from
Eureka Server )
• Circuit Breaker dashboard ( from
Hystrix or Turbine )
31. Operation
Logging
Discovery Design Build QA Deployment Operations
• Centralized Logging with ELK Stack
Front App
Front App
API Gateway
Business Services - SOAMicroservices
Central
Logging
Server
ETL Store Dashboards
Logging
MicroService
Async call
e2e trackingId
Spring I/O
2016
32. Operation
Audit
Discovery Design Build QA Deployment Operations
Spring I/O
2016
• Audit events integrated in centralized logging system
• Extended to Front and SOA Layer to provide e2e traceability
Start
Request Sent
Response received
End
Error
Functional
Automatically
generated
Generated
from
application
Event types
Event info
Timestamp
Event Type
Hostname
TrackingId
Source Application
Arch version
Error info
App Version
Message
JVMName
MicroServiceType
MicroServiceID
MIcroServiceName
OperationName RequestMapping
Automatically
generated
Generated
from
application/
architecture
Microservice layer specific
35. Conclusions
Final thoughts
Spring I/O
2016
• Microservices architectures have a lot of positive aspects but also challenges
to be solved, technical and related to the enterprise.
• Design is a key concept, there’s no silver bullet but some techniques can help.
• Standardised tools and procedures aids productivity and scalability in big
projects...
• …but extensible and open for future incremental enhancements.
• PaaS environments are best suited for microservices deployment.
Lessons learned
• Brixton upgrade, Docker, HATEOAS, Event management, Asynchronous
messaging, …
Backlog