Scalable Cloud Solutions with Node.js
Aaron Michael König & Mathias PeterTeam Centric Software
Foto: JD Hancock CC BY 2.0
Mathias Peter [email protected]
8+ years experienceJS, Redis, AWS
! mpneuried
Aaron Michael König [email protected]
10+ years experienceJS, iOS, C#
! exinferis
Team Centric Software
• Webapps & native mobile apps
• Amazon Web Services since 2007
• Redis & Node.js since 2010
Node.js since the early days
• Node.js in production since 0.4
• Developed many building blocks in 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
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
Software in a health club?
Advanced electronic fitness devices?
Foto: JD Hancock CC BY 2.0
Software in a health club?
Advanced electronic fitness devices?
WAT?
Foto: JD Hancock CC BY 2.0
Processing
Autoscale
Scaling for synchronous tasks
Load Balancer
Redis
MySQL
MySQL
S3 DynamoDB
EC2 Instances
• Logs
• Training archiving
• Training results
• Statistics
• House keeping
• Achievements
Scaling for asynchronous tasks Queueing
Advantages of Queueing
• Asynchronous Execution
• Distribution of work
• Reliability
• Guaranteed success or failure
Worker
message D
Queue
message C
message B
message Acopy
receive and …
message A
process
invisible for 30s
Queue
message D
multiple workers 👍
Worker
message Ccopymessage CWorker
message Bcopymessage B
Worker
Worker
Worker
Worker
Queue
message D
multiple workers 👍
Worker
message Ccopy
message CWorker
message Bcopymessage B
Worker
Worker
Worker
Worker
Simple & Fast
Only Redis - No management server
Guaranteed delivery to a single recipient
Visibility timeout for received messages
Design concept
rsmq.createQueue({qname:"foo", vt:30}, function(err, created){ // ... });
rsmq.sendMessage({qname:"foo", message:"bar"}, function(err){ // ...});
create
send
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.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
var RSMQWorker = require( "rsmq-worker" );var worker = new RSMQWorker( "foo" ); // poll the "foo" queueinit
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
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
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
Lightweightjust redis
No overheadtrusted environments only, no security
Fastdepends on redis
Features
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
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