SlideShare a Scribd company logo
Submit Search
Upload
LNUG: Having Your Node.js Cake and Eating It Too
Report
Share
R
Rob Tweed
IT Consultant, Developer & Director/Founder at M/Gateway Developments Ltd
Follow
•
3 likes
•
2,832 views
1
of
81
LNUG: Having Your Node.js Cake and Eating It Too
•
3 likes
•
2,832 views
Report
Share
Download Now
Download to read offline
Software
Presentation given at LNUG Meeting on 27 September 2017
Read more
R
Rob Tweed
IT Consultant, Developer & Director/Founder at M/Gateway Developments Ltd
Follow
Recommended
QEWD Update by
QEWD Update
Rob Tweed
945 views
•
32 slides
Data Persistence as a Language Feature by
Data Persistence as a Language Feature
Rob Tweed
1.3K views
•
108 slides
QEWD.js: Have your Node.js Cake and Eat It Too by
QEWD.js: Have your Node.js Cake and Eat It Too
Rob Tweed
628 views
•
76 slides
qewd-ripple: The Ripple OSI Middle Tier by
qewd-ripple: The Ripple OSI Middle Tier
Rob Tweed
720 views
•
52 slides
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data... by
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
Rob Tweed
3.9K views
•
32 slides
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services by
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
Rob Tweed
333 views
•
37 slides
More Related Content
What's hot
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality by
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
Rob Tweed
2.1K views
•
254 slides
EWD.js: The Future Starts Here by
EWD.js: The Future Starts Here
Rob Tweed
1.2K views
•
77 slides
EWD 3 Training Course Part 2: EWD 3 Overview by
EWD 3 Training Course Part 2: EWD 3 Overview
Rob Tweed
2.1K views
•
93 slides
EWD 3 Training Course Part 4: Installing & Configuring QEWD by
EWD 3 Training Course Part 4: Installing & Configuring QEWD
Rob Tweed
2.9K views
•
31 slides
EWD 3 Training Course Part 30: Modularising QEWD Applications by
EWD 3 Training Course Part 30: Modularising QEWD Applications
Rob Tweed
1.1K views
•
85 slides
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle by
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
Rob Tweed
720 views
•
20 slides
What's hot
(20)
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality by Rob Tweed
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
Rob Tweed
•
2.1K views
EWD.js: The Future Starts Here by Rob Tweed
EWD.js: The Future Starts Here
Rob Tweed
•
1.2K views
EWD 3 Training Course Part 2: EWD 3 Overview by Rob Tweed
EWD 3 Training Course Part 2: EWD 3 Overview
Rob Tweed
•
2.1K views
EWD 3 Training Course Part 4: Installing & Configuring QEWD by Rob Tweed
EWD 3 Training Course Part 4: Installing & Configuring QEWD
Rob Tweed
•
2.9K views
EWD 3 Training Course Part 30: Modularising QEWD Applications by Rob Tweed
EWD 3 Training Course Part 30: Modularising QEWD Applications
Rob Tweed
•
1.1K views
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle by Rob Tweed
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
Rob Tweed
•
720 views
EWD 3 Training Course Part 33: Configuring QEWD to use CORS by Rob Tweed
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
Rob Tweed
•
1.1K views
EWD 3 Training Course Part 42: The QEWD Docker Appliance by Rob Tweed
EWD 3 Training Course Part 42: The QEWD Docker Appliance
Rob Tweed
•
1.3K views
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD by Rob Tweed
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
Rob Tweed
•
541 views
EWD 3 Training Course Part 34: QEWD Resilient Mode by Rob Tweed
EWD 3 Training Course Part 34: QEWD Resilient Mode
Rob Tweed
•
750 views
EWD 3 Training Course Part 3: Summary of EWD 3 Modules by Rob Tweed
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
Rob Tweed
•
979 views
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services by Rob Tweed
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
Rob Tweed
•
3.3K views
EWD 3 Training Course Part 27: The QEWD Session by Rob Tweed
EWD 3 Training Course Part 27: The QEWD Session
Rob Tweed
•
920 views
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres... by Rob Tweed
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
Rob Tweed
•
1.1K views
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD by Rob Tweed
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
Rob Tweed
•
1.2K views
Nuts and Bolts of WebSocket Devoxx 2014 by Arun Gupta
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
•
13.5K views
EWD 3 Training Course Part 19: The cache.node APIs by Rob Tweed
EWD 3 Training Course Part 19: The cache.node APIs
Rob Tweed
•
905 views
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages by Rob Tweed
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
Rob Tweed
•
693 views
Docker for Java Developers by Imesh Gunaratne
Docker for Java Developers
Imesh Gunaratne
•
4.2K views
EWD 3 Training Course Part 35: QEWD Session Locking by Rob Tweed
EWD 3 Training Course Part 35: QEWD Session Locking
Rob Tweed
•
532 views
Similar to LNUG: Having Your Node.js Cake and Eating It Too
Move Your .NET Apps to AWS Without Betting the House - WIN303 - re:Invent 2017 by
Move Your .NET Apps to AWS Without Betting the House - WIN303 - re:Invent 2017
Amazon Web Services
652 views
•
55 slides
Node.Js: Basics Concepts and Introduction by
Node.Js: Basics Concepts and Introduction
Kanika Gera
3.4K views
•
24 slides
InterConnect 2017 : Programming languages in the enterprise: Which language s... by
InterConnect 2017 : Programming languages in the enterprise: Which language s...
DevOps for Enterprise Systems
309 views
•
44 slides
Top 10 frameworks of node js by
Top 10 frameworks of node js
Habilelabs
204 views
•
16 slides
NodeJS and what is actually does by
NodeJS and what is actually does
Victor Reyes Heitmann
761 views
•
8 slides
Node ts1 by
Node ts1
Yaniv Rodenski
2.8K views
•
25 slides
Similar to LNUG: Having Your Node.js Cake and Eating It Too
(20)
Move Your .NET Apps to AWS Without Betting the House - WIN303 - re:Invent 2017 by Amazon Web Services
Move Your .NET Apps to AWS Without Betting the House - WIN303 - re:Invent 2017
Amazon Web Services
•
652 views
Node.Js: Basics Concepts and Introduction by Kanika Gera
Node.Js: Basics Concepts and Introduction
Kanika Gera
•
3.4K views
InterConnect 2017 : Programming languages in the enterprise: Which language s... by DevOps for Enterprise Systems
InterConnect 2017 : Programming languages in the enterprise: Which language s...
DevOps for Enterprise Systems
•
309 views
Top 10 frameworks of node js by Habilelabs
Top 10 frameworks of node js
Habilelabs
•
204 views
NodeJS and what is actually does by Victor Reyes Heitmann
NodeJS and what is actually does
Victor Reyes Heitmann
•
761 views
Node ts1 by Yaniv Rodenski
Node ts1
Yaniv Rodenski
•
2.8K views
Kiss.ts - The Keep It Simple Software Stack for 2017++ by Ethan Ram
Kiss.ts - The Keep It Simple Software Stack for 2017++
Ethan Ram
•
522 views
Net core vs. node.js what to choose when by Katy Slemon
Net core vs. node.js what to choose when
Katy Slemon
•
75 views
New DevOps for the DBA by Kellyn Pot'Vin-Gorman
New DevOps for the DBA
Kellyn Pot'Vin-Gorman
•
1.7K views
Brownbag on basics of node.js by Jason Park
Brownbag on basics of node.js
Jason Park
•
362 views
A295 nodejs-knowledge-accelerator by Michael Dawson
A295 nodejs-knowledge-accelerator
Michael Dawson
•
480 views
Node js Development Company - Aparajayah by AparajayahTechnologi
Node js Development Company - Aparajayah
AparajayahTechnologi
•
53 views
Beginners Node.js by Khaled Mosharraf
Beginners Node.js
Khaled Mosharraf
•
496 views
11 Live Node.js CMS Frameworks by iScripts
11 Live Node.js CMS Frameworks
iScripts
•
22.3K views
Get acquainted with the new ASP.Net 5 by Suyati Technologies
Get acquainted with the new ASP.Net 5
Suyati Technologies
•
1.1K views
Why Bet on Node.js? by ThinkTanker Technosoft PVT LTD
Why Bet on Node.js?
ThinkTanker Technosoft PVT LTD
•
180 views
Webinar: End-to-End CI/CD with GitLab and DC/OS by Mesosphere Inc.
Webinar: End-to-End CI/CD with GitLab and DC/OS
Mesosphere Inc.
•
1.5K views
Web Applications Development with MEAN Stack by Shailendra Chauhan
Web Applications Development with MEAN Stack
Shailendra Chauhan
•
1.1K views
Meanstack overview by Adthasid Sabmake
Meanstack overview
Adthasid Sabmake
•
504 views
Meetup. Technologies Intro for Non-Tech People by IT Arena
Meetup. Technologies Intro for Non-Tech People
IT Arena
•
138 views
More from Rob Tweed
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services by
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
Rob Tweed
891 views
•
93 slides
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5 by
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
Rob Tweed
621 views
•
73 slides
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4 by
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
718 views
•
31 slides
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3 by
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
627 views
•
19 slides
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application by
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
Rob Tweed
999 views
•
33 slides
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2 by
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
Rob Tweed
597 views
•
56 slides
More from Rob Tweed
(13)
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services by Rob Tweed
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
Rob Tweed
•
891 views
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5 by Rob Tweed
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
Rob Tweed
•
621 views
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4 by Rob Tweed
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
•
718 views
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3 by Rob Tweed
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
•
627 views
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application by Rob Tweed
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
Rob Tweed
•
999 views
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2 by Rob Tweed
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
Rob Tweed
•
597 views
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap... by Rob Tweed
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
Rob Tweed
•
932 views
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS by Rob Tweed
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
Rob Tweed
•
608 views
EWD 3 Training Course Part 29: Running QEWD as a Service by Rob Tweed
EWD 3 Training Course Part 29: Running QEWD as a Service
Rob Tweed
•
1K views
EWD 3 Training Course Part 26: Event-driven Indexing by Rob Tweed
EWD 3 Training Course Part 26: Event-driven Indexing
Rob Tweed
•
678 views
EWD 3 Training Course Part 25: Document Database Capabilities by Rob Tweed
EWD 3 Training Course Part 25: Document Database Capabilities
Rob Tweed
•
905 views
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes by Rob Tweed
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
Rob Tweed
•
622 views
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects by Rob Tweed
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
Rob Tweed
•
797 views
Recently uploaded
Keep by
Keep
Geniusee
78 views
•
10 slides
SAP FOR TYRE INDUSTRY.pdf by
SAP FOR TYRE INDUSTRY.pdf
Virendra Rai, PMP
28 views
•
3 slides
MS PowerPoint.pptx by
MS PowerPoint.pptx
Litty Sylus
7 views
•
14 slides
predicting-m3-devopsconMunich-2023.pptx by
predicting-m3-devopsconMunich-2023.pptx
Tier1 app
7 views
•
24 slides
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke
35 views
•
124 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30
Shane Coughlan
6 views
•
18 slides
Recently uploaded
(20)
Keep by Geniusee
Keep
Geniusee
•
78 views
SAP FOR TYRE INDUSTRY.pdf by Virendra Rai, PMP
SAP FOR TYRE INDUSTRY.pdf
Virendra Rai, PMP
•
28 views
MS PowerPoint.pptx by Litty Sylus
MS PowerPoint.pptx
Litty Sylus
•
7 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptx
Tier1 app
•
7 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke
•
35 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30
Shane Coughlan
•
6 views
nintendo_64.pptx by paiga02016
nintendo_64.pptx
paiga02016
•
5 views
Airline Booking Software by SharmiMehta
Airline Booking Software
SharmiMehta
•
7 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptx
FayazAli87
•
13 views
Myths and Facts About Hospice Care: Busting Common Misconceptions by Care Coordinations
Myths and Facts About Hospice Care: Busting Common Misconceptions
Care Coordinations
•
7 views
Using Qt under LGPL-3.0 by Burkhard Stubert
Using Qt under LGPL-3.0
Burkhard Stubert
•
13 views
ShortStory_qlora.pptx by pranathikrishna22
ShortStory_qlora.pptx
pranathikrishna22
•
5 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert
•
26 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin9
•
6 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller
•
42 views
Page Object Model by artembondar5
Page Object Model
artembondar5
•
6 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik
•
8 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Ra'Fat Al-Msie'deen
•
8 views
HarshithAkkapelli_Presentation.pdf by harshithakkapelli
HarshithAkkapelli_Presentation.pdf
harshithakkapelli
•
12 views
EV Charging App Case by iCoderz Solutions
EV Charging App Case
iCoderz Solutions
•
9 views
LNUG: Having Your Node.js Cake and Eating It Too
1.
Copyright © 2017
M/Gateway Developments Ltd Having Your Node.js Cake and Eating It Too Rob Tweed M/Gateway Developments Ltd Twitter: @rtweed http://qewdjs.com
2.
Copyright © 2017
M/Gateway Developments Ltd A bit of background • Royal Marsden Hospital: 1980s • Touche Ross Management Consultants (now Deloitte): early 1990s – NHS-wide Networking Project • Independent consultant & software developer since 1993 – Specialising in Web and associated technologies, particularly in healthcare
3.
Copyright © 2017
M/Gateway Developments Ltd A bit of background
4.
Copyright © 2017
M/Gateway Developments Ltd A bit of background • Node.js: – Since August 2010 (v0.2 had just come out!) – Gave one of the talks at LNUG inaugural meeting
5.
Copyright © 2017
M/Gateway Developments Ltd And So, 6 Years Later
6.
Copyright © 2017
M/Gateway Developments Ltd Node.js Architecture • Everything executes in a single process – You might have 1000's of users doing stuff concurrently • They're all sharing the same process!
7.
Copyright © 2017
M/Gateway Developments Ltd Node.js Architecture • Non-blocking I/O – No user activity must block the process, or everyone grinds to a halt • Event-driven, asynchronous logic – Fire off the request, but don't wait for the results • Carry on with the next task – When results come back, handle them at the next opportunity
8.
Copyright © 2017
M/Gateway Developments Ltd Node.js = server-side JavaScript • Ryan Dahl wasn't actually a big JavaScript fan • However, he realised that it was a convenient language for such an environment, as it's designed for exactly the same kind of way of working in the browser • Google's V8 JavaScript engine was Open Sourced, so he used it to provide the language for Node.js – (which is actually mostly written in C++)
9.
Copyright © 2017
M/Gateway Developments Ltd Asynchronous Syntax in Other Languages? • Node.js isn't unique in supporting asynchronous logic and non-blocking I/O • Available also in most other modern languages – Java – Python, etc • Allows efficient use of resources when making parallel requests for resources – Files, external web services etc
10.
Copyright © 2017
M/Gateway Developments Ltd Asynchronous Syntax in Node.js • Node.js is unique in that you have no option but to use Asynchronous logic
11.
Copyright © 2017
M/Gateway Developments Ltd Drawbacks of Node.js • In every other language, zealots will encourage you to use it for everything! • But even Node's greatest exponents will tell you not to use it for certain things
12.
Copyright © 2017
M/Gateway Developments Ltd Drawbacks of Node.js • Don't use Node.js if you have: – CPU-intensive logic – Complex database manipulation • Particularly relational database handling
13.
Copyright © 2017
M/Gateway Developments Ltd Drawbacks of Node.js • Don't use Node.js if you have: – CPU-intensive logic • Tie up the CPU and everyone else using the process will be blocked – Complex database manipulation • Particularly relational database handling
14.
Copyright © 2017
M/Gateway Developments Ltd Drawbacks of Node.js • Don't use Node.js if you have: – CPU-intensive logic – Complex database manipulation • Particularly relational database handling – Due to the limitations of asynchronous logic, eg you can't chain functions » Limits creation of very high-level database abstractions
15.
Copyright © 2017
M/Gateway Developments Ltd Main criticism of newbies to Node.js • Asynchronous logic
16.
Copyright © 2017
M/Gateway Developments Ltd Async is the New Sync? • Node.js version 8 now supports Async/Await which greatly improves the syntax needed to handle asynchronous logic – Avoids "callback hell" – Very like synchronous logic
17.
Copyright © 2017
M/Gateway Developments Ltd Async/Await Doesn't solve: • Node.js concurrency – Still need to avoid CPU-intensive code • High-level database abstractions – Proper chaining of functions requires synchronous logic
18.
Copyright © 2017
M/Gateway Developments Ltd Usual Solutions • Use a third-party queue to offload CPU- intensive work to some other environment – RabbitMQ – ZeroMQ • Use another language such as Rails for database-intensive work
19.
Copyright © 2017
M/Gateway Developments Ltd The down-sides • Heterogeneous environment • Multiple skill-sets • Multiple moving parts Node.js RabbitMQ Rails Java Database
20.
Copyright © 2017
M/Gateway Developments Ltd What does Ryan Dahl Think?
21.
Copyright © 2017
M/Gateway Developments Ltd What does Ryan Dahl Think? "..within a single process we could handle many requests by being completely asynchronous. I believed strongly in this idea at the time, but over the past couple of years, I think that’s probably not the be-all and end-all idea for programming."
22.
Copyright © 2017
M/Gateway Developments Ltd What does Ryan Dahl Think? "..when I first started hearing about Go, which was around 2012, they had really easy to use abstractions, that make "blocking I/O", because it’s all in green threads at the interface between Go and the operating system. I think it is actually all non-blocking I/O."
23.
Copyright © 2017
M/Gateway Developments Ltd What does Ryan Dahl Think? "I think Node is not the best system to build a massive server web. I would definitely use Go for that. And honestly, that’s basically the reason why I left Node. It was the realization that: oh, actually, this is not the best server side system ever."
24.
Copyright © 2017
M/Gateway Developments Ltd What do I think? I want to have my Node.js Cake and Eat it!
25.
Copyright © 2017
M/Gateway Developments Ltd I want my Node.js Cake & Eat it • I like JavaScript • I want just one language for everything – 1 skill set – 1 set of moving parts • No extra technologies, thank you – Keep it simple • And I want to be able to use Node.js for all situations
26.
Copyright © 2017
M/Gateway Developments Ltd The Problem is Concurrency • All concurrent users in Node.js share the same process
27.
Copyright © 2017
M/Gateway Developments Ltd The Problem is Concurrency • All concurrent users in Node.js share the same process • As it happens, Amazon Web Services accidentally created a solution – And nobody (including AWS) seems to have realised the consequences of what they've done
28.
Copyright © 2017
M/Gateway Developments Ltd AWS Lambda • "Function As A Service" • AKA "Serverless"
29.
Copyright © 2017
M/Gateway Developments Ltd AWS Lambda • "Function As A Service" • AKA "Serverless" • You upload functions • AWS will execute them – You don't worry about how or on what physical machine(s) • You pay per invocation of your function(s)
30.
Copyright © 2017
M/Gateway Developments Ltd AWS Lambda • The first technology they supported was Node.js
31.
Copyright © 2017
M/Gateway Developments Ltd AWS Concurrency? • Your function will be invoked in a private computation container of some sort • Your function has that container all to itself for the duration of its execution • No competition with other concurrent users
32.
Copyright © 2017
M/Gateway Developments Ltd Lambda Node.js Examples • AWS examples show use of asynchronous APIs • Node.js users of Lambda use asynchronous APIs and Async/Await
33.
Copyright © 2017
M/Gateway Developments Ltd Lambda Node.js Examples • AWS examples show use of asynchronous APIs • Node.js users of Lambda use asynchronous APIs and Async/Await • But unless your Lambda function really needs to be asynchronous, why use asynchronous logic?
34.
Copyright © 2017
M/Gateway Developments Ltd Asynchronous Syntax in Other Languages? • Available also in most other modern languages – Java – Python, etc • Allows efficient use of resources when making parallel requests for resources – Files, external web services etc • But no programmer in those languages would use async logic if they didn't have to
35.
Copyright © 2017
M/Gateway Developments Ltd Async is the New Sync? • Why would Node.js developers use asynchronous logic in Lambda functions if they don't have to? – Partly because that's what you do, right?
36.
Copyright © 2017
M/Gateway Developments Ltd Async is the New Sync? • Why would Node.js developers use asynchronous logic in Lambda functions if they don't have to? – Partly because that's what you do, right? – Partly because almost no synchronous APIs exist, particularly for: • Database integration • Web/REST service access
37.
Copyright © 2017
M/Gateway Developments Ltd Such APIs are possible
38.
Copyright © 2017
M/Gateway Developments Ltd Such APIs are possible
39.
Copyright © 2017
M/Gateway Developments Ltd Any other way… • To have your Node.js cake and eat it? – Not everyone will want to use Lambda • Would it be possible to create a locally- available environment where my Node.js code runs in an isolated container where concurrency isn't an issue?
40.
Copyright © 2017
M/Gateway Developments Ltd
41.
Copyright © 2017
M/Gateway Developments Ltd What Is QEWD? • Essentially it's a multi-purpose Node.js- based run-time Platform
42.
Copyright © 2017
M/Gateway Developments Ltd What Is QEWD? • Essentially it's a multi-purpose Node.js- based run-time Platform • Creates an isolated run-time container for your message/request handler functions, allowing: – CPU-intensive work – Database abstractions using synchronous logic
43.
Copyright © 2017
M/Gateway Developments Ltd QEWD's Architecture • Master Process • Pool of Worker Processes
44.
Copyright © 2017
M/Gateway Developments Ltd QEWD's Architecture • Master Process – Handles and queues all incoming requests from client • HTTP/REST requests via Express or Koa.js • WebSocket requests via socket.io – Returns responses to client
45.
Copyright © 2017
M/Gateway Developments Ltd QEWD's Architecture • Pool of Persistent Worker Processes – Where all the processing occurs – A single queued request is dispatched to an available worker process – Each Worker process handles a single request at a time
46.
Copyright © 2017
M/Gateway Developments Ltd QEWD's Architecture • The queue / dispatcher / worker-process pool management part of QEWD is handled by a module named ewd-qoper8
47.
Copyright © 2017
M/Gateway Developments Ltd Master Node.js Process Queue Queue processor/ dispatcher Incoming Requests QEWD Architecture Every incoming request is passed from Express and placed in a queue No further processing of requests occurs in the master process Express or Koa.js socket.io HTTP REST WebSocket
48.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Queue dispatcher is invoked whenever a request is added to the queue
49.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Node.js Worker Process Master Node.js Process Queue Queue processor/ dispatcher Worker process started if none available
50.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Node.js Worker Process Master Node.js Process Queue Queue processor/ dispatcher Redis/Cache/GT.M QEWD & application-specific Modules loaded Custom Worker Module Custom Worker Module
51.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Node.js Worker Process Master Node.js Process Queue Queue processor/ dispatcher Custom Worker Module Node.js Worker Process Custom Worker Module Request passed to worker Redis/Cache/GT.M
52.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Node.js Worker Process Master Node.js Process Queue Queue processor/ dispatcher Custom Worker Module Worker flagged as Unavailable Node.js Worker Process Custom Worker Module Begin processing message Redis/Cache/GT.M
53.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Unavailable / processing Another incoming request Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M
54.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Node.js Worker Process Master Node.js Process Queue Queue processor/ dispatcher Custom Worker Module Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module If worker pool size not exceeded, another worker is started and request passed to it Redis/Cache/GT.M Redis/Cache/GT.M
55.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M If entire Worker Pool is busy: Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M
56.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher If entire Worker Pool is busy: New requests remain in queue Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M
57.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M As soon as a worker is available again, a queued message can be passed to it Unavailable / processing Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M Available Node.js Worker Process Custom Worker Module Redis/Cache/GT.M
58.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Finished Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Redis/Cache/GT.M A user's handler function signals completion using the function: finished(responseObject); This returns the response object to the master process
59.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Finished Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module Node.js Worker Process Custom Worker Module And the response is returned to the client that sent the original request (via Express/Koa/socket.io) Redis/Cache/GT.M
60.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Available Node.js Worker Process Custom Worker Module The finished() function also automatically returns the worker process back to the available pool So it can now handle the next queued request Redis/Cache/GT.M
61.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Available Node.js Worker Process Custom Worker Module Worker processes, once started, are persistent No start-up / tear-down cost Redis/Cache/GT.M
62.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Node.js concurrency is handled by the master process. 100% asynchronous logic The master process does almost nothing The perfect Node.js application: no CPU-intensive or long- running tasks, so very high-performance Multiple Concurrent Incoming requests
63.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Node.js concurrency is handled by the master process. 100% asynchronous logic The master process does almost nothing The perfect Node.js application: no CPU-intensive or long- running tasks, so very high-performance All the actual work happens in the isolated worker processes Multiple Concurrent Incoming requests
64.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Available Node.js Worker Process Custom Worker Module Worker processes only handle a single request at a time Completely isolated run-time environment for handler functions No need for concerns about Node.js concurrency, so synchronous APIs can be used Redis/Cache/GT.M
65.
Copyright © 2017
M/Gateway Developments Ltd QEWD Architecture Master Node.js Process Queue Queue processor/ dispatcher Available Node.js Worker Process Custom Worker Module Redis/Cache/GT.M Long-running or CPU-intensive logic has no direct impact on other worker processes
66.
Copyright © 2017
M/Gateway Developments Ltd Why not just use child_process? • To avoid the very high performance cost of starting and tearing down each child process – At least 30ms to start a child_process • Each QEWD worker is a child_process – But keeps running, and is re-used
67.
Copyright © 2017
M/Gateway Developments Ltd Why not just use Cluster? • Cluster simply spreads the concurrent requests across a pool of persistent child_processes – If one of them is CPU intensive, all other requests in that cluster are held up • QEWD forces each child_process to handle a single request only – Creates an isolated run-time environment for each request
68.
Copyright © 2017
M/Gateway Developments Ltd Why not just use RabbitMQ or ZeroMQ? • I just want to just use a single technology: Node.js / JavaScript • Initial tests showed no performance benefit in using ZeroMQ
69.
Copyright © 2017
M/Gateway Developments Ltd Performance? • ewd-qoper8 module in isolation: – Handles the queue/master/worker architecture • Raspberry Pi 3 Model B – 4 core CPU – Readily-available commodity item – Low-cost • Easily-replicable benchmark
70.
Copyright © 2017
M/Gateway Developments Ltd Performance • ewd-qoper8 benchmark script provided: – How many workers? 3 – How many messages? 500,000 – Create a steady state of messages added to the queue as they're being processed: • Add a batch of 622 messages at a time • Wait 100ms between each batch – Messages are sent to workers which echo them straight back
71.
Copyright © 2017
M/Gateway Developments Ltd Performance • 5,800 messages/second sustained throughput • Limiting factor is master process hitting 100% CPU • Workers only 30% CPU, so plenty of capacity to do real work at this rate
72.
Copyright © 2017
M/Gateway Developments Ltd What can QEWD be Used For? • Full-stack platform for browser & Native mobile applications – WebSocket or Ajax messaging • Seamlessly swap between transports • All automated and abstracted out of the way – With security also automated for you too
73.
Copyright © 2017
M/Gateway Developments Ltd What can QEWD be Used For? • API server for REST applications • Optional session management – Automated token-based authentication – Server-side (persistent JSON) session storage • Or automated JSON Web Token based: – Authentication – Client-side session storage
74.
Copyright © 2017
M/Gateway Developments Ltd What can QEWD be Used For? • MicroService Platform – With each MicroService supported by its own shared or dedicated QEWD server – Using JWTs • Shared secret on each QEWD server – Using socket.io to provide high-performance, persistent connections between QEWD servers • Secured over HTTPS if required
75.
Copyright © 2017
M/Gateway Developments Ltd QEWD MicroService Fabric ewd-qoper8 queue Express Node.js socket.io Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process ewd-qoper8 queue Express Node.js socket.io Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process ewd-qoper8 queue Express Node.js socket.io Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process User authentication Demographics Pharmacy ewd-qoper8 queue Express Node.js socket.io Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process Cache GT.M, YottaDB Redis Node.js Worker Process Client Orchestration HTTPS WebSocket Connections
76.
Copyright © 2017
M/Gateway Developments Ltd What can QEWD be Used For? • Federation platform – Providing a REST or WebSocket-based middle tier to multiple REST-based back-end servers • of any type, not just QEWD servers – One request in • Routed to all back-end systems and responses combined • Performing a "dance" between federated servers
77.
Copyright © 2017
M/Gateway Developments Ltd Federated Access to OpenEHR Browser QEWD GT.M or Redis ewd-qoper8 queue qewd-ripple Module Express OpenEHR Server AQL over HTTP(S) Worker PulseTile UI OpenEHR Server
78.
Copyright © 2017
M/Gateway Developments Ltd What can QEWD be Used For? • Interface to particular databases known as Global Storage databases – GT.M / YottaDB – Cache / IRIS – Redis (ewd-globals-redis module) • All of which are abstracted as: – Persistent JavaScript Objects – Fine-grained Document Database • Accessible at any level down to individual name/value pair anywhere in a JSON object
79.
Copyright © 2017
M/Gateway Developments Ltd QEWD.js • Resilient / Audit mode – When enabled, permanent record kept in the database of: • Queued requests • Processing status • Response(s) – If QEWD restarted, database is examined for queued, unprocessed requests • Automatically re-queued – Can specify retention period of database records
80.
Copyright © 2017
M/Gateway Developments Ltd QEWD.js • Supports all browser-side JavaScript frameworks • Some cool 3rd -party tooling and support available for React and Vue.js
81.
Copyright © 2017
M/Gateway Developments Ltd Have Your Node.js Cake And Eat It Too http://qewdjs.com