modules or microservices?
TRANSCRIPT
About SanderFellow, Software Architect
@ Luminis
Experience in modular development stacks
Conference Speaker & Author
@Sander_Mak
The Three Tenets of Modularity
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
A Microservice is...
Independently deployableImplementing a business capability
Doing one thing, and doing it wellCommunicating over the network
@Sander_Mak
users
assignmentslearningmaterial
students
gradingcourses
attendance
Microservices Monolith?
usersstudentslearningmaterial
shipping
coursesforecasting
attendance
@Sander_Mak
users
assignmentslearningmaterial
students
gradingcourses
attendance
Microservices Monolith?
usersstudentslearningmaterial
shipping
coursesforecasting
attendance
@Sander_Mak
Microservices:Distributed system
Service Discovery
?
?
?
?
users
assignmentslearningmaterial
students
gradingcourses
attendance
@Sander_Mak
users
assignmentslearningmaterial
students
gradingcourses
attendance
Microservices:Distributed system
Network Fallacies
@Sander_Mak
users
assignmentslearningmaterial
students
gradingcourses
attendance
Microservices:Distributed system
Deployment
@Sander_Mak
Microservices:Distributed system
Config. Managementv1 v2 v3
v2 v3
at least x4 (DTAP)
users
assignmentslearningmaterial
students
gradingcourses
attendance
@Sander_Mak
Microservices: Securityusers
assignmentslearningmaterial
students
gradingcourses
attendance
Distributed system
@Sander_Mak
Messy Monolith
Microservices All The Way
Features
Cost
But... vendors?! Won't magically transform your organization!
@Sander_Mak
users
assignmentslearningmaterial
students
gradingcourses
attendance
Microservices Monolith?
usersstudentslearningmaterial
shipping
coursesforecasting
attendance
@Sander_Mak
Microservices Modules!users
assignmentslearningmaterial
students
gradingcourses
attendance
Modular app users
assignmentslearningmaterial
students
gradingcourses
attendance
@Sander_Mak
Module SystemsJava OSGi
Java 9
JavaScript ...
ES2015 Modules
C++
C++20?
.Net NuGet
.Net Core
@Sander_Mak
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
Module SystemsJava OSGi
Java 9
JavaScript ...
ES2015 Modules
C++
C++20?
.Net NuGet
.Net Core
@Sander_Mak
Module Systems: Java 9module attendance {
exports attendance.api; requires students; requires courses;
}
@Sander_Mak
Module Systems: Java 9module attendance {
exports attendance.api; requires students; requires courses;
}
Strong Encapsulation
@Sander_Mak
Module Systems: Java 9module attendance {
exports attendance.api; requires students; requires courses;
}
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
Module Systems: Java 9module attendance {
exports attendance.api; requires students; requires courses;
}
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
Module Systems: Java 9Module Resolution (Reliable Configuration)
Increased Security (Hide Platform Internals)
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
import { sq } from mymodule;
console.log("Two squared", sq(2));
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
Strong Encapsulation
import { sq } from mymodule;
console.log("Two squared", sq(2));
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
Strong Encapsulation
Well-Defined Interfaces
import { sq } from mymodule;
console.log("Two squared", sq(2));
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
import { sq } from mymodule;
console.log("Two squared", sq(2));
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
import { sq } from mymodule;
console.log("Two squared", sq(2));
Consider TypeScript
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
Well-Defined Interfaces
import { sq } from mymodule;
console.log("Two squared", sq(2));
Consider TypeScript
@Sander_Mak
Module Systems: ES2015export function sq(i) { return secret(i); }
function secret(i) { return i * i; }
import { sq } from mymodule;
console.log("Two squared", sq(2)); (let's not go there...)
@Sander_Mak
Module Systems: C++20?module mymodule;
export int sq(int i) { return secret(i); }
int secret(int i) { return i * i; }
@Sander_Mak
Module Systems: C++20?module mymodule;
export int sq(int i) { return secret(i); }
int secret(int i) { return i * i; }
#include <stdio.h> import std.io import mymodule
int main() { printf("Two squared %d", sq(2)); return 0; }
@Sander_Mak
Module Systems: C++20?module mymodule;
export int sq(int i) { return secret(i); }
int secret(int i) { return i * i; }
#include <stdio.h> import std.io import mymodule
int main() { printf("Two squared %d", sq(2)); return 0; }
Strong Encapsulation
@Sander_Mak
Module Systems: C++20?module mymodule;
export int sq(int i) { return secret(i); }
int secret(int i) { return i * i; }
#include <stdio.h> import std.io import mymodule
int main() { printf("Two squared %d", sq(2)); return 0; }
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
Module Systems: C++20?module mymodule;
export int sq(int i) { return secret(i); }
int secret(int i) { return i * i; }
#include <stdio.h> import std.io import mymodule
int main() { printf("Two squared %d", sq(2)); return 0; }
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
users
app.users.User app.users.UserInfo
app.users.internal.UserImpl app.users.internal.Util;
assignments ... ...
courses ... ...
students ... ...
attendance ... ...
grading ... ...
learningmaterial ... ...
Not Just on the Whiteboard
@Sander_Mak
users
app.users.User app.users.UserInfo
app.users.internal.UserImpl app.users.internal.Util;
assignments ... ...
courses ... ...
students ... ...
attendance ... ...
grading ... ...
learningmaterial ... ...
Not Just With Discipline
@Sander_Mak
Advantages of Modules
Strong but Refactorable Boundaries
https://www.infoq.com/presentations/microservices-future
~1800 microservices
@Sander_Mak
Advantages of Modules
Strong but Refactorable Boundaries
"The [Linux] project is structured so people can work independently, Torvalds explained. "We've been able to really modularize the code and development model so we can do a lot in parallel." - El Reg
@Sander_Mak
Advantages of Modules
Strongly typed, In-Process CommunicationNo Serialization or Network Latency
@Sander_Mak
Advantages of Modules
Strongly typed, In-Process CommunicationEver Tried Serializing a Function?
@Sander_Mak
Advantages of Modules
Strongly typed, In-Process CommunicationGraphQL or Protobuf > REST
@Sander_Mak
Advantages of Modules
Eventual Consistency is a ChoiceIt's Still a Good Idea to Partition Data
@Sander_Mak
Advantages of Microservices
Best Stack for Each Service
learningmaterial students assignments
(but is your org ready for this?)
@Sander_Mak
Advantages of Microservices
Independent Deployment
learningmaterial students assignmentsv2 v3 v1
@Sander_Mak
Advantages of Microservices
Independent Deployment
learningmaterial students assignmentsv2 v3 v1
(beware of deployment dependencies!)
@Sander_Mak
Advantages of Microservices
Independent Deployment
learningmaterial students assignmentsv2 v3 v1
Modularized App > Distributed Monolith
(beware of deployment dependencies!)
@Sander_Mak
Advantages of Microservices
Independent Failure
learningmaterial students assignments
(when your services are truly autonomous...)
@Sander_Mak
Advantages of Microservices
Independent Scaling
assignmentslearningmaterial
4x g2.2xlarge 2x t2.medium 1x t2.micro
students
@Sander_Mak
At the speed of light, everything changes!
Dude, chill. The apple still doesn't fall far from the tree.
@Sander_Mak
Don't Solve Problems You Don't Have
At the speed of light, everything changes!
Dude, chill. The apple still doesn't fall far from the tree.
@Sander_Mak
Solve Problems You Do Have In The Simplest Possible Way
At Least Read Up on Modular Development In Your Tech Stack of Choice
Explicit Dependencies
Strong Encapsulation
Well-Defined Interfaces
@Sander_Mak
Design as Microservices,Build as Modules
You Can Move to (Micro)services Later.Modules EnableLarger Services!
@Sander_Mak
Design as Microservices,Build as Modules
Don't worry, you can still do: Reactive NoSQL Cloud DevOps DDD
Thanks. Read More: bit.ly/modularapps bit.ly/java9book
@Sander_Mak