Top Banner
Scalable Cloud Solutions with Node.js Aaron Michael König & Mathias Peter Team Centric Software Foto: JD Hancock CC BY 2.0
74
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: Scalable Cloud Solutions with Node.js

Scalable Cloud Solutions with Node.js

Aaron Michael König & Mathias PeterTeam Centric Software

Foto: JD Hancock CC BY 2.0

Page 2: Scalable Cloud Solutions with Node.js

Mathias Peter [email protected]

8+ years experienceJS, Redis, AWS

! mpneuried

Aaron Michael König [email protected]

10+ years experienceJS, iOS, C#

! exinferis

Page 3: Scalable Cloud Solutions with Node.js

Team Centric Software

• Webapps & native mobile apps

• Amazon Web Services since 2007

• Redis & Node.js since 2010

Page 4: Scalable Cloud Solutions with Node.js

Node.js since the early days

Page 5: Scalable Cloud Solutions with Node.js

Node.js since the early days

• Node.js in production since 0.4

Page 6: Scalable Cloud Solutions with Node.js

Node.js since the early days

• Node.js in production since 0.4

• Developed many building blocks in Node.js

Page 7: Scalable Cloud Solutions with Node.js

Node.js since the early days

• Node.js in production since 0.4

• Developed many building blocks in Node.js

• Many microservices on Node.js

Page 8: Scalable Cloud Solutions with Node.js

Node.js since the early days

• Node.js in production since 0.4

• Developed many building blocks in Node.js

• Many microservices on Node.js

• Released quite a few open source modules over the years

Page 9: Scalable Cloud Solutions with Node.js
Page 10: Scalable Cloud Solutions with Node.js

Node.js in customer projects

Page 11: Scalable Cloud Solutions with Node.js

Cloud based setup.Electronic fitness devices.

Page 12: Scalable Cloud Solutions with Node.js

Software in a health club?

Advanced electronic fitness devices?

Foto: JD Hancock CC BY 2.0

Page 13: Scalable Cloud Solutions with Node.js

Software in a health club?

Advanced electronic fitness devices?

WAT?

Foto: JD Hancock CC BY 2.0

Page 14: Scalable Cloud Solutions with Node.js

Training the “old way”

Page 15: Scalable Cloud Solutions with Node.js

Training plan

Training the “old way”

Page 16: Scalable Cloud Solutions with Node.js

Training plan

Training the “old way”

Page 17: Scalable Cloud Solutions with Node.js

Training plan Training plan

Training the “old way”

Page 18: Scalable Cloud Solutions with Node.js

Training the “milon way”

Page 19: Scalable Cloud Solutions with Node.js

Training the “milon way”

Page 20: Scalable Cloud Solutions with Node.js

☁️

Training the “milon way”

Training plan

Page 21: Scalable Cloud Solutions with Node.js

☁️

Training the “milon way”

Training plan

Page 22: Scalable Cloud Solutions with Node.js

milon care device logins

Page 23: Scalable Cloud Solutions with Node.js

Scalability

Foto: JD Hancock CC BY 2.0

Page 24: Scalable Cloud Solutions with Node.js

Bilder?

Asynchronous TasksSynchronous Tasks

Foto: JD Hancock CC BY 2.0

Page 25: Scalable Cloud Solutions with Node.js

Scaling for synchronous tasks

• more servers

• better hardware

• storage

• Autoscaling

Page 26: Scalable Cloud Solutions with Node.js

Scaling for synchronous tasks

Load Balancer

Redis

MySQL

MySQL

S3 DynamoDB

EC2 Instances

Page 27: Scalable Cloud Solutions with Node.js

Scaling for synchronous tasks

Load Balancer

Redis

MySQL

MySQL

S3 DynamoDB

EC2 Instances

Page 28: Scalable Cloud Solutions with Node.js

Autoscale

Scaling for synchronous tasks

Load Balancer

Redis

MySQL

MySQL

S3 DynamoDB

EC2 Instances

