SlideShare a Scribd company logo
Enterprise Developers Guild
9/26/2017
Microservices
Primer for
Monolithic Devs
1
2
3
4
5
Agenda
Microservices Overview
Service and API Boundaries
Designing for Distributed Data
Managing Microservices
Demo with Azure Service Fabric
GOAL: Understand what to expect on Microservices projects
Impact of Modern Apps
 Users expect more features without downtime
 Developers have to figure out a solution
Monolith vs. Microservices
Monolithic SOA Microservices
Evolution of Architectures
GoF Patterns, SOLID, Hexagonal, Testable
Use Cases – App Features
 SaaS product
 Availability critical
 Variable I/O & Scale
 Variant feature changes
Use Cases – Business Features
 Remain competitive – QTM
 Evolving business model
 Acquisition-based model
When to start with monoliths
(Realistically – Most of the time)
 Unknown growth/adoption
 Boundaries not well-defined
 No DevOps culture
MSDN
Determining
Service
Boundaries
DDD: Bounded Context
“Bounding contexts gives team
members a clear and shared
understanding of what has to
be consistent and what can
develop independently.”
- Eric Evans, Domain-Driven Design, 2003
Bounded Context Example
Course
Subject
Student
Class Schedule
Faculty
Advisor
Bounded Context Example
Course
Subject
Student
Class ScheduleCourse ID Faculty
Member
Advisor ID
(Faculty Member)
Add/Edit courses
Add/Edit students,
Set semester class schedule
Add/Edit
faculty members
The Microservices Version
Entities & Processes
Services boundaries tend to be separated by nouns & verbs
Student
Service
Course
Service
NOUNS (Entity CRUD)
Batch
Enrollment
Search
Prospects
VERBS (Business Process)
Optional Monolithic Start
 Bounded Contexts
 Variable Scaling
 Change Frequency
 Business Process
Start large and break down based on:
EXAMPLE: EF Bounded Context
// Typical EF setup with all data models in single DB context
public class SchoolDbContext : DbContext, ISchoolDbContext
{
public DbSet<Student> Students { get; set; }
public DbSet<Course> Courses { get; set; }
public DbSet<Subject> Subjects { get; set; }
public DbSet<Faculty> Faculty { get; set; }
public DbSet<FacultyMember> FacultyMembers { get; set; }
}
EXAMPLE: EF Bounded Context
// Contexts grouped by entities w/ related, specific operations
public class StudentDbContext : DbContext
{
public DbSet<Student> Students { get; set; }
public DbSet<ClassSchedule> ClassSchedules { get; set; }
}
public class CourseDbContext : DbContext { }
public class FacultyDbContext : DbContext { }
MSDN
Managing
APIs
API Death Stars
API Gateway
Follow good REST principles
 Resource hierarchies
 HTTP methods & status codes
