SlideShare a Scribd company logo
David Gómez G.
Developer Advocate .
Building monolith applications that can scale to
micro services
(only if they need to)
@AXONIQ @DGOMEZG
@DGOMEZG
https://www.infoworld.com/article/3639050/complexity-is-killing-software-developers.html
Don’t let the microservices hype
ruin your project
@AXONIQ @DGOMEZG
David Gómez G.
Developer Advocate .
An Exciting New Project Starts
@DGOMEZG
Or you may need to add
a new module/feature to
an existing project
@DGOMEZG
But this time,
you are going to get it right!
@DGOMEZG
We need to scale!
We need to go to the cloud(s)!
@DGOMEZG
How others solved
similar problems?
@DGOMEZG
@DGOMEZG
Microservices
architecture
@DGOMEZG
Microservices
architecture
@DGOMEZG
Microservices
architecture
Building Modular monliths that could scale to microservices (only if they need to) - Updated for Chicago JUG
You will probably be missing
all of these
@DGOMEZG
@DGOMEZG
Hype Driven Development
HDD
Problems seem easier to
solve when you have
enough context
@DGOMEZG
we don’t usually know enough
@DGOMEZG
@DGOMEZG
we don’t usually know enough
@DGOMEZG
@DGOMEZG
What you need
(Your steps)
• Separate your different tasks by type
• Focus on understanding the problem(s) you need to solve,
• Model each problem independently
• Be prepared to grow & scale (both in features and in
performance)
• Don’t couple to other components
@DGOMEZG
Our example:
A Conference Management Tool.
@DGOMEZG
Our example:
A Conference Management Tool.
Dates, Sponsors,
Call For Papers, Proposals, Agenda
T
alks, Tickets, Attendees…
Call For Papers,
Agenda, Questions, Forums,
Tickets,
Agenda, speakers, …
@DGOMEZG
Event Storming
@DGOMEZG
Command Query Responsibility Separation
CQRS
@DGOMEZG
COMMANDS QUERIES
CQRS
Separate Queries from Commands
@DGOMEZG
@DGOMEZG
CQRS
Separate Queries from Commands
COMMANDS
What actions do require
changes in the state of the
application?
What other changes will be
necessary to notify/propagate?
@DGOMEZG
@DGOMEZG
CQRS
Separate Queries from Commands
COMMANDS
Define Edition (Dates)
Accept/Reject Talk Proposal
Open Ticket sales
Open Call For Papers
Add/Remove Track
Define Q&A Channel
Submit Proposal
Withdraw Proposal
Confirm Proposal
Join Q&A Channel
Buy Ticket
Add Talk To My Agenda
Ask Questions in Q&A.
Rate Talk
@DGOMEZG
@DGOMEZG
CQRS
Separate Queries from Commands
QUERIES
What information do the users
require?
@DGOMEZG
@DGOMEZG
CQRS
Separate Queries from Commands
QUERIES
List Proposals
Get Talk Popularity
Get Talks Rating
Get Questions
Get Talk Feedback
My Talk Info
Conference Agenda
My Agenda
Q&A Messages
@DGOMEZG
@DGOMEZG
Queries
UI / API
Commands
@DGOMEZG
@DGOMEZG
Model with Boundaries
DDD
https://www.flickr.com/photos/xwl/4936781806/
@DGOMEZG
Which map would you prefer?
It depends!
@DGOMEZG
@DGOMEZG
COMMANDS QUERIES
Focus on modelling within the
boundaries of each element
Command model Projections
Keep only
relevant information
for the action in each model
@DGOMEZG
@DGOMEZG
JoinRoom
Send Message
JoinRoom
Command model
CreateChatRoom
NAME, DESCRIPTION
USER, ROOMID, MSG
USERID, ROOMID
@DGOMEZG
@DGOMEZG
Projections
Projections maintain the structure of information
close to how it is needed by the client/user
ListRooms
ROOM,
DESCRIPTION,
NUM_OF_MEMBERS
GetRoomMessages
DATE, USER, MSG
DATE, USER, MSG
DATE, USER, MSG
@DGOMEZG
@DGOMEZG
Aggregate
A set of objects, relationship and invariants that are
considered as one unit with regard to data changes.
Define the boundaries in which some invariants are kept.
They are a model of part of the domain.
@DGOMEZG
@DGOMEZG
Aggregate
@DGOMEZG
@DGOMEZG
Queries
UI / API
Commands
Command Model Projections
?
@DGOMEZG
@DGOMEZG
Notify that something has happened
Events
Remember our micro services
architecture?
@DGOMEZG
Remember our micro services
architecture?
@DGOMEZG
Remember our micro services
architecture?
Event
@DGOMEZG
@DGOMEZG
Queries
UI / API
Commands
Command Model
Projections
Events
@DGOMEZG
@DGOMEZG
Event Modeling
http://eventmodeling.org
@DGOMEZG
Event-Streaming
vs
Event-Sourcing
Event-Streaming
@DGOMEZG
Event-Sourcing
@DGOMEZG
@DGOMEZG
Why Event-Sourcing?
@DGOMEZG
Why Event-Sourcing?
ProposalUpdated (id: 123, title, Smith)
SpeakerChanged (id:123, jDoe)
ProposalSubmitted
ProposalAccepted
ProposalWithdrawn
ProposalDraftSent (id: 123) id: 123.
Author: John Doe
Title:
What’s new in Java 17
status: Withdrawn
What happened What we store
@DGOMEZG
Why Event-Sourcing?
Business Reasons Technical reasons
• Reliability of decisions
• Auditing / compliance /
transparency
• Data mining, analytics: value for
data
• Historic data useful for new
features
• Guaranteed completeness of event stream
• Single point of truth
• Concurrency / conflict resolution
• Facilitates debugging / forensic analysis
• Replay into new read models (scalability with
CQRS)
@DGOMEZG
Location
Transparency
(Enabled by
Commands, Queries & Events)
Location Transparency
@DGOMEZG
@DGOMEZG
Location Transparency
@DGOMEZG
@DGOMEZG
Location Transparency
A component should neither be aware of nor make any assumptions about
the location of other components
Furthermore, it should not even know which components it interacts with
@DGOMEZG
@DGOMEZG
@DGOMEZG
1. Keep the independent models
@DGOMEZG
1. Keep the independent models
@DGOMEZG
1. Keep the independent models
@DGOMEZG
1. Keep the independent models
CQRS + DDD
@DGOMEZG
Event Sourcing (sync modules)
+ Message
Bus
Event
store
@DGOMEZG
Putting it
together
using
@DGOMEZG
Command Model
data class CreateRoomCommand(

@TargetAggregateIdentifier val roomId: String, 

val name: String)
data class JoinRoomCommand(

@TargetAggregateIdentifier val roomId: String, 

val participant: String)

