Suche senden
Hochladen
Presentation @ Node.js Global Summit 2020 - Online
•
0 gefällt mir
•
399 views
Alessandro Polidori
Folgen
Speaking about REST API performance improvements with Node.js Fastify Framework
Weniger lesen
Mehr lesen
Software
Melden
Teilen
Melden
Teilen
1 von 57
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Port knocking
Port knocking
Ramalhev90
Programa simulador de gerador eólico
Programa simulador de gerador eólico
Simuladorgeradoreolico
InterAS MPLS-VPN with RyuBgp
InterAS MPLS-VPN with RyuBgp
Toshiki Tsuboi
Netstatoutput
Netstatoutput
annaoc99
Image Fundamental
Image Fundamental
Lusiana Diyan
JS Audio/Video Streaming: WebRTC APIs 101 explained
JS Audio/Video Streaming: WebRTC APIs 101 explained
Alessandro Polidori
Presentation at ClueCon 2019 - Chicago, IL, USA 🇺🇸
Presentation at ClueCon 2019 - Chicago, IL, USA 🇺🇸
Alessandro Polidori
Presentation at JSConf.be 2019 - Alessandro Polidori
Presentation at JSConf.be 2019 - Alessandro Polidori
Alessandro Polidori
Empfohlen
Port knocking
Port knocking
Ramalhev90
Programa simulador de gerador eólico
Programa simulador de gerador eólico
Simuladorgeradoreolico
InterAS MPLS-VPN with RyuBgp
InterAS MPLS-VPN with RyuBgp
Toshiki Tsuboi
Netstatoutput
Netstatoutput
annaoc99
Image Fundamental
Image Fundamental
Lusiana Diyan
JS Audio/Video Streaming: WebRTC APIs 101 explained
JS Audio/Video Streaming: WebRTC APIs 101 explained
Alessandro Polidori
Presentation at ClueCon 2019 - Chicago, IL, USA 🇺🇸
Presentation at ClueCon 2019 - Chicago, IL, USA 🇺🇸
Alessandro Polidori
Presentation at JSConf.be 2019 - Alessandro Polidori
Presentation at JSConf.be 2019 - Alessandro Polidori
Alessandro Polidori
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Weitere ähnliche Inhalte
Empfohlen
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Empfohlen
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Presentation @ Node.js Global Summit 2020 - Online
1.
A world of
Rest APIs… from Restify to a faster Fastify ALESSANDRO POLIDORI Senior Software Engineer ale_polidori Node.js Global Summit 2020
2.
2009 2020
3.
Debug in PRODUCTION
?
4.
Photo by Matteo
Cappè
5.
Debug in PRODUCTION
?
6.
7.
NethCTI Backend REST
API
8.
M I G
R A T I O N
9.
Internet (PSTN) server REST /
WS REST / WS REST / WS REST / WS PBX 1 2 3
10.
Internet (PSTN) server REST /
WS REST / WS REST / WS REST / WS PBX 1 2 Event: BridgeEnter Privilege: call,all BridgeUniqueid: c2c967b6-9044 BridgeType: basic BridgeTechnology: simple_bridge BridgeCreator: <unknown> BridgeName: <unknown> BridgeNumChannels: 1 BridgeVideoSourceMode: none Channel: PJSIP/Nethesis-00000123 ChannelState: 6 ChannelStateDesc: Up CallerIDNum: 3401234567 CallerIDName: 3401234567 ConnectedLineNum: 072112345 ConnectedLineName: <unknown> Language: it AccountCode: 223 Context: from-pstn Exten: Priority: 1 Uniqueid: 1590499030.97474 Linkedid: 1590499029.97472 { "connected": true, "counterpartName": "3401234567", "counterpartNum": "3401234567", "direction": "out", "duration": 19, "id": "PJSIP/91223-00000", "inConference": false, "linkedId": "1590499772.97717", "owner": "91223", "recording": "false", "startTime": 1590499772000, "throughQueue": false } 3
11.
Internet (PSTN) REST /
WS REST / WS REST / WS REST / WS PBX 1 3 Asterisk-Proxy Database Config Phonebook CustomerCard Exec-Script User Call History REST Phonebook REST CustCard REST History RESTAstProxy WebSocket
12.
Internet (PSTN) REST /
WS REST / WS REST / WS REST / WS PBX 1 3
13.
Internet (PSTN) REST /
WS REST / WS REST / WS REST / WS PBX 1 3
14.
Unresponsive Client 100% CPU
15.
Debug in PRODUCTION
? How To Reproduce
16.
Internet (PSTN) S I P e s
s i o n n i t i a t i o n r o t o c o l
17.
18.
#sipp -sf register_invite_client.xml -inf
register_invite_client.csv 192.168.5.80 -m 100 -d 10000 -r 10
19.
FlameGraph
20.
FlameGraph 1. capture the
stacks 2. fold the stack 3. create svg image
21.
22.
23.
0x 1. installation: npm
install -g 0x 2. exec: 0x my-server.js 3. image creation: SIGINT
24.
npm i autocannon
-g
25.
HTTP Pipelining https://en.wikipedia.org/wiki/HTTP_pipelining
26.
27.
28.
REST Phonebook REST CustCard REST
History RESTAstProxy WebSocket Node http-proxy{ REST-API }
29.
M I G
R A T I O N
30.
var restify = require('restify'); var plugins = require('jsplugs')().require('./plugins/com_astproxy_rest/plugins_rest'); for (p in plugins) { get = plugins[p].api.get; root = plugins[p].api.root; post = plugins[p].api.post; del = plugins[p].api.del; // add routing functions for (k in get) { server.get('/' + root + '/' + get[k], execute); } // post... } server.listen(port, address, function() { logger.log.info(IDLOG, server.name + ' listening at ' + server.url); }); T
h e O l d C o d e
31.
var restify = require('restify'); var plugins = require('jsplugs')().require('./plugins/com_astproxy_rest/plugins_rest'); for (p in plugins) { get = plugins[p].api.get; root = plugins[p].api.root; post = plugins[p].api.post; del = plugins[p].api.del; // add routing functions for (k in get) { server.get('/' + root + '/' + get[k], execute); } // post } server.listen(port, address, function() { logger.log.info(IDLOG, server.name + ' listening at ' + server.url); }); T
h e O l d C o d e
32.
var fastify = require('fastify')({ logger: false }); var plugins = require(‘jsplugs')().require('./plugins/com_astproxy_rest/plugins_rest'); for (p in plugins) { get = plugins[p].api.get; // add routing functions for (k in get) { fastify.get('/' + root + '/' + get[k], plugins[p][get[k] + '_schema'], execute); } } fastify.listen(port, address, function (err, address) { if (err) { fastify.log.error(err) process.exit(1) } fastify.log.info(`fastify server listening on ${address}`) }); T h e
N e w C o d e
33.
var fastify = require('fastify')({ logger: false }); var plugins = require(‘jsplugs')().require('./plugins/com_astproxy_rest/plugins_rest'); for (p in plugins) { get = plugins[p].api.get; // add routing functions for (k in get) { fastify.get('/' + root + '/' + get[k], plugins[p][get[k] + '_schema'], execute); } } fastify.listen(port, address, function (err, address) { if (err) { fastify.log.error(err) process.exit(1) } fastify.log.info(`fastify server listening on ${address}`) }); T h e
N e w C o d e
34.
var fastify = require('fastify')({ logger: false }); var plugins = require(‘jsplugs')().require('./plugins/com_astproxy_rest/plugins_rest'); for (p in plugins) { get = plugins[p].api.get; // add routing functions for (k in get) { fastify.get('/' + root + '/' + get[k], plugins[p][get[k] + '_schema'], execute); } } fastify.listen(port, address, function (err, address) { if (err) { fastify.log.error(err) process.exit(1) } fastify.log.info(`fastify server listening on ${address}`) }); T h e
N e w C o d e
35.
M I G
R A T I O N HTTP GET astproxy/extensions
36.
Test Scenario 1 Virtual
Machine on MBP 2,7 GHz Intel Core i5 • 1 CPU • 1 GB RAM • 10 Phone Extensions
37.
$ autocannon -c 100 -d
10 -l https://$IP/astproxy/extensions # concurrent connections 10 secs: test duration print latency
38.
Running 10s test
@ https://192.168.11.22/webrest/astproxy/extensions 100 connections ┌─────────┬────────┬────────┬─────────┬─────────┬───────────┬───────────┬────────────┐ │ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │ ├─────────┼────────┼────────┼─────────┼─────────┼───────────┼───────────┼────────────┤ │ Latency │ 158 ms │ 226 ms │ 1490 ms │ 1671 ms │ 270.33 ms │ 233.65 ms │ 1748.84 ms │ └─────────┴────────┴────────┴─────────┴─────────┴───────────┴───────────┴────────────┘ ┌───────────┬─────┬──────┬─────────┬─────────┬─────────┬────────┬────────┐ │ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │ ├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤ │ Req/Sec │ 0 │ 0 │ 414 │ 511 │ 366.5 │ 145.5 │ 204 │ ├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤ Restify performance
39.
Running 10s test
@ https://192.168.11.22/webrest/astproxy/extensions 100 connections ┌─────────┬────────┬────────┬────────┬─────────┬───────────┬───────────┬────────────┐ │ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │ ├─────────┼────────┼────────┼────────┼─────────┼───────────┼───────────┼────────────┤ │ Latency │ 128 ms │ 169 ms │ 540 ms │ 1544 ms │ 212.24 ms │ 197.89 ms │ 1778.33 ms │ └─────────┴────────┴────────┴────────┴─────────┴───────────┴───────────┴────────────┘ ┌───────────┬─────┬──────┬─────────┬─────────┬─────────┬────────┬────────┐ │ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │ ├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤ │ Req/Sec │ 0 │ 0 │ 524 │ 658 │ 468.4 │ 204.98 │ 153 │ ├───────────┼─────┼──────┼─────────┼─────────┼─────────┼────────┼────────┤ Fastify performance
40.
I m p
r o v e A G A I N ? Is it possible ?
41.
fastify-http-proxy github.com/fastify/fastify-http-proxy
42.
REST Phonebook REST CustCard REST
History RESTAstProxy WebSocket { REST-API } Node http-proxy
43.
Running 10s test
@ https://192.168.11.22/webrest/astproxy/extensions 100 connections ┌─────────┬───────┬────────┬────────┬─────────┬───────────┬───────────┬────────────┐ │ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │ ├─────────┼───────┼────────┼────────┼─────────┼───────────┼───────────┼────────────┤ │ Latency │ 82 ms │ 121 ms │ 218 ms │ 1363 ms │ 143.46 ms │ 153.47 ms │ 1530.87 ms │ └─────────┴───────┴────────┴────────┴─────────┴───────────┴───────────┴────────────┘ ┌───────────┬─────┬──────┬─────────┬─────────┬────────┬────────┬─────────┐ │ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │ ├───────────┼─────┼──────┼─────────┼─────────┼────────┼────────┼─────────┤ │ Req/Sec │ 0 │ 0 │ 776 │ 906 │ 692.2 │ 259.05 │ 468 │ ├───────────┼─────┼──────┼─────────┼─────────┼────────┼────────┼─────────┤ Fastify with HTTP-PROXY
44.
const Fastify = require('fastify'); const serverF = Fastify({ logger: false }); const proxyF = require(‘fastify-http-proxy'); serverF.register(proxyF, { upstream: http://myserver, prefix: ‘/astproxy’, preHandler: function (req, res, done) { if (!req.headers.authorization) { // do ahutentication } } } serverF.listen(port, address, (err, address) => {
... }); f a s t i f y - h t t p - p r o x y
45.
0 175 350 525 700 Restify Fastify Rest
Fastify Proxy + Rest +48% +22% Req/sec Autocannon results
46.
I want a R
E A L S C E N A R I O ! ! !
47.
Test Scenario 2
48.
Test Scenario 2 ┌───────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ │
Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │ ├───────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ │ Req/Sec │ 51 │ 51 │ 180 │ 239 │ 164.65 │ 57.3 │ 51 │ ├───────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ │ Bytes/Sec │ 165 kB │ 165 kB │ 582 kB │ 773 kB │ 532 kB │ 185 kB │ 165 kB │ └───────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘ ┌───────────┬─────┬──────┬────────┬────────┬────────┬────────┬────────┐ │ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │ ├───────────┼─────┼──────┼────────┼────────┼────────┼────────┼────────┤ │ Req/Sec │ 0 │ 0 │ 236 │ 285 │ 213.6 │ 70.19 │ 45 │ ├───────────┼─────┼──────┼────────┼────────┼────────┼────────┼────────┤ │ Bytes/Sec │ 0 B │ 0 B │ 772 kB │ 932 kB │ 698 kB │ 229 kB │ 147 kB │ └───────────┴─────┴──────┴────────┴────────┴────────┴────────┴────────┘ +33% restify Fastify
49.
Something about Fastify
50.
Fastify story
51.
Fastify story
52.
Rest API
53.
Plugin
54.
Features Plugins
55.
• https://github.com/fastify/help • https://gitter.im/fastify •
Stack Overflow Help
56.
www.fastify.io
57.
ALESSANDRO POLIDORI Senior Software
Engineer ale_polidori alessandropolidori alepolidori
Jetzt herunterladen