SlideShare a Scribd company logo
1 of 44
Download to read offline
Microservices
with Node.js and Apache Cassandra
1
Jorge Bay Gondra
@jorgebg
Software Engineer, Drivers team at DataStax
© 2015 DataStax, All Rights Reserved. Company Confidential
Topics
1- Microservices
2- Why Node.js and Cassandra
3- The Node.js driver
4- Putting it all together: killr-service
2
1- Microservices
3
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
Defining microservices
4
- Service as software component
- 1 service per process
- Different data storage per service
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
From monolithic server architecture
5
- Single process contains all the logic
- Simple to develop
- Simple to deploy
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
From monolithic server architecture
6
- Large code bases
- Hard add new features
- Hard to train new developers
- Long term technology commitment
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
Why Microservices
7
- Codebase <---> teams
- Independently deployable: Versioning
- Fault isolation
- Best technology for the job
- Long lived systems, short lived services
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
But some things get harder
8
- Inter-service communication
- Deployment
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
9
Monolithic architecture
UI
Services
Data Access
Browser Monolithic Application Relational database
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
10
Monolithic architecture
Store UI Order UI Customer UI
Catalog Svc Order Svc Customer Svc
Product DA Order DA Customer DA
Browser Monolithic Application Relational database
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
11
Microservices architecture
Browser Front end Services Data storage
Order
Product
Customer
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
12
Inter-service communication
Products
Orders
Message Broker
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
Inter-service communication
13
- Event based
- Async
- Start simple
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
14
Microservices architecture
Browser Front end Services Data storage
Order
Product
Customer
Message broker
© 2015 DataStax, All Rights Reserved. Company Confidential
1- Microservices
Recap
15
- Service as component
- Deploy / Versioning
- Own your data
2- Node.js + Cassandra
16
© 2015 DataStax, All Rights Reserved. Company Confidential
2- Why Node.js and Cassandra
Node.js
17
- Single paradigm: async IO / event loop
- Minimum overhead per connection
- Predictable amount of memory usage under load
© 2015 DataStax, All Rights Reserved. Company Confidential
2- Why Node.js and Cassandra
Cassandra
18
- Tunable consistency
- No master / slave
- Fault tolerant
3- The Node.js Driver
for Apache Cassandra
19
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Features
20
- Automatic failover
- Node discovery
- Tunable policies
- Request pipelining
- TLS
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Automatic failover
21
Client 1
DC 1
DC 2
Requests
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Node discovery
22
Client
DC 1
Request
Events
Response
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Tunable policies
23
- Load balancing
- Retry
- Reconnection
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Load balancing policy sample
24
function BlackListPolicy(blackListedHost, childPolicy) {
this.blackListedHost = blackListedHost;
this.childPolicy = childPolicy;
}
util.inherits(BlackListPolicy, LoadBalancingPolicy);
BlackListPolicy.prototype.newQueryPlan = function (keyspace, queryOptions, callback) {
this.childPolicy.newQueryPlan(keyspace, queryOptions, function (err, iterator) {
callback(err, filter(iterator));
});
};
function *filter () {/**/}
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Ecmascript 6
25
- Load balancing policies: generators
- Encoding / decoding: ES6 Map / Set
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Request pipelining
26
Client
Sending first request
(1)
Cassandra Node
time
Received first response
(2)
© 2015 DataStax, All Rights Reserved. Company Confidential
3- The Node.js Driver for Cassandra
Recap
27
- Failover built-in
- Connection pooling
- Defaults
4- Putting it all together
Demo: Microservices with
Node.js and Cassandra Demo
28
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Functionality
29
- Video Comments
- Video Ratings
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Schema
30
CREATE TABLE comments_by_video (
videoid uuid,
commentid timeuuid,
userid uuid,
comment text,
PRIMARY KEY (videoid, commentid))
WITH CLUSTERING
ORDER BY (commentid DESC);
CREATE TABLE comments_by_user (
userid uuid,
commentid timeuuid,
videoid uuid,
comment text,
PRIMARY KEY (userid, commentid))
WITH CLUSTERING
ORDER BY (commentid DESC);
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Schema
31
CREATE TABLE video_rating (
videoid uuid,
rating_counter counter,
rating_total counter,
PRIMARY KEY (videoid));
CREATE TABLE video_ratings_by_user (
videoid uuid,
userid uuid,
rating int,
PRIMARY KEY (videoid, userid));
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Service methods
32
- GET comments by video
- POST comment
- GET rating by video
- POST rating
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
GET comments by video
33
var cassandra = require('cassandra-driver');
var client = new cassandra.Client({ contactPoints: ['localhost']});
var query = 'SELECT videoid, commentid, userid, comment FROM comments_by_video WHERE videoid = ?';
app.get('/v1/comments/:videoId([a-f0-9-]{36})', function (req, res, next) {
client.execute(query, [req.params.videoId], { prepare: true }, function (err, result) {
if (err) return next(err);
res.json(result.rows);
});
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
GET comments by video
34
var repository = new Repository(client);
//...
app.get('/v1/comment/:videoId([a-f0-9-]{36})', function (req, res, next) {
repository.getCommentsByVideo(req.params.videoId, function (err, comments) {
if (err) return next(err);
res.json(comments);
});
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
POST comment
35
app.post('/v1/comment/:videoId([a-f0-9-]{36})', function (req, res, next) {
repository.insertComment(req.params.videoId, req.body.userId, req.body.comment, (err, id) {
if (err) return next(err);
res.send(id.toString());
});
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Repository: Insert comment
36
Repository.prototype.insertComment = function (videoId, userId, comment, callback) {
var commentId = cassandra.types.TimeUuid.now();
var queries = [
{ query: 'INSERT INTO comments_by_video (videoid, commentid, userid, comment) VALUES (?, ?, ?, ?)',
params: [videoId, commentId, userId, comment]},
{ query: 'INSERT INTO comments_by_user (userid, commentid, videoid, comment) VALUES (?, ?, ?, ?)',
params: [userId, commentId, videoId, comment]}];
this.client.batch(queries, { prepare: true }, callback);
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Repository: Insert comment
37
Repository.prototype.insertComment = function (videoId, userId, comment, callback) {
var commentId = cassandra.types.TimeUuid.now();
var queries = [/*...*/];
var bus = this.bus;
this.client.batch(queries, { prepare: true }, function (err) {
if (!err) {
bus.publishNewComment(videoId, commentId, userId, comment);
}
callback(err, commentId);
});
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Message broker client
38
function Bus() {
}
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Message broker client
39
function Bus() {
}
Bus.prototype.publishNewComment = function (videoId, /*...*/) {
//Insert magic here
};
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Message broker client
40
function Bus() {
events.EventEmitter.call(this);
var self = this;
serverLib.on('whatever.topic.event.name', function (data) {
self.emit('whatever-client-name', data);
});
}
util.inherits(Bus, events.EventEmitter);
Bus.prototype.publishNewComment = function () {/*...*/};
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Seneca sample: GET comments
41
seneca.add( {role: 'comment', cmd: 'get'}, function (args, done) {
repository.getCommentsByVideo(args.id, done);
});
© 2015 DataStax, All Rights Reserved. Company Confidential
4- Microservices Demo
Recap
42
- 3 classes
- ~150 LoC
- Boundaries
© 2015 DataStax, All Rights Reserved. Company Confidential
Thanks
@jorgebg
github.com/jorgebay/killr-service
datastax.com/dev/blog
bit.ly/nodejs-cassandra-user
43
© 2015 DataStax, All Rights Reserved. Company Confidential
Thanks
Further reading
- Sample project: killr-service
- Presentation: Implementing Micro-Service Architecture by Fred George
- Book: Building Microservices By Sam Newman (O'Reilly)
- Article: Microservices Architecture By James Lewis and Martin Fowler
44

More Related Content

What's hot

Hadoop Security Architecture
Hadoop Security ArchitectureHadoop Security Architecture
Hadoop Security ArchitectureOwen O'Malley
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Ludovico Caldara
 
Always on in sql server 2017
Always on in sql server 2017Always on in sql server 2017
Always on in sql server 2017Gianluca Hotz
 
Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Stefan Oehrli
 
Ambari: Agent Registration Flow
Ambari: Agent Registration FlowAmbari: Agent Registration Flow
Ambari: Agent Registration FlowHortonworks
 
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and AdministerAndrejs Karpovs
 
Oracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionOracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionAlex Gorbachev
 
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best PracticesOracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best PracticesMarkus Michalewicz
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesEberhard Wolff
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databasesAshwani Kumar
 
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and AdministerAndrejs Karpovs
 
Best Practices for implementing Database Security Comprehensive Database Secu...
Best Practices for implementing Database Security Comprehensive Database Secu...Best Practices for implementing Database Security Comprehensive Database Secu...
Best Practices for implementing Database Security Comprehensive Database Secu...Kal BO
 
Oracle Golden Gate Bidirectional Replication
Oracle Golden Gate Bidirectional ReplicationOracle Golden Gate Bidirectional Replication
Oracle Golden Gate Bidirectional ReplicationArun Sharma
 
Mindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developersMindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developersKeshav Murthy
 
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Andrejs Prokopjevs
 
YOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesYOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesChris Richardson
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)Emil Eifrem
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022Frederic Descamps
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesFrederic Descamps
 

What's hot (20)

Hadoop Security Architecture
Hadoop Security ArchitectureHadoop Security Architecture
Hadoop Security Architecture
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
 
Always on in sql server 2017
Always on in sql server 2017Always on in sql server 2017
Always on in sql server 2017
 
Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!
 
Ambari: Agent Registration Flow
Ambari: Agent Registration FlowAmbari: Agent Registration Flow
Ambari: Agent Registration Flow
 
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.6 on Database 12c: Install, Patch and Administer
 
Oracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionOracle ASM 11g - The Evolution
Oracle ASM 11g - The Evolution
 
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best PracticesOracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databases
 
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
 
Best Practices for implementing Database Security Comprehensive Database Secu...
Best Practices for implementing Database Security Comprehensive Database Secu...Best Practices for implementing Database Security Comprehensive Database Secu...
Best Practices for implementing Database Security Comprehensive Database Secu...
 
Oracle Golden Gate Bidirectional Replication
Oracle Golden Gate Bidirectional ReplicationOracle Golden Gate Bidirectional Replication
Oracle Golden Gate Bidirectional Replication
 
Oracle Data Masking
Oracle Data MaskingOracle Data Masking
Oracle Data Masking
 
Mindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developersMindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developers
 
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
 
YOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesYOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous Microservices
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 

Viewers also liked

API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and DockerApigee | Google Cloud
 
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...DataStax
 
Getting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi FrameworkGetting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi FrameworkJimmy Guerrero
 
Data Modeling for Microservices with Cassandra and Spark
Data Modeling for Microservices with Cassandra and SparkData Modeling for Microservices with Cassandra and Spark
Data Modeling for Microservices with Cassandra and SparkJeffrey Carpenter
 
Asynchronous Microservices in nodejs
Asynchronous Microservices in nodejsAsynchronous Microservices in nodejs
Asynchronous Microservices in nodejsBruno Pedro
 
Microservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQMicroservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQPaulius Uza
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Chris Richardson
 
Building Scalable Micro-services with Nodejs
Building Scalable Micro-services with NodejsBuilding Scalable Micro-services with Nodejs
Building Scalable Micro-services with NodejsMichal Juhas
 
Building an API in Node with HapiJS
Building an API in Node with HapiJSBuilding an API in Node with HapiJS
Building an API in Node with HapiJSLoc Nguyen
 
Adventures with Microservices
Adventures with MicroservicesAdventures with Microservices
Adventures with MicroservicesAnand Agrawal
 
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...Chris Richardson
 
Building microservices with docker
Building microservices with dockerBuilding microservices with docker
Building microservices with dockerRoman Melnyk
 
Odoo acces rights & groups
Odoo acces rights & groupsOdoo acces rights & groups
Odoo acces rights & groupsLithin Thampan
 
Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Chris Richardson
 
CQL: SQL In Cassandra
CQL: SQL In CassandraCQL: SQL In Cassandra
CQL: SQL In CassandraEric Evans
 
Microservice architecture case study
Microservice architecture case studyMicroservice architecture case study
Microservice architecture case studyRudra Tripathy
 
Monitoring microservices platform
Monitoring microservices platformMonitoring microservices platform
Monitoring microservices platformBoyan Dimitrov
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to MicroservicesDavid Currie
 
Lessons Learned: Using Spark and Microservices
Lessons Learned: Using Spark and MicroservicesLessons Learned: Using Spark and Microservices
Lessons Learned: Using Spark and MicroservicesAlexis Seigneurin
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and BeyondMatt Stine
 

Viewers also liked (20)

API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and Docker
 
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...
From Monolith to Microservices with Cassandra, Grpc, and Falcor (Luke Tillman...
 
Getting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi FrameworkGetting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi Framework
 
Data Modeling for Microservices with Cassandra and Spark
Data Modeling for Microservices with Cassandra and SparkData Modeling for Microservices with Cassandra and Spark
Data Modeling for Microservices with Cassandra and Spark
 
Asynchronous Microservices in nodejs
Asynchronous Microservices in nodejsAsynchronous Microservices in nodejs
Asynchronous Microservices in nodejs
 
Microservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQMicroservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQ
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
 
Building Scalable Micro-services with Nodejs
Building Scalable Micro-services with NodejsBuilding Scalable Micro-services with Nodejs
Building Scalable Micro-services with Nodejs
 
Building an API in Node with HapiJS
Building an API in Node with HapiJSBuilding an API in Node with HapiJS
Building an API in Node with HapiJS
 
Adventures with Microservices
Adventures with MicroservicesAdventures with Microservices
Adventures with Microservices
 
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
 
Building microservices with docker
Building microservices with dockerBuilding microservices with docker
Building microservices with docker
 
Odoo acces rights & groups
Odoo acces rights & groupsOdoo acces rights & groups
Odoo acces rights & groups
 
Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)Decomposing applications for scalability and deployability (devnexus 2013)
Decomposing applications for scalability and deployability (devnexus 2013)
 
CQL: SQL In Cassandra
CQL: SQL In CassandraCQL: SQL In Cassandra
CQL: SQL In Cassandra
 
Microservice architecture case study
Microservice architecture case studyMicroservice architecture case study
Microservice architecture case study
 
Monitoring microservices platform
Monitoring microservices platformMonitoring microservices platform
Monitoring microservices platform
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
 
Lessons Learned: Using Spark and Microservices
Lessons Learned: Using Spark and MicroservicesLessons Learned: Using Spark and Microservices
Lessons Learned: Using Spark and Microservices
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
 

Similar to Microservices with Node.js and Apache Cassandra

Pivotal Platform - December Release A First Look
Pivotal Platform - December Release A First LookPivotal Platform - December Release A First Look
Pivotal Platform - December Release A First LookVMware Tanzu
 
Java springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology MeetupJava springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology MeetupAccenture Hungary
 
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktop
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktopCitrix Mobility Conference 2015 - Migrating XenApp & XenDesktop
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktopJonathan Wade
 
You Can Be Cloud Native, Too
You Can Be Cloud Native, TooYou Can Be Cloud Native, Too
You Can Be Cloud Native, TooVMware Tanzu
 
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEPRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEEditor IJCTER
 
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryConcevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryVMware Tanzu
 
NetIQ identity powered security
NetIQ identity powered security   NetIQ identity powered security
NetIQ identity powered security Finceptum Oy
 
Simplifying Multi-User SOLIDWORKS Implementations
Simplifying Multi-User SOLIDWORKS ImplementationsSimplifying Multi-User SOLIDWORKS Implementations
Simplifying Multi-User SOLIDWORKS ImplementationsHawk Ridge Systems
 
Application Modernization with PKS / Kubernetes
Application Modernization with PKS / KubernetesApplication Modernization with PKS / Kubernetes
Application Modernization with PKS / KubernetesPaul Czarkowski
 
Securely Connecting Your Customers to Their Cloud-Hosted App – In Minutes
Securely Connecting Your Customers to Their Cloud-Hosted App – In MinutesSecurely Connecting Your Customers to Their Cloud-Hosted App – In Minutes
Securely Connecting Your Customers to Their Cloud-Hosted App – In MinutesKhash Nakhostin
 
Add Apache Web Server to your Unified Monitoring Toolkit
Add Apache Web Server to your Unified Monitoring ToolkitAdd Apache Web Server to your Unified Monitoring Toolkit
Add Apache Web Server to your Unified Monitoring ToolkitAppDynamics
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptxVMware Tanzu
 
Webinar - Building Custom Extensions With AppDynamics
Webinar - Building Custom Extensions With AppDynamicsWebinar - Building Custom Extensions With AppDynamics
Webinar - Building Custom Extensions With AppDynamicsTodd Radel
 
Getting Started with ThousandEyes Proof of Concepts
Getting Started with ThousandEyes Proof of ConceptsGetting Started with ThousandEyes Proof of Concepts
Getting Started with ThousandEyes Proof of ConceptsThousandEyes
 
Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)SDNRG ITB
 
Scaling Automated Tests: Choosing an Appropriate Subset
Scaling Automated Tests: Choosing an Appropriate SubsetScaling Automated Tests: Choosing an Appropriate Subset
Scaling Automated Tests: Choosing an Appropriate SubsetTechWell
 
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...VMworld
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volutionQAware GmbH
 
Swarn Singh_CV_SSE
Swarn Singh_CV_SSESwarn Singh_CV_SSE
Swarn Singh_CV_SSESwarn Singh
 
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebMysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebAlkin Tezuysal
 

Similar to Microservices with Node.js and Apache Cassandra (20)

Pivotal Platform - December Release A First Look
Pivotal Platform - December Release A First LookPivotal Platform - December Release A First Look
Pivotal Platform - December Release A First Look
 
Java springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology MeetupJava springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology Meetup
 
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktop
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktopCitrix Mobility Conference 2015 - Migrating XenApp & XenDesktop
Citrix Mobility Conference 2015 - Migrating XenApp & XenDesktop
 
You Can Be Cloud Native, Too
You Can Be Cloud Native, TooYou Can Be Cloud Native, Too
You Can Be Cloud Native, Too
 
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGEPRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
PRIVATE CLOUD SERVER IMPLEMENTATIONS FOR DATA STORAGE
 
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryConcevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
 
NetIQ identity powered security
NetIQ identity powered security   NetIQ identity powered security
NetIQ identity powered security
 
Simplifying Multi-User SOLIDWORKS Implementations
Simplifying Multi-User SOLIDWORKS ImplementationsSimplifying Multi-User SOLIDWORKS Implementations
Simplifying Multi-User SOLIDWORKS Implementations
 
Application Modernization with PKS / Kubernetes
Application Modernization with PKS / KubernetesApplication Modernization with PKS / Kubernetes
Application Modernization with PKS / Kubernetes
 
Securely Connecting Your Customers to Their Cloud-Hosted App – In Minutes
Securely Connecting Your Customers to Their Cloud-Hosted App – In MinutesSecurely Connecting Your Customers to Their Cloud-Hosted App – In Minutes
Securely Connecting Your Customers to Their Cloud-Hosted App – In Minutes
 
Add Apache Web Server to your Unified Monitoring Toolkit
Add Apache Web Server to your Unified Monitoring ToolkitAdd Apache Web Server to your Unified Monitoring Toolkit
Add Apache Web Server to your Unified Monitoring Toolkit
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Webinar - Building Custom Extensions With AppDynamics
Webinar - Building Custom Extensions With AppDynamicsWebinar - Building Custom Extensions With AppDynamics
Webinar - Building Custom Extensions With AppDynamics
 
Getting Started with ThousandEyes Proof of Concepts
Getting Started with ThousandEyes Proof of ConceptsGetting Started with ThousandEyes Proof of Concepts
Getting Started with ThousandEyes Proof of Concepts
 
Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)
 
Scaling Automated Tests: Choosing an Appropriate Subset
Scaling Automated Tests: Choosing an Appropriate SubsetScaling Automated Tests: Choosing an Appropriate Subset
Scaling Automated Tests: Choosing an Appropriate Subset
 
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...
VMworld 2013: NSX PCI Reference Architecture Workshop Session 3 - Operational...
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volution
 
Swarn Singh_CV_SSE
Swarn Singh_CV_SSESwarn Singh_CV_SSE
Swarn Singh_CV_SSE
 
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebMysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
 

Recently uploaded

OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Projectwajrcs
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxPrakarsh -
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Neo4j
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesSoftwareMill
 
20240330_고급진 코드를 위한 exception 다루기
20240330_고급진 코드를 위한 exception 다루기20240330_고급진 코드를 위한 exception 다루기
20240330_고급진 코드를 위한 exception 다루기Chiwon Song
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdfMeon Technology
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9Jürgen Gutsch
 

Recently uploaded (20)

OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptx
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retries
 
20240330_고급진 코드를 위한 exception 다루기
20240330_고급진 코드를 위한 exception 다루기20240330_고급진 코드를 위한 exception 다루기
20240330_고급진 코드를 위한 exception 다루기
 
Sustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire ThornewillSustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire Thornewill
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdf
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9
 

Microservices with Node.js and Apache Cassandra

  • 1. Microservices with Node.js and Apache Cassandra 1 Jorge Bay Gondra @jorgebg Software Engineer, Drivers team at DataStax
  • 2. © 2015 DataStax, All Rights Reserved. Company Confidential Topics 1- Microservices 2- Why Node.js and Cassandra 3- The Node.js driver 4- Putting it all together: killr-service 2
  • 4. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices Defining microservices 4 - Service as software component - 1 service per process - Different data storage per service
  • 5. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices From monolithic server architecture 5 - Single process contains all the logic - Simple to develop - Simple to deploy
  • 6. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices From monolithic server architecture 6 - Large code bases - Hard add new features - Hard to train new developers - Long term technology commitment
  • 7. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices Why Microservices 7 - Codebase <---> teams - Independently deployable: Versioning - Fault isolation - Best technology for the job - Long lived systems, short lived services
  • 8. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices But some things get harder 8 - Inter-service communication - Deployment
  • 9. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices 9 Monolithic architecture UI Services Data Access Browser Monolithic Application Relational database
  • 10. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices 10 Monolithic architecture Store UI Order UI Customer UI Catalog Svc Order Svc Customer Svc Product DA Order DA Customer DA Browser Monolithic Application Relational database
  • 11. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices 11 Microservices architecture Browser Front end Services Data storage Order Product Customer
  • 12. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices 12 Inter-service communication Products Orders Message Broker
  • 13. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices Inter-service communication 13 - Event based - Async - Start simple
  • 14. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices 14 Microservices architecture Browser Front end Services Data storage Order Product Customer Message broker
  • 15. © 2015 DataStax, All Rights Reserved. Company Confidential 1- Microservices Recap 15 - Service as component - Deploy / Versioning - Own your data
  • 16. 2- Node.js + Cassandra 16
  • 17. © 2015 DataStax, All Rights Reserved. Company Confidential 2- Why Node.js and Cassandra Node.js 17 - Single paradigm: async IO / event loop - Minimum overhead per connection - Predictable amount of memory usage under load
  • 18. © 2015 DataStax, All Rights Reserved. Company Confidential 2- Why Node.js and Cassandra Cassandra 18 - Tunable consistency - No master / slave - Fault tolerant
  • 19. 3- The Node.js Driver for Apache Cassandra 19
  • 20. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Features 20 - Automatic failover - Node discovery - Tunable policies - Request pipelining - TLS
  • 21. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Automatic failover 21 Client 1 DC 1 DC 2 Requests
  • 22. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Node discovery 22 Client DC 1 Request Events Response
  • 23. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Tunable policies 23 - Load balancing - Retry - Reconnection
  • 24. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Load balancing policy sample 24 function BlackListPolicy(blackListedHost, childPolicy) { this.blackListedHost = blackListedHost; this.childPolicy = childPolicy; } util.inherits(BlackListPolicy, LoadBalancingPolicy); BlackListPolicy.prototype.newQueryPlan = function (keyspace, queryOptions, callback) { this.childPolicy.newQueryPlan(keyspace, queryOptions, function (err, iterator) { callback(err, filter(iterator)); }); }; function *filter () {/**/}
  • 25. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Ecmascript 6 25 - Load balancing policies: generators - Encoding / decoding: ES6 Map / Set
  • 26. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Request pipelining 26 Client Sending first request (1) Cassandra Node time Received first response (2)
  • 27. © 2015 DataStax, All Rights Reserved. Company Confidential 3- The Node.js Driver for Cassandra Recap 27 - Failover built-in - Connection pooling - Defaults
  • 28. 4- Putting it all together Demo: Microservices with Node.js and Cassandra Demo 28
  • 29. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Functionality 29 - Video Comments - Video Ratings
  • 30. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Schema 30 CREATE TABLE comments_by_video ( videoid uuid, commentid timeuuid, userid uuid, comment text, PRIMARY KEY (videoid, commentid)) WITH CLUSTERING ORDER BY (commentid DESC); CREATE TABLE comments_by_user ( userid uuid, commentid timeuuid, videoid uuid, comment text, PRIMARY KEY (userid, commentid)) WITH CLUSTERING ORDER BY (commentid DESC);
  • 31. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Schema 31 CREATE TABLE video_rating ( videoid uuid, rating_counter counter, rating_total counter, PRIMARY KEY (videoid)); CREATE TABLE video_ratings_by_user ( videoid uuid, userid uuid, rating int, PRIMARY KEY (videoid, userid));
  • 32. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Service methods 32 - GET comments by video - POST comment - GET rating by video - POST rating
  • 33. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo GET comments by video 33 var cassandra = require('cassandra-driver'); var client = new cassandra.Client({ contactPoints: ['localhost']}); var query = 'SELECT videoid, commentid, userid, comment FROM comments_by_video WHERE videoid = ?'; app.get('/v1/comments/:videoId([a-f0-9-]{36})', function (req, res, next) { client.execute(query, [req.params.videoId], { prepare: true }, function (err, result) { if (err) return next(err); res.json(result.rows); }); });
  • 34. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo GET comments by video 34 var repository = new Repository(client); //... app.get('/v1/comment/:videoId([a-f0-9-]{36})', function (req, res, next) { repository.getCommentsByVideo(req.params.videoId, function (err, comments) { if (err) return next(err); res.json(comments); }); });
  • 35. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo POST comment 35 app.post('/v1/comment/:videoId([a-f0-9-]{36})', function (req, res, next) { repository.insertComment(req.params.videoId, req.body.userId, req.body.comment, (err, id) { if (err) return next(err); res.send(id.toString()); }); });
  • 36. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Repository: Insert comment 36 Repository.prototype.insertComment = function (videoId, userId, comment, callback) { var commentId = cassandra.types.TimeUuid.now(); var queries = [ { query: 'INSERT INTO comments_by_video (videoid, commentid, userid, comment) VALUES (?, ?, ?, ?)', params: [videoId, commentId, userId, comment]}, { query: 'INSERT INTO comments_by_user (userid, commentid, videoid, comment) VALUES (?, ?, ?, ?)', params: [userId, commentId, videoId, comment]}]; this.client.batch(queries, { prepare: true }, callback); });
  • 37. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Repository: Insert comment 37 Repository.prototype.insertComment = function (videoId, userId, comment, callback) { var commentId = cassandra.types.TimeUuid.now(); var queries = [/*...*/]; var bus = this.bus; this.client.batch(queries, { prepare: true }, function (err) { if (!err) { bus.publishNewComment(videoId, commentId, userId, comment); } callback(err, commentId); }); });
  • 38. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Message broker client 38 function Bus() { }
  • 39. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Message broker client 39 function Bus() { } Bus.prototype.publishNewComment = function (videoId, /*...*/) { //Insert magic here };
  • 40. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Message broker client 40 function Bus() { events.EventEmitter.call(this); var self = this; serverLib.on('whatever.topic.event.name', function (data) { self.emit('whatever-client-name', data); }); } util.inherits(Bus, events.EventEmitter); Bus.prototype.publishNewComment = function () {/*...*/};
  • 41. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Seneca sample: GET comments 41 seneca.add( {role: 'comment', cmd: 'get'}, function (args, done) { repository.getCommentsByVideo(args.id, done); });
  • 42. © 2015 DataStax, All Rights Reserved. Company Confidential 4- Microservices Demo Recap 42 - 3 classes - ~150 LoC - Boundaries
  • 43. © 2015 DataStax, All Rights Reserved. Company Confidential Thanks @jorgebg github.com/jorgebay/killr-service datastax.com/dev/blog bit.ly/nodejs-cassandra-user 43
  • 44. © 2015 DataStax, All Rights Reserved. Company Confidential Thanks Further reading - Sample project: killr-service - Presentation: Implementing Micro-Service Architecture by Fred George - Book: Building Microservices By Sam Newman (O'Reilly) - Article: Microservices Architecture By James Lewis and Martin Fowler 44

Editor's Notes

  1. These are the high-level topics we'll be getting into: - We start with an introduction of Microservices, usage, common patterns. - Second, we continue with a case why Node.js and Apache Cassandra, and what makes them an excellent choice for Microservices. - Then, we will talk about the Node.js driver: tuning, best practices and some of the driver internals. - Finally we will put it all together in a demo, called killr-service, based on a killr-video schema used by Patrick McFadin to demonstrate data modeling technique. With this project we will try to cover what we discussed on the previous topics.
  2. Let's start with a brief theory microservices, there is a lot of buzz about microservices but there is no precise definition about it. There are certain characteristics that define microservices.
  3. Besides a hyped word, microservices is an architectural approach to develop applications using a suite of services. Each service is a component that is developed around a functionality, a unit of software that can be independently replaceable and upgradeable. Each service runs in its own process. Each service should have a different data storage. Each service generates events, that can be picked up by another microservices to perform specific actions based on it. In the following slides, we are going to describe the reasons behind this pattern.
  4. It's hard to talk about microservices without talking about where we all came from. We are used to build monolithic applications as a single unit, where all the logic for handling user requests go through a single process. A system with multiple software components, components that depend on each other, is relatively easy to develop and deploy. You just end up with 1 package (jar).
  5. But monoliths have their problems, they tend to grow big, making it hard to implement new features without a deep knowledge of the internals. Overtime, it starts to be difficult to understand how to correctly implement a change and the quality of the code declines. To add functionality for which your application was not originally designed, you are sometimes forced to "hack" into the code base. Additionally, a monolith means a long term commitment to a technology stack, making it hard to benefit from newer technology.
  6. This pattern allows cross functional teams to be responsible of the whole life cycle of a component, organized around a business capability. Keeping things that can change at the same time in the same module, enable us to quickly implement new changes and make the system evolve faster. That's is the reason for the microservice to have their own data, to manage schema changes independently. It is even OK to have multiple versions of the same service, online. No single point of failure, if one of the services goes down, the application can remain operative. As a microservice is loosely coupled with others, it allows teams to choose the technology stack (from the programming language to the database). Microservices architecture makes sense under the premise that system are long lived but versions of the services are short lived.
  7. But it is not all good news, some parts of your development life cycle do get harder. Now you have to deal with inter-service communication, each service is a different process and probably is located in a different server, so there should be a network protocol to communicate. The microservices architecture replaces 1 monolithic application but there are multiple services per application, making deployment not trivial.
  8. Let's look at a basic design of a monolithic architecture of server application. You can use layers to allocate different responsibilities of the application, typically: - Presentation layer - Service layer - Data access layer
  9. Each layer has different components. Components can call each other and boundaries are not defined in the design. For example the order service can call the products, order and customer data access to process an order.
  10. Now, lets consider the microservice architecture, this looks simple enough. Components are functionally decomposed. Each service contains the logic to deal with an specific functionality. Each service with has its own data storage, you can even denote the service as the group containing the package and the database.
  11. Lets focus now in 2 of the services, Orders and Products. Keeping in mind that there can be multiple instances of each service running in production. If we start making direct calls from one service to the other we end up with the same problems as the monolithic pattern, plus we must implement the logic for handling other services going down, plus knowing details of other services like address / contracts. [Next] That is why we should introduce a message broker. [Next][Next] That deals with messages coming from one service and delivers them asynchronously.
  12. About communication between services, there are a few principles that we can follow. We publish and consume events, for example: order made, a product has been restocked. We just have to worry about the event being received by the broker, not about what other services have to do with it. Start simple and cheap, it doesn't have to be a fancy enterprise service bus, think of it as a dumb pipe. Message queue protocol is a good fit, products like RabbitMQ/ActiveMQ are fully featured.
  13. Now, lets look at the complete example, focused on the Order service. The order service package communicates with a database and the message broker. The order service publish events and consume events from other services or systems.
  14. This pattern allow us to organize software components around business capabilities. We can deploy new versions of a service independently. Owning the data allow us to implement schema changes knowing that we won't affect other services. [Long Pause]
  15. What we will see in this small section is why Node.js and Cassandra are a great fit for Microservices. It will be very short because I don't want to make this presentation to turn into a Marketing or Sales presentation...
  16. Node.js is really good for IO Bound scenarios. There is one or few ways to implement a functionality, for example most IO libraries do not include synchronous method, just async. Node.js performs very well for high number concurrent connections, where most of the time is spent waiting for IO.
  17. Well, and with Cassandra: You get tunable consistency, for any given read or write operation, the we can decide how consistent the requested data must be. The peer-to-peer architecture, which can include several identical nodes, protects us from data loss. It's not just a key value store, via cql, it provides tabular outputs and a rich type system, including maps, lists, sets and user defined types. [Long Pause]
  18. Let’s have a quick look at the Node.js driver before trying to build our own microservice demo.
  19. The Node.js driver provides: - Connection pooling - Automatic failover and retry - The driver discovers the Cassandra cluster topology automatically. - Tunable load balancing, retry and reconnection policies. - Request pipelining, meaning that you can issue more than multiple requests without waiting for a response. - Client-server SSL support.
  20. I tried to illustrate how automatic failover works. [Next] If a Cassandra node fails or becomes unreachable [Next] the driver automatically tries other nodes in the cluster and schedules reconnections to the dead nodes in the background. It can try with another node in the same datacenter. [Next] Or, In the case the local datacenter becomes unavailable [Next] it will issue the request on a node of another datacenter.
  21. The Cassandra protocol is a request-response based communication mechanism but it also features notification of events. These events can be: - A new node being added. - An existing node being moved or removed - A change in the schema. - Or a node status change: a node went DOWN or back UP. To discover the nodes that are part of the cluster, the driver initially fetches the topology information and then uses this notification mechanism to keep the cluster information up to date.
  22. In the driver, you can select the load balancing policies, to define which node should be the coordinator of each query. The driver has 3 built-in load balancing policies: - Round robin policy - Datacenter Aware policy. - Token Aware policy. You can also create your own load balancing policy. With the retry policy, you can choose when a query should be retried when an specific error occurred. With the reconnection policy, you can define what should be the delay for the reconnection attempts, in case a node goes down.
  23. Here is a code sample of a load balancing policy. I don't want to dig deep into it, as you probably would not need to implement your own policy (built-in ones are suitable for most cases). But it's just a way to show you that, with a couple of lines of code, you can override the behaviour of the driver. In this case, by inheriting from LoadBalancingPolicy base class and yielding the hosts, you are able to build your own policy.
  24. Do you fancy Ecmascript 6? The driver enables you to use the latest ES6 features. For the load balancing policies, you can use the generators (using yield keyword), as it uses the iterator protocol. For encoding and decoding Cassandra maps and sets, you can configure the driver to use Ecmascript 6 Maps and Sets.
  25. Cassandra native protocol supports multiple requests to be sent without waiting for a response. This enables higher levels of parallelism with just one connection. What the graph is trying to show is that, thanks to request pipelining, the driver does not have to wait for the response to be received to issue the following requests. Other database protocols that don't support request pipelining (I don't want to name names), force clients to maintain lots of connections to the same host to achieve the same level of concurrency.
  26. The driver implements failover and retry, so you don't have to implement your own failover / retry functionality. The driver uses connection pooling to the Cassandra nodes, so you should reuse the same client instance and don't worry about it. The driver supports fine tuning through policies and setting, but the default policies and configuration settings are suitable for most of the use cases, so you don't need to spend time on this. [Long pause]
  27. Well let's try to build a demo of a microservice with Node.js and Cassandra.
  28. The service will focus in user feedback of videos (comments and ratings). It is based on a sample schema for a video sharing site that Patrick McFadin has been using to demonstrate data modeling techniques with Cassandra. There are other sample applications using this schema, most notably there is a live site built by Luke Tillman from DataStax: killrvideo.com And here it comes, a lot of code in presentation slides, ...
  29. We will be using these two column families for comments, one partitioned by videoId and the other by user. [Long Pause]
  30. And we will be using these two column families for ratings, the To keep the presentation short, I will be showing the code for the comments functionality and not the ratings but on GitHub you have all the functionality if you want to look into it.
  31. We will be using HTTP and just GET and POST verbs. We will be implement it with ExpressJS but I will also provide samples with Seneca.
  32. Let's start with a simple one: Expose a GET route to get all the comments and return them as JSON. We reuse the same cassandra client instance and execute using different parameters.
  33. Well, using the repository pattern, we moved all the logic of the data accessing and adapting of results to the repository class. We set the cassandra driver instance as a dependency to the repository class. Now, we have a cleaner code there. I made it as a personal choice to provide more concise code snippets, but we could have it all in just one module as there are very few lines of code.
  34. Now, lets looks at a more complete example. The routing part is very similar, we route POST requests, insert the comment and return the id of the comment. All the logic is on the repository.
  35. As we have a denormalized schema, we have to make 2 inserts. We execute them in a single batch, that translates into a single request to Cassandra.
  36. Let's complete the example of the insertion of a comment pushing a notification to the BUS, the message broker. Consumers of that event, could perform specific actions with that message: An example would be a user profile service that outputs some stats related to comments cleaning its internal cache. An example would be a service cache being cleaned before a bit of content that needs to be rendered in a webpage, in this case a new comment, changed.
  37. The internal implementation of a message broker client is out of scope of this presentation. But let's look into in what it should expose.
  38. It should expose typed methods to publish events, like the one we invoked from the repository.
  39. It should emit events based on server events. In this example, I'm using an imaginary library, but the idea would be to subscribe to a topic and emit an client event of that. Listeners of this event within this service could perform specific actions out of it. So that is the complete example of a service bus client class, there's a lack of real code in this example but hope it helps to build your own.
  40. Just as a quick note, here is the same action to retrieve comments but using SenecaJs. Seneca is a tool that separates an application into small actions. An action is not aware if it is being exposed through HTTP or any other protocol.
  41. Let's recap It can be traversed, the 3 classes can be setup, comment and rating. It's around 150 lines of code, it can be less without code comments and a less verbose programming style. Around a functionality… it can even splitted up into comment service and rating service.
  42. And that's about it, here is the link to the sample project, killr-service. Check out the DataStax dev blog, where we publish news about the Cassandra and it's drivers.