Page 29: Scalable Cloud Solutions with Node.js

Processing

Autoscale

Scaling for synchronous tasks

Load Balancer

Redis

MySQL

MySQL

S3 DynamoDB

EC2 Instances

Page 30: Scalable Cloud Solutions with Node.js

Scaling for asynchronous tasks Queueing

Page 31: Scalable Cloud Solutions with Node.js

• Logs

• Training archiving

• Training results

• Statistics

• House keeping

• Achievements

Scaling for asynchronous tasks Queueing

Page 32: Scalable Cloud Solutions with Node.js

Advantages of Queueing

Page 33: Scalable Cloud Solutions with Node.js

Advantages of Queueing

• Asynchronous Execution

• Distribution of work

• Reliability

• Guaranteed success or failure

Page 34: Scalable Cloud Solutions with Node.js

Queueing… or how a queue should work

Foto: JD Hancock CC BY 2.0

Page 35: Scalable Cloud Solutions with Node.js
Page 36: Scalable Cloud Solutions with Node.js

Queue

create queue

Page 37: Scalable Cloud Solutions with Node.js

message D

Queue

message C

message B

message A

create queueadd messages …

Page 38: Scalable Cloud Solutions with Node.js

message D

Queue

message C

message B

message A

create queueadd messages …

Worker

create a worker

Page 39: Scalable Cloud Solutions with Node.js

Worker

message D

Queue

message C

message B

message Acopy

receive and …

message A

Page 40: Scalable Cloud Solutions with Node.js

Worker

message D

Queue

message C

message B

message Acopy

receive and …

message A

process

invisible for 30s

Page 41: Scalable Cloud Solutions with Node.js

Worker

message D

Queue

message C

message B

delete on success

message A message Acopy

Page 42: Scalable Cloud Solutions with Node.js

Worker

message D

Queue

message C

message B

delete on success

Page 43: Scalable Cloud Solutions with Node.js

Worker

Queue

message D

message C

message Bcopy

receive and …

message B

Page 44: Scalable Cloud Solutions with Node.js

Worker

Queue

message D

message C

message Bcopy

receive and …

message B

process

invisible for 30s

Page 45: Scalable Cloud Solutions with Node.js

Worker

Queue

message D

message C

message B message Bcopy

Page 46: Scalable Cloud Solutions with Node.js

Worker

Queue

message D

message C

💩 ERROR !

message B

Worker

message Bcopy

Page 47: Scalable Cloud Solutions with Node.js

Worker

Queue

message D

message C

message B

… remain within stack

Page 48: Scalable Cloud Solutions with Node.js

Wait … SCALING !

Foto: JD Hancock CC BY 2.0

Page 49: Scalable Cloud Solutions with Node.js

Queue

message D

multiple workers 👍

Worker

message Ccopymessage CWorker

message Bcopymessage B

Worker

Worker

Worker

Worker

Page 50: Scalable Cloud Solutions with Node.js

Queue

message D

multiple workers 👍

Worker

message Ccopy

message CWorker

message Bcopymessage B

Worker

Worker

Worker

Worker

Page 51: Scalable Cloud Solutions with Node.js

Redis Simple Message Queue

RSMQ made by

npm install rsmq

Page 52: Scalable Cloud Solutions with Node.js

Design concept

Page 53: Scalable Cloud Solutions with Node.js

Simple & Fast

Only Redis - No management server

Guaranteed delivery to a single recipient

Visibility timeout for received messages

Design concept

Page 54: Scalable Cloud Solutions with Node.js

How to …

Foto: JD Hancock CC BY 2.0

Page 55: Scalable Cloud Solutions with Node.js
Page 56: Scalable Cloud Solutions with Node.js

