Top Banner
36
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Scalable Micro-services with Nodejs
Page 2: Building Scalable Micro-services with Nodejs

Node.js

Scalable Micro-Services

Page 3: Building Scalable Micro-services with Nodejs

Server side javascript

Makes it great for IO bound tasks

Single threaded

Event driven

Best for asynchronous things

Page 4: Building Scalable Micro-services with Nodejs

What do you think when you hear ‘scalable’?

Page 5: Building Scalable Micro-services with Nodejs

What do I think when I hear ‘scalable’?

Page 6: Building Scalable Micro-services with Nodejs

Will this code scale with your employees?

Page 7: Building Scalable Micro-services with Nodejs
Page 8: Building Scalable Micro-services with Nodejs

What is a Micro-Service?

Separate monolithic functionality into smaller parts.

MY AWESOME MONOLITH

git

git git gitgit

svn? git git

Design Pattern

Page 9: Building Scalable Micro-services with Nodejs

Then distribute those parts in an individually scalable fashion,

behind an API Facade.

service

API Facade

service serviceservice service serviceservice

Page 10: Building Scalable Micro-services with Nodejs

Room Available

?

Monolithic API

Payment

3rd party

3rd party

Translation

3rd party

Client request Server response

Page 11: Building Scalable Micro-services with Nodejs

Room Available?

API Facade

Payment Translation

3rd party

3rd party

3rd party

Client request Server response

Page 12: Building Scalable Micro-services with Nodejs

With a powerful pattern comes great responsibility

Page 13: Building Scalable Micro-services with Nodejs

Not everything can / should be microtized

Lower level design problems will be multiplied

across codebases

Page 14: Building Scalable Micro-services with Nodejs
Page 15: Building Scalable Micro-services with Nodejs
Page 16: Building Scalable Micro-services with Nodejs

What is the secret sauce?

Page 17: Building Scalable Micro-services with Nodejs
Page 18: Building Scalable Micro-services with Nodejs

The Pyramid Of Doom

Page 19: Building Scalable Micro-services with Nodejs
Page 20: Building Scalable Micro-services with Nodejs

How to:

DEAL WITH IT

Page 21: Building Scalable Micro-services with Nodejs

Named Functions Flatten Dat Code

Page 22: Building Scalable Micro-services with Nodejs

Async Library Also Flattens Dat Code

Page 23: Building Scalable Micro-services with Nodejs

No Asynchronous IO?

Page 24: Building Scalable Micro-services with Nodejs

.then(what the function (do) { we(do)……..

Page 25: Building Scalable Micro-services with Nodejs

• Pending

• Fulfilled

• Rejected

Page 26: Building Scalable Micro-services with Nodejs

Basic Promises

Page 27: Building Scalable Micro-services with Nodejs

Advanced Promising

Page 28: Building Scalable Micro-services with Nodejs

BONUS SLIDE

Page 29: Building Scalable Micro-services with Nodejs

Next generation

Page 30: Building Scalable Micro-services with Nodejs

Scaling your micro services?

Page 31: Building Scalable Micro-services with Nodejs

Cluster

Page 32: Building Scalable Micro-services with Nodejs
Page 33: Building Scalable Micro-services with Nodejs

pm2

Page 34: Building Scalable Micro-services with Nodejs
Page 35: Building Scalable Micro-services with Nodejs

Finding the right libraries

Q Bluebird

Page 36: Building Scalable Micro-services with Nodejs