GET /students/123/schedule/2017 | 200
POST /students/123/schedule | 201
PUT ...
PATCH ...
DELETE ...
Versioning
URI
/v1/students/123
Query String
/students/123?v=1.0
Accept Header
/students/123
Accept: x.student-api.v1+json
MSDN
Managing
Distributed
Data
Monolith Queries
SELECT -- Syllabus and advisor info
FROM StudentSyllabus ss
INNER JOIN Syllabus s ON ss.SyllabusId = s.Id
INNER JOIN Course c ON s.CourseId = c.Id
INNER JOIN Advisor a ON ss.AdvisorId = a.Id
INNER JOIN [User] u ON a.UserId = u.Id
WHERE ss.[Year] = @currentYear
AND ss.StudentId = @studentId
AND ss.IsActive = 1
Querying Distributed Databases
Cross-Service Queries
Cross-Service Queries
fetch('/api/v1/students/12345/schedule/2017')
.then((response) => response.json())
.then(function(student) {
// Call the other services to get “join” data
var advisorApi = '/api/v1/faculty/members/' + student.advisorId;
var courseApis = [];
student.courses.forEach(function(course) {
courseApis.push('/api/v1/courses/' + course.id);
}, this);
// Create promises, merge results, data binding, etc.
});
Materialized Views
Materialized Views
fetch('/api/v1/students/12345/syllabus/2017')
.then((response) => response.json())
.then(function(student) {
// Call the other services to get “join” data
var advisorApi = '/api/v1/faculty/members/' + student.advisorId;
var courseApis = [];
student.courses.forEach(function(course) {
courseApis.push('/api/v1/courses/' + course.id);
}, this);
// Create promises, merge results, data binding, etc.
});
// Trade-off is more backend code for event publishing
fetch('/api/v1/students/12345/schedule/2017’).then(...)
Monolith Commands
using (IDbContext db = _dbFactory.GetContext())
{
Syllabus syllabusDataModel = db.Syllabus.Single(s =>
s.Id == syllabusDomainModel.Id);
Mapper.MapChanges(
syllabusDataModel, syllabusDomainModel);
// Built-in transactions for related tables
db.SaveChanges();
}
Eventually Consistent Services
Event Sourcing
Managing
Microservices
Team DevOps
Repos Builds Releases
Unit Testing
Internal Logic
• In-memory only
• Mock/fake dependencies
Unit Testing
Owned Dependencies
• Provisioning/Teardown
• Longer duration
Unit Testing
Non-Owned Dependencies
• Contracts
• Consumer vs. Provider
Platform Checklist
 Frameworks
 Logging
 Monitoring
 Auto Scaling
 Service Discovery
 Instant Rollback
 Auto Versioning
 Failure Resistance
 Self-Service Provisioning
 Rapid Deployment
To run microservices, you need:
Platforms
PaaS CaaS IaaS
 Azure Service Fabric
 Pivotal Cloud Foundry
 Cloud w/ Frameworks:
 Netflix OSS
 Mantl
 Amazon ECS
 Azure Container
Services
 Google Container
Engine
 VMs
Tools/Frameworks/Libraries
Event Stores
 Eventuate
 Cosmos DB Change Feed
 eventstore.org
Service Discovery
 Service Fabric Naming Service
 Consul
 Netflix Eureka
API Gateway
 Azure/AWS API Management
 Mulesoft
 Google Apigee
Event Messaging
 Azure/AWS queue services
 Apache Kafka
 RabbitMQ
More Info
Questions? lfaulkner@cardinalsolutions.com
Design patterns and technical approaches:
http://microservices.io/
https://docs.microsoft.com/en-us/azure/architecture/ (Cloud Patterns PDF)
https://martinfowler.com/articles/microservices.html
How they did it:
http://searchmicroservices.techtarget.com/ (RSS)
https://medium.com/netflix-techblog
https://blogs.msdn.microsoft.com/bharry/ (How the VSTS team does it)

More Related Content

PDF
An Overview of Entity Framework
PDF
deep learning in production cff 2017
PPTX
Overview of entity framework by software outsourcing company india
PPTX
Spring andspringboot training
PDF
Delivering Mobile Course Content with uMobile
PPTX
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
PPTX
Math-Bridge Architecture
PDF
PHP: 4 Design Patterns to Make Better Code
An Overview of Entity Framework
deep learning in production cff 2017
Overview of entity framework by software outsourcing company india
Spring andspringboot training
Delivering Mobile Course Content with uMobile
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Math-Bridge Architecture
PHP: 4 Design Patterns to Make Better Code

Similar to Microservices Primer for Monolithic Devs (20)

PDF
Cursos sql server .net visual basic octubre 2010
PDF
Designing Java EE Applications in the Age of CDI
PDF
Lessons learned teaching a groovy grails course
PDF
JavaScript and jQuery for SharePoint Developers
PDF
exploring-spring-boot-clients.pdf Spring Boot
PPTX
MVC & backbone.js
PDF
GraphQL 101
PPTX
Scalable java script applications
PPTX
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
PPTX
1. Mini seminar intro
PPTX
jquery summit presentation for large scale javascript applications
PPTX
Java Technology
PPTX
Building a scalable web application by combining modern front-end stuff and A...
PDF
Data access
PDF
Getting Started with Spring Framework
PDF
Principles of MVC for Rails Developers
PPTX
A Groovy Way to Interface With Cascade Server
PPT
Introduction to design_patterns
PPTX
CORE JAVA & ADVANCE JAVA
PPT
Sakai and IMS LIS Integration
Cursos sql server .net visual basic octubre 2010
Designing Java EE Applications in the Age of CDI
Lessons learned teaching a groovy grails course
JavaScript and jQuery for SharePoint Developers
exploring-spring-boot-clients.pdf Spring Boot
MVC & backbone.js
GraphQL 101
Scalable java script applications
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
1. Mini seminar intro
jquery summit presentation for large scale javascript applications
Java Technology
Building a scalable web application by combining modern front-end stuff and A...
Data access
Getting Started with Spring Framework
Principles of MVC for Rails Developers
A Groovy Way to Interface With Cascade Server
Introduction to design_patterns
CORE JAVA & ADVANCE JAVA
Sakai and IMS LIS Integration
Ad

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Welding lecture in detail for understanding
PPTX
web development for engineering and engineering
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Construction Project Organization Group 2.pptx
PDF
Well-logging-methods_new................
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Welding lecture in detail for understanding
web development for engineering and engineering
CH1 Production IntroductoryConcepts.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Construction Project Organization Group 2.pptx
Well-logging-methods_new................
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
bas. eng. economics group 4 presentation 1.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
UNIT 4 Total Quality Management .pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Ad

Microservices Primer for Monolithic Devs

Editor's Notes

  • #3: Poll audience – have used microservices; have not but experienced with monoliths; have just heard the buzzwords Walk away with enough info to research on your own, so will table deep dive questions.
  • #4: Users want more features, no downtime, and have other options Microservices provides agility and flexibility to application design
  • #5: Independent services, own data storage, deployed independently
  • #6: This graphic really clarified microservices for me Monoliths – Tightly integrated, changes have ripple effects to rest of app SOA – Looser coupling, but had to be orchestrated to fit together Microservices – Independently developed and deployed Earlier – Mainframes New – Serverless
  • #7: Does this apply to you? Technical approaches we’re about to discuss have complexity trade-offs. Like with any architecture, make sure to use right tool for the job
  • #9: Going straight to microservices is a risk. A lot more technical complexity
  • #10: What are the boundaries
  • #11: DDD provides a holistic view of software design. Bounded context is one of its patterns. Small models that support specific operations Quote gets to the heart of what microservices “Delimited applicability”
  • #13: Group into sets that represent related, specific operations. How micro is micro? Add, Edit as separate services would be a nanoservice. Group by related but specific operations
  • #14: Independent services, own data storage, deployed independently
  • #16: As mentioned in earlier slide, if bounded contexts are unknown or you’re not sure ROI there for the technical complexity trade-off, option to start as a monolith and break it down.
  • #17: Illustrate breaking down monoliths with EF contexts.
  • #18: Contexts grouped by specific operations/transactions.
  • #20: As microservices grow, becomes difficult for web and mobile developers to understand how to use them.
  • #21: Consolidate/orchestrate calls, provide single API call for consumers Good REST design (DX, Developer Experience. API UX for web/mobile developers) API gateway Versioning
  • #25: Isolated databases Calling other services Duplicated data is ok Event-driven architecture CQRS
  • #26: Direct DB access creates a tight coupling that loses the benefit of microservices
  • #27: Have to call out to other services to get “join” data Still gain scale advantages of other endpoints Plus, the other services might be doing their own gets. Slippery slope
  • #28: Call each service and aggregate the results Also can push aggregation to server, e.g., API Gateway, or inter-service calls
  • #29: Note the use of messaging, not a tightly coupled replication feature Also an example of CQRS Trade off is more code for pub/sub, but less code on query
  • #30: Replace the logic that aggregates results to directly calling the materialized view That’s queries, now let’s look at commands (saves)
  • #31: Switch from SQL to ORM to more easily illustrate transactions Same deal, don’t create tight coupling by saving directly to other service db’s
  • #32: 2pc not an option (not all db types support it) Event-driven, eventually consistent approach Pros: Consistency across services Cons: More complex, event publishing must be reliable
  • #33: Use an event store Add only, so faster and no local transaction needed Replay events for current state Services still subscribe Most event stores have snapshots for performance - Eventuate, Cosmos DB change feed Others – transaction log tailing/mining (Linkedin w/ Oracle, AWS)
  • #35: (depends on your IT setup)  Teams own repos, builds, releases
  • #42: Demo if time