SlideShare a Scribd company logo
Microservice
Architecture with
Reusable Components
Mar 30, 2018
Slides JSFest bot
Nikita
Galkin
Love and Know:
▰ How to make developers and business happy
▰ Technical and process debt elimination
Believe that:
▰ Any problem must be solved at the right level
▰ Software is easy. People are hard
▰ A problem should be highlighted, an idea should
be "sold", a solution should be demonstrated
Links:
Site GitHub Twitter Facebook
3
4
5
“Wanna do something
good, do it yourself”
Jean-Baptiste
Emanuel Zorg
(Gary Oldman)
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
7
“Almost all the successful
microservice stories have started
with a monolith that got too big and
was broken up”
from MonolithFirst
Martin Fowler
8
9
“I picked Java because I felt the most
people would be able to understand
the code examples if they were
written in Java. That was the case in
1997, but how about in 2017?
…
But I went for the alternative:
JavaScript.”
27 March 2018
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
Components
Best
Practices
Reusable Components
14
Why?
15
Don’t
Repeat
Yourself
16
What?
17
Scoped packages
Scoped packages
18
▶ npm install @zorg/zf
+ @zorg/zf@1.0.5
added 1 package in 1.727s
▶ cat ~/.npmrc
@zorg:registry=http://npm.zorg-weapon.com
19
20
First package
21
▰ @your-scope/code-style
▰ Code Style and Violence
by Anton Nemtsev
22
What is not
reusable
component?
23
“Small, autonomous
services that work
together.
24
Evolution
26
27
How?
28
Robustness
Engineered for engineers
Useful
Simple
Examples included
npm i -g how-to-npm
how-to-npm
Or
Free 1,5 hour-long video:
How to Write an Open
Source JavaScript Library
Git flow
30How to convince the team?
31
How to convince the manager?
“Wanna do
something good,
do it yourself”
Zorg
“Wanna do
something good,
do it yourself”
Zorg
“Don't use require(../../utils/logger),
use npm packages” © Galkin
Awesome Pair!
But how reuse code...
Microservices
35
How to develop
reusable
components?
▰ npx scripts
▻ eslint helper
▰ plop
▰ yeoman.io
▰ raml2html
Code, spec, docs generators
36
Generators
37
Test Driven Development
38
FAIL
PASS
TDD
REFACTORING
“Repetition of a very short
development cycle: requirements are
turned into very specific test cases,
then the software is improved to pass
the new tests, only.”
Kent Beck
Types or Documentation Driven Development
39
tsc
Add JSDoc
TDD
▰ choose typescript or JSDoc
▰ autocomplete for engineers
▰ always actual code documentation
▰ puppeteer source-code is
awesome JSDoc example
REFACTORING
/**
* @typedef {Object} CoverageEntry
* @property {string} url
* @property {string} text
* @property {!Array<!{start: number,
end: number}>} ranges
*/
Theft Driven Development
41
STEAL
ADOPT
TDD
SHARE
Reusable Components
I'll show you my
package.json
during speaker
corner
44
Where?
Source code
storage
CI for
build and test
Artifact
storage
Git flow
46
Gitflow
Git flow
47
Gitflow
Github Flow
Monorepo with Lerna
Or one repo for one component?
Your DevOps Engineer: @#_$!
Your DevOps Engineer: @#_$!
12factor.net
“II. Dependencies
Explicitly declare and
isolate dependencies
54
“III. Config
Store config in the
environment
55
“V. Build, release, run
Strictly separate build and
run stages
56
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
“VI. Processes
Execute the app as one or
more stateless processes
58
“XI. Logs
Treat logs as event
streams
59
stdout stderr
61
How to develop
microservices?
MonolithFirst
How your system works?
ECB is a variant of Model/View/Controller (MVC). It
was published by Ivar Jacobson (Ericsson Co.) in
the 80's with a focus on separating responsibilities
of elements in Object Oriented Systems.
Boundary – objects that interface with system
actors (e.g. a user or external service). Side
effected.
Boundary component should be reusable.
EBC Pattern – Boundary
65
Boundary place for validation
▰ Wrapper for Enterprise Bus
▰ File Storage wrapper
(S3/Local FileSystem)
▰ JSON RPC with different
transports
Possible Boundaries Components
67
Control – objects that implement business
logic. This code has the main value for
business.
This part of every microservice is unique.
EBC Pattern – Control
68
Control – just control.
Entity – objects representing system data,
often from the domain model. In our
application we use an entity also for
transforming data from one format to another.
For example, from XML to JSON.
Entity can be shared between applications as
interfaces or components.
EBC Pattern – Entity
70
Entity for data transform
microservices base application with:
▰ Base boundary class
▰ App class with start stop
▰ Default logger
▰ Hooks
Basement
72
1. Only Boundary provide services for the
"other world".
2. Boundary can call only to Control.
3. Control can call anybody.
4. Entity can't call anybody (!), only be called.
EBC Pattern
73
74
Why does it matter?
Bootstrapping and Graceful
shutdown
Interface Microservice {
void start();
void stop();
}
Microservice interface
76
Bootstrapping
1. Attach uncaught exception hooks.
2. Log start of bootstrapping.
3. Verify configuration.
4. Init boundaries and controls.
5. Attach shutdown hooks.
6. Log finish of bootstrapping.
Bootstrapping
78
Graceful Shutdown
For graceful shutdown application should:
1. Log start of graceful shutdown.
2. Close incoming boundaries. For example,
stop accepting new tasks for processing
from queue, stop handling new incoming
http requests, etc.
Graceful shutdown
80
3. Set a forced timeout for completion current
tasks or save them for future processing.
Recommended value for this timeout is not
more then 5 second.
4. Notify consumers about shutdown. For
example, send heartbeat-shutdown.
Graceful shutdown
81
5. Correctly disconnect from all connections.
For example, database, RabbitMQ, Redis,
etc.
6. Log finish of graceful shutdown and stop
the process.
Graceful shutdown
82
83Let’s summarize!
▰ Reusable Components
▰ Monolith First
▰ The Twelve Factors
▰ EСB (Entity, Boundary, Control) Pattern
▰ Bootstrapping and Graceful shutdown
Microservice Best Practises
84
85
Robustness
Engineered for engineers
Useful
Simple
Examples included
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами
89
Thank you for attention!
Be consistent in your
microservices!!!
You can find me on Twitter as @galk_in
Slides are available at speakerdeck.com/galkin
or on my site galk.in
Slides JSFest bot
▰ koa
▰ bunyan
▰ dotenv-safe
▰ gatsbyjs
▰ rxjs
My favorite packages
91
▰ pre-commit
▰ eslint
▰ jest
▰ raml-cli
▰ dredd

