SlideShare uma empresa Scribd logo
1 de 115
Real World Lessons on the Pain Points of
Node.js Applications
@Ben_Hall
Ben@BenHall.me.uk
OcelotUproar.com / Katacoda.com
@Ben_Hall / Blog.BenHall.me.uk
Ocelot Uproar
WHOAMI?
Learn via Interactive Browser-Based Labs
Katacoda.com
Agenda
• Creating strong foundation
– Node v6/v7, NPM, Security
• Error Handling
• Async / Promises
• Deploying / Scaling
• Performance
• Debugging
Provide an overview of our
node.js experiences and the
tasks we wish we did earlier!
Strong Foundations
Upgrading from Node v0.10.38
to v6.1.0
#nodestats for March: Node 6.x hits 48% share, Node 7.x breaks 15%, 0.10 and 0.12 drop
below 10% share for the first time:
https://mobile.twitter.com/i/web/status/838922927735132160
Previous Node Versioning
• Even === Stable
– 0.10, 0.12, 4, 6
• Odd === Beta
– 0.9, 0.11, 5
Node Release Stages
• CURRENT: new features (and bug fixes and
security patches)
• ACTIVE LTS: bug fixes (and security patches)
• MAINTENANCE: only security patches
Docker to test deployment
• Didn’t need to install anything on host
> docker run -it -v $(pwd):/src -p 3000 node:6
root@container:> npm install
root@container:> npm start
Default to Underscore.js ?
Fixing NPM
Lock down NPM dependencies
because no-one respects SemVer
AngularJs 1.2 => 1.3
"dependencies": {
"angular": "^1.2.16”
}
Angular 1.2 => 1.3
> angular.element(document)
[#document]
> angular.element(document)
TypeError: undefined is not a function
Lock Down Dependencies
Randomly breaking builds and
deployments will occur otherwise
$ npm shrinkwrap
Lock down dependencies to what’s
running locally
Hard code versions in
package.json
"dependencies": {
"angular": “1.2.23”
}
$ npm outdated
.npmrc
• https://docs.npmjs.com/misc/config
> cat .npmrc
save=true
save-exact=true
npm install -g
Replaced Glup, Grunt with Make
templates:
handlebars views/templates/*.hbs -f public/js/templates.js
> make templates
Security
Child Process Exec
child_process.exec(req.query.url, function (err, data) {
console.log(data);
});
https://localhost:49155/api/openUrlInDefaultBrowser?url=c:/windows/sy
stem32/calc.exe
Thanks TrendMicro Antivirus on Windows!
https://code.google.com/p/google-security-research/issues/detail?id=693
Cross-Site Request Forgery
var csrf = require('csurf');
var csrfProtection = csrf({ cookie: true });
var parseForm = bodyParser.urlencoded({ extended: false });
app.get('/form', csrfProtection, function(req, res) {
res.render('send', { csrfToken: req.csrfToken() });
});
app.post('/process', parseForm, csrfProtection, function(req, res) {
res.send('data is being processed');
});
https://blog.risingstack.com/node-js-security-checklist/
Rate Limiting
var ratelimit = require('koa-ratelimit');
var ipBasedRatelimit = ratelimit({
db: redis.createClient(),
duration: 60000,
max: 10,
id: function (context) {
return context.ip;
}
});
app.post('/login', ipBasedRatelimit, handleLogin);
https://blog.risingstack.com/node-js-security-checklist/
Security Audit NPM Packages
> npm install nsp
> nsp check
(+) 18 vulnerabilities found
https://nodesecurity.io/
• Root Path Disclosure (2x)
• Regular Expression Denial of Service (10x)
• Incorrect Handling of Non-Boolean Comparisons
During Minification
• Denial-of-Service Extended Event Loop Blocking
• Denial-of-Service Memory Exhaustion
• Symlink Arbitrary File Overwrite
• Remote Memory Disclosure (2x)
NPM Credentials Leaks
• https://github.com/ChALkeR/notes/blob/mast
er/Do-not-underestimate-credentials-
leaks.md
https://blog.acolyer.org/2017/03/07/thou-shalt-not-depend-on-me-analysing-the-use-of-
outdated-javascript-libraries-on-the-web/
Create Strong Foundations
Error Handling
Wasn’t great from the start
Try {} Catch {}
Try {} Catch {}
Domains haven’t really worked
https://raw.githubusercontent.com/strongloop/zone/master/showcase/curl/curl-zone.js
Zones? No. Not really
Returning String as Error
Strongly typed errors
Async Flow Control
Promises
Promises… Promises… Never break
your promises.
Personally, I never make promises.
http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/
Callbacks
So good it’s got it’s own website
callbackhell.com
“The goal isn’t about removing
levels of indentation but rather
writing modular code that is easy to
reason about”
Strongloop Blog
http://strongloop.com/strongblog/node-js-callback-hell-promises-generators/
Loops + Async Callbacks
Loops + Async Callbacks
“You can't get into callback hell if
you don't go there.”
Isaac Schlueter
Node 7 – Async Await
class Demo {
async greeting() {
const h = await this.world();
return h;
}
world() {
return Promise.resolve('hello world');
}
}
const retval = await demo.greeting();
Node 7 – Async Await Errors
async getPersonFullNameWithTryCatch() {
try {
let response = await fetch('./data/person2.json');
}
catch(e) {
console.log('there was an error');
console.log(e);
}
}
DEPLOY!
Single Threaded
CPU Intensive?
Array Filtering / Sorting / Processing
Maybe not use Node?
Golang has a great community
Where Node was a few years ago?
Have more threads
Solved Problem?
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
// Workers can share any TCP connection
// In this case it is an HTTP server
http.createServer(function(req, res) {
res.writeHead(200);
res.end("hello worldn");
}).listen(8000);
}
> NODE_DEBUG=cluster node server.js
23521,Master Worker 23524 online
23521,Master Worker 23526 online
23521,Master Worker 23523 online
23521,Master Worker 23528 online
Deploying with Docker
Container
https://www.docker.com/whatisdocker/
Container
Deploying Node App via Docker
> cat Dockerfile
FROM node:6-onbuild
EXPOSE 3000
> docker build –t my-node-app .
> docker run –p 3000:3000 my-node-app
59,040
environments/day/server
112,320
environments/day/server
> docker run -d 
-p 80:80 
-v /var/run/docker.sock:/tmp/docker.sock:ro 
jwilder/nginx-proxy
> docker run --name web 
-e VIRTUAL_HOST=www.katacoda.com
my-node-app
Load Balancer
Nginx Proxy
Node Node
Node Node
Node Node
Nginx Proxy
Node Node
Node Node
Node Node
Nginx Proxy
Node Node
Node Node
Node Node
Health Endpoints
router.get('/_specialfunctions/_check', function(req, res) {
async.parallel([
check_docker,
check_starter,
check_redis,
check_pg
], function(err, results) {
if(err) {
console.log("Health check failed", err);
res.status(500);
return res.json({healthy: false, details: err});
}
res.json({healthy: true});
})
});
var check_docker = function(cb) {
docker.ping(function(err) { handle_error('docker', err, cb);});
};
var check_redis = function(cb) {
redis.status(function(err, connected) {
if(err === null && connected === "ready") {
cb();
} else {
handle_error('redis', {msg: 'Not Connected', err: err}, cb);
}
})
};
var check_pg = function(cb) {
pg.status(function(err) { handle_error('postgres', err, cb);});
};
Careful!
socket.io and global state
Sticky Sessions
Compiled Nginx + OSS Modules
Global State as a Service
Microservices FTW!!
Code Performance Still Matters
Performance
> npm install v8-profiler
const profiler = require('v8-profiler')
const fs = require('fs')
var profilerRunning = false
function toggleProfiling () {
if (profilerRunning) {
const profile = profiler.stopProfiling()
console.log('stopped profiling')
profile.export()
.pipe(fs.createWriteStream('./myapp-'+Date.now()+'.cpuprofile'))
.once('error', profiler.deleteAllProfiles)
.once('finish', profiler.deleteAllProfiles)
profilerRunning = false
return
}
profiler.startProfiling()
profilerRunning = true
console.log('started profiling')
}
process.on('SIGUSR2', toggleProfiling)
> kill -SIGUSR2 <pid>
JetBrains WebStorm
OpenTracing - Zipkin
Prometheus + Grafana
Debugging
require(‘debug’);
Webstorm
VS Code
Profiling Node Applications
March 10, 2017 @ 09:00 Fontaine E
Real-Time Monitoring with
Grafana, StatsD and InfluxDB
March 10, 2017 @ 15:00
Testing?!
Summary
• Upgrade to Node.js v6
• Start looking at ES6 / Node 7
• Security
• Manage your errors
• Forgot making promises
• Scale using Docker
Thank you!
@Ben_Hall
Ben@BenHall.me.uk
www.Katacoda.com

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Lessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersLessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containers
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Exploring Docker Security
Exploring Docker SecurityExploring Docker Security
Exploring Docker Security
 
Docker All The Things - ASP.NET 4.x and Windows Server Containers
Docker All The Things - ASP.NET 4.x and Windows Server ContainersDocker All The Things - ASP.NET 4.x and Windows Server Containers
Docker All The Things - ASP.NET 4.x and Windows Server Containers
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource Consulting
 
Docker orchestration v4
Docker orchestration v4Docker orchestration v4
Docker orchestration v4
 
DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains  DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
DCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on KubernetesDCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on Kubernetes
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
 
Docker在豆瓣的实践 刘天伟-20160709
Docker在豆瓣的实践 刘天伟-20160709Docker在豆瓣的实践 刘天伟-20160709
Docker在豆瓣的实践 刘天伟-20160709
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
 
青云虚拟机部署私有Docker Registry
青云虚拟机部署私有Docker Registry青云虚拟机部署私有Docker Registry
青云虚拟机部署私有Docker Registry
 
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and ChefScaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
 
kubernetes practice
kubernetes practicekubernetes practice
kubernetes practice
 

Destaque

Panorama internacional y situación española
Panorama internacional y situación españolaPanorama internacional y situación española
Panorama internacional y situación española
alba galan
 

Destaque (20)

Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with KubernetesTips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
 
Strengthen your talent_brand
Strengthen your talent_brandStrengthen your talent_brand
Strengthen your talent_brand
 
Recognizing the cultural bias in Artificial Intelligence
Recognizing the cultural bias in Artificial IntelligenceRecognizing the cultural bias in Artificial Intelligence
Recognizing the cultural bias in Artificial Intelligence
 
Area of composite shapes
Area of composite shapesArea of composite shapes
Area of composite shapes
 
Los Riesgos en Emprendimientos de TI - Claudia Araujo Michel (YANAPTI CORP)
Los Riesgos en Emprendimientos de TI - Claudia Araujo Michel (YANAPTI CORP)Los Riesgos en Emprendimientos de TI - Claudia Araujo Michel (YANAPTI CORP)
Los Riesgos en Emprendimientos de TI - Claudia Araujo Michel (YANAPTI CORP)
 
Localizing Your eLearning Course
Localizing Your eLearning CourseLocalizing Your eLearning Course
Localizing Your eLearning Course
 
Cartilla planificacion-curricular
Cartilla planificacion-curricularCartilla planificacion-curricular
Cartilla planificacion-curricular
 
El periódico
El periódicoEl periódico
El periódico
 
Manual corporativo lalhita's
Manual corporativo lalhita'sManual corporativo lalhita's
Manual corporativo lalhita's
 
Panorama internacional y situación española
Panorama internacional y situación españolaPanorama internacional y situación española
Panorama internacional y situación española
 
Ventajas y desventajas de calameo y slideshare
Ventajas y desventajas de calameo y slideshareVentajas y desventajas de calameo y slideshare
Ventajas y desventajas de calameo y slideshare
 
Trabajo en Equipo, un recurso del liderazgo - Ana María Ribera (HUMAN VALUE)
Trabajo en Equipo, un recurso del liderazgo - Ana María Ribera (HUMAN VALUE)Trabajo en Equipo, un recurso del liderazgo - Ana María Ribera (HUMAN VALUE)
Trabajo en Equipo, un recurso del liderazgo - Ana María Ribera (HUMAN VALUE)
 
Lfz apresentação 2017
Lfz apresentação 2017 Lfz apresentação 2017
Lfz apresentação 2017
 
Microservices Minus the Hype: How to Build and Why
Microservices Minus the Hype: How to Build and WhyMicroservices Minus the Hype: How to Build and Why
Microservices Minus the Hype: How to Build and Why
 
BSW Salem State Project
BSW Salem State ProjectBSW Salem State Project
BSW Salem State Project
 
Tecnologias educacionais e tecnologias da informação e comunicação
Tecnologias educacionais e tecnologias da informação e comunicaçãoTecnologias educacionais e tecnologias da informação e comunicação
Tecnologias educacionais e tecnologias da informação e comunicação
 
Prescripcion ,, tesis
Prescripcion ,, tesisPrescripcion ,, tesis
Prescripcion ,, tesis
 
UNICO Riviera Maya
UNICO Riviera MayaUNICO Riviera Maya
UNICO Riviera Maya
 
Una llamada al amor tony de mello
Una llamada al amor   tony de melloUna llamada al amor   tony de mello
Una llamada al amor tony de mello
 
Medicion de la productividad del valor agregado
Medicion de la productividad del valor agregadoMedicion de la productividad del valor agregado
Medicion de la productividad del valor agregado
 

Semelhante a Real World Lessons on the Pain Points of Node.JS Application

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 

Semelhante a Real World Lessons on the Pain Points of Node.JS Application (20)

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Node azure
Node azureNode azure
Node azure
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 

Mais de Ben Hall

Mais de Ben Hall (17)

The Art Of Documentation - NDC Porto 2022
The Art Of Documentation - NDC Porto 2022The Art Of Documentation - NDC Porto 2022
The Art Of Documentation - NDC Porto 2022
 
The Art Of Documentation for Open Source Projects
The Art Of Documentation for Open Source ProjectsThe Art Of Documentation for Open Source Projects
The Art Of Documentation for Open Source Projects
 
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside ContainersThree Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside Containers
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
 
The Art of Documentation and Readme.md for Open Source Projects
The Art of Documentation and Readme.md for Open Source ProjectsThe Art of Documentation and Readme.md for Open Source Projects
The Art of Documentation and Readme.md for Open Source Projects
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
The Challenges of Becoming Cloud Native
The Challenges of Becoming Cloud NativeThe Challenges of Becoming Cloud Native
The Challenges of Becoming Cloud Native
 
The art of documentation and readme.md
The art of documentation and readme.mdThe art of documentation and readme.md
The art of documentation and readme.md
 
Experimenting and Learning Kubernetes and Tensorflow
Experimenting and Learning Kubernetes and TensorflowExperimenting and Learning Kubernetes and Tensorflow
Experimenting and Learning Kubernetes and Tensorflow
 
Learning Patterns for the Overworked Developer
Learning Patterns for the Overworked DeveloperLearning Patterns for the Overworked Developer
Learning Patterns for the Overworked Developer
 
Implementing Google's Material Design Guidelines
Implementing Google's Material Design GuidelinesImplementing Google's Material Design Guidelines
Implementing Google's Material Design Guidelines
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 
The Art Of Building Prototypes and MVPs
The Art Of Building Prototypes and MVPsThe Art Of Building Prototypes and MVPs
The Art Of Building Prototypes and MVPs
 
Node.js Anti Patterns
Node.js Anti PatternsNode.js Anti Patterns
Node.js Anti Patterns
 
What Designs Need To Know About Visual Design
What Designs Need To Know About Visual DesignWhat Designs Need To Know About Visual Design
What Designs Need To Know About Visual Design
 
Real World Lessons On The Anti-Patterns of Node.JS
Real World Lessons On The Anti-Patterns of Node.JSReal World Lessons On The Anti-Patterns of Node.JS
Real World Lessons On The Anti-Patterns of Node.JS
 
Learning to think "The Designer Way"
Learning to think "The Designer Way"Learning to think "The Designer Way"
Learning to think "The Designer Way"
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Real World Lessons on the Pain Points of Node.JS Application

Notas do Editor

  1. var d = require('domain').create(); d.on('error', function(err){ // handle the error safely console.log(err); }); // catch the uncaught errors in this // asynchronous or synchronous code block d.run(function(){ // the asynchronous or synchronous code // that we want to catch thrown errors on var err = new Error('example'); throw err; });
  2. var util = require('util'); function UserNameAlreadyExistsError(err) { Error.call(this); this.name = 'UserNameAlreadyExistsError'; if(typeof err === 'string') { this.message = err; } else { this.message = err.message; } this.detail = err.details; } util.inherits(UserNameAlreadyExistsError, Error); module.exports = UserNameAlreadyExistsError;
  3. getTweetsFor("domenic") // promise-returning function .then(function (tweets) { var shortUrls = parseTweetsForUrls(tweets); var mostRecentShortUrl = shortUrls[0]; return expandUrlUsingTwitterApi(mostRecentShortUrl); // promise-returning function }) .then(httpGet) // promise-returning function .then( function (responseBody) { console.log("Most recent link text:", responseBody); }, function (error) { console.error("Error with the twitterverse:", error); } );
  4. var repo_url = $(site).find('li[data-tab="repo"]').find('a').attr('href'); var activity_url = $(site).find('li[data-tab="activity"]').find('a').attr('href'); request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $(p).find('.repolist-name a').attr('href'), title: $(p).find('.repolist-name').text().clean(), stars: parseInt($(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $(p).find('.language').text()}; if(repo_list.length === (ix + 1)) { request.get("https://github.com" + activity_url, function(err, activity_html) { var $_activity = cheerio.load(activity_html); var repo_list = $_activity('.alert'); var results = []; repo_list.each(function(ix, p) { var repo = {title: $(p).find('.title').text().clean(), actioned_at: $(p).find('.js-relative-date').attr('datetime')}; results.push(repo); if(repo_list.length === (ix + 1)) { data.repositories = results.repo; data.public_activity = results.activity; callback({parser: 'github', id: data.username, profile: data}); } }); }); } }); });
  5. var repo_url = $(site).find('li[data-tab="repo"]').find('a').attr('href'); var activity_url = $(site).find('li[data-tab="activity"]').find('a').attr('href'); request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $(p).find('.repolist-name a').attr('href'), title: $(p).find('.repolist-name').text().clean(), stars: parseInt($(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $(p).find('.language').text()}; if(repo_list.length === (ix + 1)) { request.get("https://github.com" + activity_url, function(err, activity_html) { var $_activity = cheerio.load(activity_html); var repo_list = $_activity('.alert'); var results = []; repo_list.each(function(ix, p) { var repo = {title: $(p).find('.title').text().clean(), actioned_at: $(p).find('.js-relative-date').attr('datetime')}; results.push(repo); if(repo_list.length === (ix + 1)) { data.repositories = results.repo; data.public_activity = results.activity; callback({parser: 'github', id: data.username, profile: data}); } }); }); } }); });
  6. var repo_url = $(site).find('li[data-tab="repo"]').find('a').attr('href'); var activity_url = $(site).find('li[data-tab="activity"]').find('a').attr('href'); request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $(p).find('.repolist-name a').attr('href'), title: $(p).find('.repolist-name').text().clean(), stars: parseInt($(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $(p).find('.language').text()}; if(repo_list.length === (ix + 1)) { request.get("https://github.com" + activity_url, function(err, activity_html) { var $_activity = cheerio.load(activity_html); var repo_list = $_activity('.alert'); var results = []; repo_list.each(function(ix, p) { var repo = {title: $(p).find('.title').text().clean(), actioned_at: $(p).find('.js-relative-date').attr('datetime')}; results.push(repo); if(repo_list.length === (ix + 1)) { data.repositories = results.repo; data.public_activity = results.activity; callback({parser: 'github', id: data.username, profile: data}); } }); }); } }); });
  7. var repo_url = $(site).find('li[data-tab="repo"]').find('a').attr('href'); var activity_url = $(site).find('li[data-tab="activity"]').find('a').attr('href'); request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $(p).find('.repolist-name a').attr('href'), title: $(p).find('.repolist-name').text().clean(), stars: parseInt($(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $(p).find('.language').text()}; if(repo_list.length === (ix + 1)) { request.get("https://github.com" + activity_url, function(err, activity_html) { var $_activity = cheerio.load(activity_html); var repo_list = $_activity('.alert'); var results = []; repo_list.each(function(ix, p) { var repo = {title: $(p).find('.title').text().clean(), actioned_at: $(p).find('.js-relative-date').attr('datetime')}; results.push(repo); if(repo_list.length === (ix + 1)) { data.repositories = results.repo; data.public_activity = results.activity; callback({parser: 'github', id: data.username, profile: data}); } }); }); } }); });
  8. var repo_url = $(site).find('li[data-tab="repo"]').find('a').attr('href'); var activity_url = $(site).find('li[data-tab="activity"]').find('a').attr('href'); request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $(p).find('.repolist-name a').attr('href'), title: $(p).find('.repolist-name').text().clean(), stars: parseInt($(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $(p).find('.language').text()}; if(repo_list.length === (ix + 1)) { request.get("https://github.com" + activity_url, function(err, activity_html) { var $_activity = cheerio.load(activity_html); var repo_list = $_activity('.alert'); var results = []; repo_list.each(function(ix, p) { var repo = {title: $(p).find('.title').text().clean(), actioned_at: $(p).find('.js-relative-date').attr('datetime')}; results.push(repo); if(repo_list.length === (ix + 1)) { data.repositories = results.repo; data.public_activity = results.activity; callback({parser: 'github', id: data.username, profile: data}); } }); }); } }); });
  9. var parse_repositories = function(repo_url, callback) { request.get("http://github.com" + repo_url, function(rr, repo_html) { var $_repo = cheerio.load(repo_html); var repo_list = $_repo('.repolist li'); var results = []; repo_list.each(function(ix, p) { var source = true; if($_repo(p).hasClass('fork')) source = false; var repo = { link: "http://github.com" + $_repo(p).find('.repolist-name a').attr('href'), title: $_repo(p).find('.repolist-name').text().clean(), stars: parseInt($_repo(p).find('.stargazers a').text().clean(), 10), is_source: source, language: $_repo(p).find('.language').text()}; if(repo.title !== '') { results.push(repo); } if(repo_list.length === (ix + 1)) { callback(null, results); } }); if(repo_list.length === 0) { callback(null, []); } }); };
  10. Story
  11. Story