data class PostMessageCommand(

@TargetAggregateIdentifier val roomId: String, 

val participant: String, 

val message: String)

data class LeaveRoomCommand(

@TargetAggregateIdentifier val roomId: String, 

val participant: String)
@DGOMEZG
Event Model
data class RoomCreatedEvent(

val roomId: String, 

val name: String)
data class ParticipantJoinedRoomEvent(

val roomId: String, 

val participant: String)

data class MessagePostedEvent(

val roomId: String, 

val participant: String, 

val message: String)

data class ParticipantLeftRoomEvent(

val roomId: String, 

val participant: String)
@DGOMEZG
Aggregate
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



public ChatRoom() {

}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public ChatRoom() {



}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public ChatRoom(CreateRoomCommand command) {



}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public ChatRoom(CreateRoomCommand command) {

apply(new RoomCreatedEvent(command.getRoomId(), command.getName()));

}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public ChatRoom(CreateRoomCommand command) {

apply(new RoomCreatedEvent(command.getRoomId(), command.getName()));

}

@CommandHandler

public void handle(JoinRoomCommand command) {

}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public ChatRoom(CreateRoomCommand command) {

apply(new RoomCreatedEvent(command.getRoomId(), command.getName()));

}

@CommandHandler

public void handle(JoinRoomCommand command) {

apply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));

}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public void handle(JoinRoomCommand command) {

apply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));

}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public void handle(JoinRoomCommand command) {

apply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));

}

@EventSourcingHandler

public void on() {



}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public void handle(JoinRoomCommand command) {

apply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));

}

@EventSourcingHandler

public void on(ParticipantJoinedRoomEvent event) {



}

}
@DGOMEZG
Aggregate: Handling a Command
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public void handle(JoinRoomCommand command) {

apply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));

}

@EventSourcingHandler

public void on(ParticipantJoinedRoomEvent event) {

this.participants.add(event.getParticipant());

}

}
@DGOMEZG
Aggregate: Command Validation
@Aggregate

public class ChatRoom {

@AggregateIdentifier

private String roomId;

private Set<String> participants;



@CommandHandler

public void handle(JoinRoomCommand command)

if (…) {

pply(new ParticipantJoinedRoomEvent(command.getRoomId(), command.getParticipant()));



}

@EventSourcingHandler

public void on(ParticipantJoinedRoomEvent event) {

this.participants.add(event.getParticipant());

}

}
@DGOMEZG
Location Transparency. Sync other components
@Component