More Related Content

What's hot (20)

PDF
Pattern-Based Debugging of Declarative Models
Vajih Montaghami
 
PDF
Debugging and Profiling C++ Template Metaprograms
Platonov Sergey
 
PDF
JavaScript for Web Analysts
Lukáš Čech
 
PDF
Metaprogramming
Mehmet Emin İNAÇ
 
PDF
Dove sono i tuoi vertici e di cosa stanno parlando?
Codemotion
 
PDF
С++ without new and delete
Platonov Sergey
 
PDF
Task Parallel Library (TPL)
Muhammad Zaid Sarfraz
 
PDF
AST Transformations: Groovy’s best kept secret by Andres Almiray
ZeroTurnaround
 
PDF
Garbage collection
Seemal Afza
 
PDF
Of complicacy of programming, or won't C# save us?
PVS-Studio
 
PDF
A quick and fast intro to Kotlin
XPeppers
 
PPT
Groovy AST Demystified
Andres Almiray
 
PDF
Missing objects: ?. and ?? in JavaScript (BrazilJS 2018)
Igalia
 
PPTX
Annotation processor and compiler plugin
Oleksandr Radchykov
 
PDF
Code quality par Simone Civetta
CocoaHeads France
 
PDF
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Codemotion
 
PDF
C++ Tail Recursion Using 64-bit variables
PVS-Studio
 
PDF
Categories for the Working C++ Programmer
Platonov Sergey
 
PDF
Why Java Sucks and C# Rocks (Final)
jeffz
 
PPTX
Typescript tips & tricks
Ori Calvo
 
Pattern-Based Debugging of Declarative Models
Vajih Montaghami
 
Debugging and Profiling C++ Template Metaprograms
Platonov Sergey
 
JavaScript for Web Analysts
Lukáš Čech
 
Metaprogramming
Mehmet Emin İNAÇ
 
Dove sono i tuoi vertici e di cosa stanno parlando?
Codemotion
 
С++ without new and delete
Platonov Sergey
 
Task Parallel Library (TPL)
Muhammad Zaid Sarfraz
 
AST Transformations: Groovy’s best kept secret by Andres Almiray
ZeroTurnaround
 
Garbage collection
Seemal Afza
 
Of complicacy of programming, or won't C# save us?
PVS-Studio
 
