SlideShare a Scribd company logo
You only need
100 lines of code
@rjrodger
nodeconfeu.com
Small services that do
one thing and do it well.
!
And there are lots of
them.
!
Fred George
http://vimeo.com/search?q=fred+george
Micro-Services
Best Practices.
!
Are a local maximum.
!
They exist to mitigate
inherent weakness.
Enterprise Software
Development
Discovering Micro-
services by accident.
The Sunday Business Post
Content processing flow
Article
Process
Feed
Reader
Article
Store
Article
Index
Image
Store
Image
Size
Image
Load
Natural way to split
the work...
!
For machines and for
humans
Individual node processes
Some services work
hard. Other's don't.
!
You can focus team
effort where it counts.
!
Cut corners. It works.
Scalable system?
Scalable services!
What is the number one risk
to enterprise software
development?
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-final
Small.
Single-purpose.
Use messages.
There are many of them.
Death is expected.
Micro-Services
100 lines of code.
!
A few screens to scroll.
!
Can fit inside your head.
Small
Use node modules.
!
Prefer composition of
libraries over the tyranny
of frameworks.
Where does the code go?
Do one thing and do it well.
!
Or badly. Rewrites are easy.
!
Large source files are a code
smell.
Single-purpose
A service that mediates.
A service that knows about
other services.
A service that accepts and
sends many kinds of messages.
Anti-pattern: the orchestrator
Standalone information.
!
You can pattern-match them.
!
They define the interface.
!
The transport mechanism is
not important.
Communicate with messages
No need for complex rules.
!
Do named keys have given values?
!
Use MUST IGNORE semantics.
This makes your world extendable.
Pattern matching
Richardrodger nodeday-2014-final
Write your services so they can
restart cleanly.
!
This is Node best practice. You
MUST die on uncaught exceptions.
!
So expect to die.
Crash-first Software
How do you give
your Node.js app
"enterprise-grade" reliability?
Richardrodger nodeday-2014-final
Make decisions later, with more information.
!
Calibrate quality and performance.
!
Make rewrites cheap.
!
Avoid project management ceremony.
!
Services are the right size for humans.
Micro-service Architecture
The classic agile iteration cycle
Design
refactor
developtest
release
The classic enterprise iterations
"We need a bug-fix iteration!"
!
"Let's refactor!"
!
"Unit test coverage is under 90%"
!
"Lock down!"
My previous startup:
FeedHenry
Monolithic Java System.
!
30 developer team, 3 years.
Strict 2-week agile iterations.
!
Custom integrations.
On-premise rollouts.
!
FeedHenry uses Node now
... because Technical Debt!
"Telecoms" Grade
We were stuck with our
original design decisions
When you have more information, later in the
project, you can:
!
Split services. Combine services.
Add services for special cases.
Extend messages with more context.
!
Rewrite bad services. Throw away and start
again. It's only 100 lines.
Changing services is easy
Calibrate
Some code is critical: high performance with
high cost of failure
!
Other code has much weaker constraints:
- low request volumes
- batch processes
- idempotent operations
- obvious immediate failure modes
Not all code is created equal
Services are a comfortable size.
!
You can easily group them by scale and
quality requirements.
!
This lets you focus effort where it counts.
Services can be
grouped by quality
The universal law of defects
project stage
costtofix
Rewriting buggy services is not expensive.
They are small and independent.
Messages keep you safe.
Micro-services reduce
the slope of this curve
Does it matter if a junior developer makes a
mess of a service that has low quality
requirements?
!
Does it even matter if developers randomly
pick services to work on?
!
Do you deploy a system? Or do you deploy
services?
Ceremony
Architecture
Let's design a system!
A basic approach
User Stories
capabilities
services
messages
User stories
autocomplete query
perform search
view info page
rank modules
update with new modules
get metadata from github etc.
Capabilities
Search
Engine
Module
Store
Meta
Data
Services
search-engine module-store meta-data
auto-complete
search
info request
update
Messages
IN OUT
auto-complete: list
auto-complete: add
search: query
search: index
search: rank
info: set
info: get
Update: notify
request: request info: set
search: index
auto-complete:add
auto-complete:add
request: request
How many of each service to run?
!
How do messages make it from one service
to another?
!
What happens when you deploy a new
version?
Micro-services in Production
Time domain.
!
Scale domain.
!
Behavioral domain.
!
+ Context-dependent domains.
Domain analysis
Time domain
real-time (1ms)
soft real-time (100ms)
responsive (1s)
process (1m)
batch (1h)
Scale domain
Messages per minute?
!
Message size?
!
CPU burn per message?
!
Acceptable error rate?
Behavioral domain
Idempotent?
!
At most once / exactly once / At least once ?
!
Transactional?
Message Transport
Should not matter. Do not decide upfront.
!
You will need to reconfigure later anyway.
Transport Modes
In Process.
- mostly for development
- also works for low volume services
!
Direct.
- use HTTP
- use load balancers to scale
More Transport Modes
PubSub.
- messages generate multiple actions
- senders know nothing
- publish interesting stuff
!
Message Queues.
- Needed for scale
- Choose wisely
- we like Apache Kafka
Message Delivery
In principle, every service could listen for
every message, ignoring most.
!
In practice, you will define a more
appropriate architecture (over time).
!
Micro-services allow you to defer this design
work until you have more information.
Some Examples
An MVP, with two instances behind a load
balancer. In-Process, and Direct transports
will take you quite far as you scale up.
!
Booking engine with 100 queries per
second, and 100 000 000 bookings per year.
You'll need PubSub and Queues.
Production Monitoring
Monitor your services. But the information is
not as useful as you think.
!
There are too many of them.
!
Monitor business outcomes.
!
Example: purchases per minute
Production Deployment
Business outcome monitoring enables low
risk deployments.
!
Messages (with MUST IGNORE) insulate
services from each other. You can run
multiple versions of the same service.
!
Deploy in stages, replacing a old version
with a new version gradually.
It's not about Node
You can build micro-services in any
language.
!
Node's event-drive nature does make it very
suitable.
!
More important: Node gives you covering
fire. Make a real change to the way you
build software.
Let's take the next step
Thank You!
richardrodger.com/monolithic-nodejs
@rjrodger

