De los microservicios al
monolito
Cristian Cotes
@ccotesg
Microservices
Cristian Cotes
ExperienceWho am I?
Contexts
● Responsibilities
● Motivation/goals
● Team
● Type of product
● Type of company
Everything is a trade-off
VS
Rápido y mal
Lento y bien
Rápido y bien
Microservices vs monolith
Call to other components
S4
S3
S5
S2S1
C1 C2
Microservices vs monolith
Contract changes
S4
S3
S5
S2S1
C1 C2
Microservices vs monolith
Deploy
S4
S3
S5
S2S1
C1 C2
Microservices vs monolith
Transactions
S4
S3
S5
S2S1
C1 C2
C3
Microservices vs monolith
Monitoring
S4
S3
S5
S2S1
C1 C2
Coding horror
(Some nice examples)
Rule 1: Create use cases
Examples:
● SendMessageUseCase
● EditMessageUseCase
● ForwardMessageUseCase
● ...
Rule 2: Encapsulate your business logic
● Create Objects with its own behaviour
● Instantiate/create them inside use cases
● Don’t expose their implementation
Rule 3: Hide implementation details
● Database implementation
● Message brokers
● 3rd parties services
● Frameworks
DomainApplicationInfrastructure
Repository
Implementation
HTTP server
Use Case Object / Entity
Infrastructure
Application
Domain
Rule 4: Create slices
Infrastructure
Application
Domain
Rule 5: Extract commonalities
● Common folder
● Future independent libraries
Can I skip the rules?
Testing
● Testing by layers
● Unit test
● Integration
● End-2-end
Database
● Each slice has its on database/schema
● Queries across slices?
The purpose of a good architecture is to
defer decisions, delay decisions. The job
of an architect is not to make decisions,
the job of an architect is to build a
structure that allows decisions to be
delayed as long as possible. Why?
Because when you delay a decision,
you have more information when it
comes time to make it.
But...
Break? When?
● The team is big enough
● Some slices have special requirements (performance,
computation...)
● Slices with different non-functional requirements
Conclusion
● Understand your context
● Study the trade-offs
● Optimize your decisions
● Rules for the win!
● Monoliths are so cool, if you know how to build them! :)
De los microservicios al
monolito
Cristian Cotes
@ccotesg
One more thing...
● DDD complexity
● Domain services, domain events, aggregates…
● Frontend
● Frameworks
● ORM
● FP

De los microservicios al monolito