rsmq.createQueue({qname:"foo", vt:30}, function(err, created){ // ... });create

Page 57: Scalable Cloud Solutions with Node.js

rsmq.createQueue({qname:"foo", vt:30}, function(err, created){ // ... });

rsmq.sendMessage({qname:"foo", message:"bar"}, function(err){ // ...});

create

send

Page 58: Scalable Cloud Solutions with Node.js

rsmq.createQueue({qname:"foo", vt:30}, function(err, created){ // ... });

rsmq.sendMessage({qname:"foo", message:"bar"}, function(err){ // ...});

rsmq.receiveMessage({qname:"foo"}, function(err, message){ // ... { id: "42abc", message: "bar", rc: 1, ... } });

create

send

receive

Page 59: Scalable Cloud Solutions with Node.js

rsmq.createQueue({qname:"foo", vt:30}, function(err, created){ // ... });

rsmq.sendMessage({qname:"foo", message:"bar"}, function(err){ // ...});

rsmq.receiveMessage({qname:"foo"}, function(err, message){ // ... { id: "42abc", message: "bar", rc: 1, ... } });

create

send

receive

rsmq.deleteMessage({qname:"foo", id: msgid}, function(err, success){ // ...});

delete

Page 60: Scalable Cloud Solutions with Node.js

Foto: JD Hancock CC BY 2.0

Page 61: Scalable Cloud Solutions with Node.js

Foto: JD Hancock CC BY 2.0

npm install rsmq-worker

Page 62: Scalable Cloud Solutions with Node.js

How to …

Foto: JD Hancock CC by 2.0

Page 63: Scalable Cloud Solutions with Node.js
Page 64: Scalable Cloud Solutions with Node.js

var RSMQWorker = require( "rsmq-worker" );var worker = new RSMQWorker( "foo" ); // poll the "foo" queueinit

Page 65: Scalable Cloud Solutions with Node.js

var RSMQWorker = require( "rsmq-worker" );var worker = new RSMQWorker( "foo" ); // poll the "foo" queue

worker.on("message", function(message, next, msgid){ // ... processing next(); // on error use: next( err );});

init

listen

Page 66: Scalable Cloud Solutions with Node.js

var RSMQWorker = require( "rsmq-worker" );var worker = new RSMQWorker( "foo" ); // poll the "foo" queue

worker.on("message", function(message, next, msgid){ // ... processing next(); // on error use: next( err );});

worker.start();

init

listen

start

Page 67: Scalable Cloud Solutions with Node.js

var RSMQWorker = require( "rsmq-worker" );var worker = new RSMQWorker( "foo" ); // poll the "foo" queue

worker.on("message", function(message, next, msgid){ // ... processing next(); // on error use: next( err );});

worker.start();

init

listen

start

worker.send(„bar"); // send to "foo"send

Page 68: Scalable Cloud Solutions with Node.js

DEMO

Foto: JD Hancock CC by 2.0

Page 69: Scalable Cloud Solutions with Node.js

Demo results

1x worker.js 4x worker.jsperformance

> 250%

Page 70: Scalable Cloud Solutions with Node.js

Lightweightjust redis

No overheadtrusted environments only, no security

Fastdepends on redis

Features

Page 71: Scalable Cloud Solutions with Node.js

Want more?

Terminal Client

RSMQrest-interface

REST Interface

For PHP, ASP, Curl …

rsmq-cli (under dev.)

RSMQcli

Monitoring

Usage charts

rsmq-monitor (planned)

RSMQmonitor

Notification Engine

Email Buffer

Page 72: Scalable Cloud Solutions with Node.js

Questions?

Foto: JD Hancock CC by 2.0

Team Centric Software: http://www.tcs.de/

RSMQ: ! http://smrchy.github.io/rsmq/

RSMQ-worker: ! https://github.com/mpneuried/rsmq-worker

Demo-Source: ! https://github.com/mpneuried/rsmq-mnug-demo

Images: Thanks to JD Hancock for providing CC licensed images

Credits

Page 73: Scalable Cloud Solutions with Node.js
Page 74: Scalable Cloud Solutions with Node.js

RabbitMQmanagement server

Kuetoo complex and not lightweight

SQSonly AWS, higher latency

Redis-Listwe need more than that

Why not use …?