More Related Content

PDF
How microservices fail, and what to do about it
PDF
Micro-services Battle Scars
PDF
Richardrodger microxchgio-feb-2015-final
PDF
Building businesspost.ie using Node.js
PDF
Rapid Digital Innovation: How Node.js Delivers
PDF
Don't try these at home
PDF
Cleaning up your codebase with a clean architecture
PPTX
Serverless lessons learned #5 retries
How microservices fail, and what to do about it
Micro-services Battle Scars
Richardrodger microxchgio-feb-2015-final
Building businesspost.ie using Node.js
Rapid Digital Innovation: How Node.js Delivers
Don't try these at home
Cleaning up your codebase with a clean architecture
Serverless lessons learned #5 retries

What's hot (6)

PPTX
Design patterns - The Good, the Bad, and the Anti-Pattern
PDF
WordCamp Nashville: Clean Code for WordPress
PPT
Scaling Your Web Application
PPTX
Serverless lessons learned #4 circuit breaker
PDF
Coolblue Behind the Scenes | Pat Hermens - On the shoulders of giants.
PDF
WordCamp Nashville 2015: Agile Contracts for WordPress Consultants
Design patterns - The Good, the Bad, and the Anti-Pattern
WordCamp Nashville: Clean Code for WordPress
Scaling Your Web Application
Serverless lessons learned #4 circuit breaker
Coolblue Behind the Scenes | Pat Hermens - On the shoulders of giants.
WordCamp Nashville 2015: Agile Contracts for WordPress Consultants
Ad

Similar to Richardrodger nodeday-2014-final (20)