public class RoomSummaryProjection {

private final RoomSummaryRepository roomSummaryRepository;

@EventHandler

public void on(RoomCreatedEvent event) {

roomSummaryRepository.save(new RoomSummary(event.getRoomId(), event.getName()));

}

@EventHandler

public void on(ParticipantJoinedRoomEvent event) {

roomSummaryRepository.findById(event.getRoomId())

.ifPresent(RoomSummary"#addParticipant);

}

}
@DGOMEZG
Handling Queries
@Component

public class RoomSummaryProjection {

private final RoomSummaryRepository roomSummaryRepository;

@QueryHandler

public List<String> handle(RoomParticipantsQuery query) {

return roomSumaryRepository.findRoomParticipants(query.getRoomId())

.stream()

.map(RoomParticipant"#getParticipant).sorted()

.collect(toList())event.getName()));

}

}
@DGOMEZG
In summary
@DGOMEZG
HDD
CQRS
DDD
Event-
Sourcing
@DGOMEZG
https://youtu.be/TnKzCFPtl0E
@DGOMEZG
Useful Resources
https://lp.axoniq.io/chicago-jug
The slides Code-sample &
tutorial repo
Free DDD, CQRS & ES
courses
eventmodeling.org
Domain-Driven
Design
https://lp.axoniq.io/chicago-jug

More Related Content

DOCX
Physics project chirag
PDF
Qualitative Analysis of Coconut Water Chemistry Investigatory Project
PDF
Complete practical file of class xii cs 2021-22
PPTX
Password Cracking
PPT
DDoS Attacks
DOCX
Dna Replication
PDF
English project class 12 (ch on the face of it)
PDF
Building modular monoliths that could scale to microservices (only if they ne...
Physics project chirag
Qualitative Analysis of Coconut Water Chemistry Investigatory Project
Complete practical file of class xii cs 2021-22
Password Cracking
DDoS Attacks
Dna Replication
English project class 12 (ch on the face of it)
Building modular monoliths that could scale to microservices (only if they ne...

Similar to Building Modular monliths that could scale to microservices (only if they need to) - Updated for Chicago JUG (20)

PDF
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
PPT
Document Object Model
PPT
Document Object Model
PPTX
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
PPT
Grails Introduction - IJTC 2007
PPT
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
PDF
Consumer driven contract testing
PPT
Robotlegs on Top of Gaia
PPT
DDD Framework for Java: JdonFramework
PPTX
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
PDF
DIとトレイとによるAndroid開発の効率化
PPTX
React native: building shared components for Android and iOS
PPTX
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
PPTX
Designing DDD Aggregates
PDF
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
PDF
Cleaning your architecture with android architecture components
PPT
A Brief MongoDB Intro
PPTX
Introduction to CQRS
PPTX
Old code doesn't stink - Detroit
PDF
Xamarin Under The Hood - Dan Ardelean
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Document Object Model
Document Object Model
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
Grails Introduction - IJTC 2007
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Consumer driven contract testing
Robotlegs on Top of Gaia
DDD Framework for Java: JdonFramework
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DIとトレイとによるAndroid開発の効率化
React native: building shared components for Android and iOS
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
Designing DDD Aggregates
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
Cleaning your architecture with android architecture components
A Brief MongoDB Intro
Introduction to CQRS
Old code doesn't stink - Detroit
Xamarin Under The Hood - Dan Ardelean
Ad

More from David Gómez García (20)

PDF
Leverage CompletableFutures to handle async queries. DevNexus 2022
PDF
Leveraging Completable Futures to handle your query results Asynchrhonously
PDF
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
PDF
What's in a community like Liferay's
PDF
Java9 Beyond Modularity - Java 9 más allá de la modularidad
PDF
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
PDF
Managing user's data with Spring Session
PDF
Parallel streams in java 8
PDF
Construccion de proyectos con gradle
PDF
Java 8 Stream API. A different way to process collections.
PDF
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
PDF
Measuring Code Quality in WTF/min.
PDF
Spring4 whats up doc?
PDF
Gradle como alternativa a maven
PDF
El poder del creador de Software. Entre la ingeniería y la artesanía
PDF
Geo-SentimentZ
PDF
HDTR images with Photoshop Javascript Scripting
PDF
Wtf per lineofcode
PDF
A real systemwithjms-rest-protobuf-mongodb
PDF
Spring Data y Mongo DB en un proyecto Real
Leverage CompletableFutures to handle async queries. DevNexus 2022
Leveraging Completable Futures to handle your query results Asynchrhonously
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
What's in a community like Liferay's
Java9 Beyond Modularity - Java 9 más allá de la modularidad
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
Managing user's data with Spring Session
Parallel streams in java 8
Construccion de proyectos con gradle
Java 8 Stream API. A different way to process collections.
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Measuring Code Quality in WTF/min.
Spring4 whats up doc?
Gradle como alternativa a maven
El poder del creador de Software. Entre la ingeniería y la artesanía
Geo-SentimentZ
HDTR images with Photoshop Javascript Scripting
Wtf per lineofcode
A real systemwithjms-rest-protobuf-mongodb
Spring Data y Mongo DB en un proyecto Real
Ad

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation

Building Modular monliths that could scale to microservices (only if they need to) - Updated for Chicago JUG