A quick and fast intro to Kotlin
XPeppers
 
Groovy AST Demystified
Andres Almiray
 
Missing objects: ?. and ?? in JavaScript (BrazilJS 2018)
Igalia
 
Annotation processor and compiler plugin
Oleksandr Radchykov
 
Code quality par Simone Civetta
CocoaHeads France
 
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Codemotion
 
C++ Tail Recursion Using 64-bit variables
PVS-Studio
 
Categories for the Working C++ Programmer
Platonov Sergey
 
Why Java Sucks and C# Rocks (Final)
jeffz
 
Typescript tips & tricks
Ori Calvo
 

Similar to JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами (20)

PDF
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Derek Ashmore
 
PDF
Microservices for java architects schamburg-2015-05-19
Derek Ashmore
 
PPTX
Architecting Microservices in .Net
Richard Banks
 
PDF
Microservices for Java Architects (Chicago, April 21, 2015)
Derek Ashmore
 
PDF
Microservices for java architects coders-conf-2015-05-15
Derek Ashmore
 
PDF
Stay productive while slicing up the monolith
Markus Eisele
 
PDF
Stay productive while slicing up the monolith
Markus Eisele
 
PDF
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
PDF
Microservices for Java Architects (Indianapolis, April 15, 2015)
Derek Ashmore
 
PPTX
Microservices architecture
Faren faren
 
PDF
Will Microservices Die.pdf
RichHagarty
 
PDF
Microservices Architecture
Izzet Mustafaiev
 
PPTX
Service Mesh CTO Forum (Draft 3)
Rick Hightower
 
PDF
Microservices for Architects - Atlanta 2018-03-28
Derek Ashmore
 
PPTX
Introduction to microservices
Anil Allewar
 
PDF
Microservice pitfalls
Mite Mitreski
 
PDF
Writing microservices in Java -- Chicago-2015-11-10
Derek Ashmore
 
PPTX
Pragmatic Approach to Microservices and Cell-based Architecture
Andrew Blades
 
PDF
Writing microservices in java java one-2015-10-28
Derek Ashmore
 
PPTX
Software Architectures, Week 3 - Microservice-based Architectures
Angelos Kapsimanis
 
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Derek Ashmore
 
Microservices for java architects schamburg-2015-05-19
Derek Ashmore
 
Architecting Microservices in .Net
Richard Banks
 
Microservices for Java Architects (Chicago, April 21, 2015)
Derek Ashmore
 
Microservices for java architects coders-conf-2015-05-15
Derek Ashmore
 
Stay productive while slicing up the monolith
Markus Eisele
 
Stay productive while slicing up the monolith
Markus Eisele
 
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
Microservices for Java Architects (Indianapolis, April 15, 2015)
Derek Ashmore
 
Microservices architecture
Faren faren
 
Will Microservices Die.pdf
RichHagarty
 
Microservices Architecture
Izzet Mustafaiev
 
Service Mesh CTO Forum (Draft 3)
Rick Hightower
 
Microservices for Architects - Atlanta 2018-03-28
Derek Ashmore
 
Introduction to microservices
Anil Allewar
 
Microservice pitfalls
Mite Mitreski
 
Writing microservices in Java -- Chicago-2015-11-10
Derek Ashmore
 
Pragmatic Approach to Microservices and Cell-based Architecture
Andrew Blades
 
Writing microservices in java java one-2015-10-28
Derek Ashmore
 
Software Architectures, Week 3 - Microservice-based Architectures
Angelos Kapsimanis
 
Ad

More from JSFestUA (20)

PDF
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JSFestUA
 
PDF
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JSFestUA
 
PDF
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JSFestUA
 
PDF
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JSFestUA
 
PDF
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JSFestUA
 
PDF
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Александр Товмач. JAMstack
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JSFestUA
 
PDF
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JSFestUA
 
PDF
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JSFestUA
 
PDF
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JSFestUA
 
PPTX
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JSFestUA
 
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JSFestUA
 
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JSFestUA
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JSFestUA
 
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JSFestUA
 
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JSFestUA
 
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JSFestUA
 
JS Fest 2019/Autumn. Александр Товмач. JAMstack
JSFestUA
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JSFestUA
 
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JSFestUA
 
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JSFestUA
 
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JSFestUA
 
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JSFestUA
 
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JSFestUA
 
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JSFestUA
 
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JSFestUA
 
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JSFestUA
 
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JSFestUA
 
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JSFestUA
 
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JSFestUA
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JSFestUA
 
Ad

Recently uploaded (20)

PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 

JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми компонентами