PDF
Moving to Microservices with the Help of Distributed Traces
PDF
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
PPTX
Let's talk about... Microservices
PPTX
Microservices for performance - GOTO Chicago 2016
PPTX
AI for Subtitling - Limecraft presentation the 2022 Open Forum
PPTX
Deep Dive: AWS X-Ray London Summit 2017
PDF
Tuenti Tech Teams. Frontend, Backend, Systems and more, working together
PDF
Adventures with Microservices
PDF
QCon 2015 - Microservices Track Notes
ODP
The Art of Message Queues - TEKX
PPTX
What are microservices
PDF
The Why and How of Applications with APIs and microservices
PPTX
Microservices architecture
PPTX
Microsoft Microservices
PDF
Form Function Class 6, Manila, Philippines 14/11/2015
PDF
Mini-course "Practices of the Web Giants" at Global Code - São Paulo
PDF
Operator-Less DataCenters A Near Future Reality
PDF
Operator-less DataCenters -- A Reality
PPT
Tuenti teams - Php Conference
PPTX
Introduction to requirement of microservices
Moving to Microservices with the Help of Distributed Traces
RedisConf18 - Common Redis Use Cases for Cloud Native Apps and Microservices
Let's talk about... Microservices
Microservices for performance - GOTO Chicago 2016
AI for Subtitling - Limecraft presentation the 2022 Open Forum
Deep Dive: AWS X-Ray London Summit 2017
Tuenti Tech Teams. Frontend, Backend, Systems and more, working together
Adventures with Microservices
QCon 2015 - Microservices Track Notes
The Art of Message Queues - TEKX
What are microservices
The Why and How of Applications with APIs and microservices
Microservices architecture
Microsoft Microservices
Form Function Class 6, Manila, Philippines 14/11/2015
Mini-course "Practices of the Web Giants" at Global Code - São Paulo
Operator-Less DataCenters A Near Future Reality
Operator-less DataCenters -- A Reality
Tuenti teams - Php Conference
Introduction to requirement of microservices
Ad

More from Richard Rodger (20)

PDF
Using RAG to create your own Podcast conversations.pdf
PDF
Richard_TheDev2023_pattern.pptx.pdf
PDF
richard-rodger-awssofia-microservices-2019.pdf
PDF
richardrodger-microservice-algebra-cluj-apr.pdf
PDF
richardrodger-designing-microservices-london-may.pdf
PDF
richardrodger-designing-microservices-london-may.pdf
PDF
richardrodger-microservice-risk-dublin-mar.pdf
PDF
richardrodger-service-discovery-waterford-feb.pdf
PDF
richardrodger-vespa-waterford-oct.pdf
PDF
Richardrodger designing-microservices-uxdx-dublin-oct
PDF
Richardrodger nodeconfeu-2014-final
PDF
Richardrodger nodeday-2014-final
PDF
Richard rodger technical debt - web summit 2013
PDF
The Seneca Pattern at EngineYard Distill 2013 Conference
PDF
How to Write Big Apps (Richard Rodger NodeDublin 2012)
KEY
Richard rodger-appgen-2012-lxjs-lisbon
KEY
20120802 timisoara
KEY
20120816 nodejsdublin
KEY
20120306 dublin js
KEY
20120514 nodejsdublin
Using RAG to create your own Podcast conversations.pdf
Richard_TheDev2023_pattern.pptx.pdf
richard-rodger-awssofia-microservices-2019.pdf
richardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdf
richardrodger-microservice-risk-dublin-mar.pdf
richardrodger-service-discovery-waterford-feb.pdf
richardrodger-vespa-waterford-oct.pdf
Richardrodger designing-microservices-uxdx-dublin-oct
Richardrodger nodeconfeu-2014-final
Richardrodger nodeday-2014-final
Richard rodger technical debt - web summit 2013
The Seneca Pattern at EngineYard Distill 2013 Conference
How to Write Big Apps (Richard Rodger NodeDublin 2012)
Richard rodger-appgen-2012-lxjs-lisbon
20120802 timisoara
20120816 nodejsdublin
20120306 dublin js
20120514 nodejsdublin

Recently uploaded (20)

PDF
Testing WebRTC applications at scale.pdf
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Digital Literacy And Online Safety on internet
PDF
The Internet -By the Numbers, Sri Lanka Edition
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPT
tcp ip networks nd ip layering assotred slides
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Introduction to Information and Communication Technology
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
innovation process that make everything different.pptx
Testing WebRTC applications at scale.pdf
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
PptxGenJS_Demo_Chart_20250317130215833.pptx
Digital Literacy And Online Safety on internet
The Internet -By the Numbers, Sri Lanka Edition
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
tcp ip networks nd ip layering assotred slides
522797556-Unit-2-Temperature-measurement-1-1.pptx
Introuction about ICD -10 and ICD-11 PPT.pptx
Sims 4 Historia para lo sims 4 para jugar
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Cloud-Scale Log Monitoring _ Datadog.pdf
Introuction about WHO-FIC in ICD-10.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Introduction to Information and Communication Technology
Tenda Login Guide: Access Your Router in 5 Easy Steps
An introduction to the IFRS (ISSB) Stndards.pdf
innovation process that make everything different.pptx

Richardrodger nodeday-2014-final