Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)
-
Upload
agile-lietuva -
Category
Education
-
view
26 -
download
1
Transcript of Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)
![Page 1: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/1.jpg)
Decomposing
distributed monolith with
Node.jsVilius, Software Engineer
linkedin/viliusl github.com/viliusl@[email protected]
![Page 2: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/2.jpg)
Decomposing
distributed monolith with
Node.jsVilius, Sofware Engineer
linkedin/viliusl github.com/viliusl@[email protected]
Stack of your
choice
![Page 3: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/3.jpg)
Hi. I am Vilius
Lithuania
Ukraine
Vilnius
Kyiv
Dnipro
Wix Engineering Locations
Israel
Tel-Aviv
Be’er Sheva
![Page 4: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/4.jpg)
Hi. I am Vilius
Lithuania
Vilnius
Wix Engineering Locations
![Page 5: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/5.jpg)
AGENDA
Microservices and Distributed Monolith
(DM)
Why am I talking about DM in first place?
Short history and joys of adding 2nd stack
Decomposing Distributed Monolith
![Page 6: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/6.jpg)
“Microservice architectural style is an
approach to developing a single
application as a suite of small services,
each running in its own process and
communicating with lightweight
mechanisms, often an HTTP resource
API”
Martin Fowler
![Page 7: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/7.jpg)
What is a
distributed
monolith
01
![Page 8: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/8.jpg)
A form of a binary coupling, when in
order to interact and coexist in a
given system you are required to
use a set of “official” libraries.
![Page 9: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/9.jpg)
Client library becomes “Only” official
way to access the service
![Page 10: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/10.jpg)
What’s wrong with it?
![Page 11: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/11.jpg)
Nearly impossible to adopt new
architectures, languages, etc.
![Page 12: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/12.jpg)
But hey, DRY, code reuse - it’s good
right?
![Page 13: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/13.jpg)
“The evils of too much coupling
between services are far worse than
the problems caused by code
duplication”
Sam Newman, Building
Microservices
![Page 14: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/14.jpg)
You potentially lose
polyglot;
organizational/technical decoupling;
temporal decoupling;
![Page 15: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/15.jpg)
Ok, so what is an alternative?
![Page 16: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/16.jpg)
Contracts and protocols!
![Page 17: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/17.jpg)
Yeah, but central logging, distributed
tracing, context passing….
![Page 18: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/18.jpg)
You don’t need binary coupling
Standardization via protocols and contracts and independent libraries
Compliancy/contract tests
![Page 19: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/19.jpg)
Why am I talking about
Distributed Monolith in the first
place?
02
![Page 20: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/20.jpg)
Let’s answer to 2 following questions
honestly
![Page 21: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/21.jpg)
Does it take months to upgrade a
library across company?
![Page 22: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/22.jpg)
Does it take months to upgrade a
library across company?
![Page 23: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/23.jpg)
Does it take ~ a year to introduce a
new stack?
![Page 24: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/24.jpg)
Introducing a Node.js stack @
Wix
03
![Page 25: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/25.jpg)
“Target or this project is to enable
coding front-end servers in Wix using
Node.js. We are aiming at the
pattern of front-end servers and
service-servers – a pattern that is
used in different companies”
Yoav Abrahami
![Page 26: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/26.jpg)
![Page 27: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/27.jpg)
![Page 28: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/28.jpg)
![Page 29: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/29.jpg)
Does not look too hard right?
![Page 30: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/30.jpg)
![Page 31: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/31.jpg)
![Page 32: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/32.jpg)
But wait, there is more…
![Page 33: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/33.jpg)
![Page 34: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/34.jpg)
![Page 35: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/35.jpg)
Oh, and ops contracts…
![Page 36: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/36.jpg)
![Page 37: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/37.jpg)
But not all is gloom and doom
![Page 38: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/38.jpg)
Build/Deploy pipeline* already had
support/extensions for non-official
stack
*lifecycle, fryingpan, teamcity
![Page 39: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/39.jpg)
Contract for deploying application
was defined, sane, simple*
*https://kb.wixpress.com/display/system/Docker+image+deployment+requirement
![Page 40: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/40.jpg)
Contract for configuration was clear
and defined*
* https://kb.wixpress.com/display/chef/Wix+Artifact+Config+Templates
![Page 41: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/41.jpg)
Underlying protocols were
standardized, business services as
proper microservices
![Page 42: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/42.jpg)
Decomposing Distributed
Monolith
04
![Page 43: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/43.jpg)
There were never a goal to
decompose, fix, re-architect existing
stack
![Page 44: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/44.jpg)
The goal was to introduce new one
to be leaner, be faster, make us go
faster
![Page 45: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/45.jpg)
Decomposition is just a side-effect if
you want to actually be leaner, go
faster
![Page 46: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/46.jpg)
Step #1 – just do it!
![Page 47: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/47.jpg)
// todo - talk to Vilius about that
var url = req => req.protocol + '://' + req.get('host') + req.originalUrl;
// todo - add petri enricher
return new WixRpcClientSupport(
reqContext.get(wixRequestContext),
rpcSigner.get(options.rpcSigningKey),
wixSessionEnricher.get(wixSession),
biEnricher.get(wixBi)
);
module.exports.addTo = app => {
app.get('/health/is_alive', (req, res) => res.send('Alive'));
};
Some TODOs
![Page 48: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/48.jpg)
Proxy APIs for fat clients
![Page 49: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/49.jpg)
Cover bare-minimum to run in
production
![Page 50: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/50.jpg)
Step #2 – we got noticed!
![Page 51: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/51.jpg)
![Page 52: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/52.jpg)
const {expect} = require('chai'),
testkit = require('./support/testkit'),
http = require('wnp-http-test-client'),
jvmTestkit = require('wix-jvm-bootstrap-testkit');
describe('petri client', function () {
const app = testkit.server('petri').beforeAndAfter();
const jvmTestkit = jvmTestkit.server({
artifact: {
groupId: 'com.wixpress.node',
artifactId: 'wix-spjs-test-server'
}
}).beforeAndAfter();
it('should conduct AB test', () =>
givenABTest('scope', 'anExperiment')
.then(() => conductExperiment('anExperiment'))
.then(res => expect(res).to.equal('true'))
);
//...
});
Test-kits based off
of a core platform
RPC
Petri
Session
![Page 53: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/53.jpg)
Step #3 – time to get serious –
compliancy tests are born.
![Page 54: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/54.jpg)
Platform agnostic
![Page 55: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/55.jpg)
trait HealthProtocol extends BaseHealthSpec with HealthDriverSupport {
"health monitoring - protocol" >> {
"/health/is_alive responds with failure" >> {
healthTestDependency.becomeUnavailable()
eventually {
queryIsAliveAPI must beUnavailable
}
}
"/health/is_alive responds with success" >> {
healthTestDependency.becomeAvailable()
eventually {
queryIsAliveAPI must beSuccessfulWith("Alive")
}
}
"health tests executed with three retries" >> {
stabilizeInHealthyState()
healthTestDependency.becomeFlaky(consecutiveFailures = 1)
holds(samples = 100, sleep = 50.milliseconds) {
queryIsAliveAPI must beSuccessful
}
}
Generic tests
Using testkits;
Platform-agnostic.
![Page 56: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/56.jpg)
class NodeComplianceE2E extends BaseComplianceE2E
with HealthAll
with SecurityAll
with I18nAll
with PetriAll
with BiAll
with WebAll
with NodeMetricKeys
with NodeBiKeys
with RpcAll {
LogbackTestHelper.initLogger()
override protected def systemUnderTest: MainService =
new LocalNodeService
}
Easy to add another
stack
App with exposed
APIs
Adapters
Runner
![Page 57: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/57.jpg)
What is a contract and what is not?
![Page 58: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/58.jpg)
Isn’t it like… monolithic?
![Page 59: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/59.jpg)
![Page 60: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/60.jpg)
We are at the junction
![Page 61: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/61.jpg)
Proxy
![Page 62: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/62.jpg)
API’s and compliance
![Page 63: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/63.jpg)
So that we could pass a Litmus test
![Page 64: Vilius Lukošius - Decomposing distributed monolith with Node.js (WIX.com)](https://reader030.fdocuments.net/reader030/viewer/2022020314/5a674d727f8b9a453d8b5b4d/html5/thumbnails/64.jpg)
“can I actually take a team of
engineers who are interested in X
becoming a legit thing in my service
and actually build something without
convincing the rest of the company?”
Ben Christensen,