SlideShare ist ein Scribd-Unternehmen logo
1 von 62
1
Node.js and Azure
1
Building Applications for the Web
2
Jason Gerard
•Director of Product Development, PaySpan Inc. (www.payspan.com)
•Developing software for 15 years (VB, COM, JAVA, .NET)
•Focus on SaaS
•Married with 3 kids
3
What is node.js
•Created by Ryan Dahl in 2009
•Platform for asynchronous JavaScript
•Event based programming
• Event loop fundamental structure
•DIRTy
• Data Intensive Real Time
•Solution for c10k problem
4
Architecture
• Written in C++ and JavaScript
• 20k lines of C++, 2k lines of JavaScript
• Built with Chrome’s V8 JavaScript Engine
• Libev
• Native Event Loop
• Libeio
• uses POSIX threads to provide async IO
• Evcom
• Stream socket library built on libev
• udns
5
Events vs. Threads
• Threads
• Each request gets its own thread
• Thread can’t process another request until it’s done with current
• 2 MB stack per thread
• Context Switching
• Events
• Each request is added to a queue
• Processed by single thread
• Only one thread, no context switching
5
6
Why JavaScript?
•Ubiquitous
• Everyone knows it
•“WORA”
• Stole Java’s name and beat it at it’s own game
•Front end developers can easily transition to server development
• Already used to event based programming
7
ASYNCHRONOUS JAVASCRIPT
• Same programming model as web browser
• Wait for events
• Non Blocking IO
• Uses Callbacks
7
8
Callbacks
• “Everything” is a callback
• Only one thread, don’t block it
• Building Blocks of Async Programming
8
9
Consuming Events
• Example with sockets
9
10
Event Emitters
• EventEmitter class
• emitter.addListener(event, listener)
• emitter.on(event, listener)
• emitter.once(event, listener)
• emitter.removeListener(event, listener)
• emitter.removeAllListeners([event])
• emitter.setMaxListeners(n)
• emitter.listeners(event)
• emitter.emit(event, [arg1], [arg2], [...])
11
Event Example
11
12
Nodemon
• Monitors for file changes
• Automatically restarts node process
• nodemon app.js
12
13
Package Management
• npm
• command for creating, installing, updating packages
• npm test (runs test scripts)
• package.json
• JSON file describing package
13
14
npm
• npm install
• npm install module_name
• npm install -g module_name (don’t forget to sudo)
14
15
package.json
15
16
Web Development
• Node’s bread and butter
• Basic HTTP server right in the box
16
17
Connect
• Extends HTTP support
• Adds concept of “middleware”
• function (req, res, next){
//do something
next();}
• Configured with use() method
• Order IS important
17
18
Middleware Example
18
19
Express
• Framework built on top of connect
• Provides view engine facilities
• Routes
• Many helper functions
19
20
Express Routing
• Inspired by Sinatra (ruby)
• /users
• /users/:id
• regex
20
21
Express Routing
• app.VERB() where verb is an HTTP verb (get, post, etc...)
• app.all() execute for all verbs
• req.query for querystring parameters
• req.body for POST, must use bodyParser middleware
21
22
Error Handling
• Basic middleware
• function handler(err, req, res, next)
22
23
View Engines
• EJS
• Jade
• Mustache
• Hogan
• Dust
• Swig
• Flatiron Plates
23
24
EJS
24
25
Jade
25
26
Mustache
26
27
Mustache Output
27
28
Mustache derivatives
• Hogan (builded with express, built by twitter)
• Handlebars
28
29
Flatiron Plates
• Created by nodejitsu
• Pure HTML binding
29
30
Consolidate
• Provides support for many view engines
• Exposes each view engine as Express middleware
• Wraps each view invocation in function
• function x(path[, locals], callback)
• Same format Express uses
30
31
Consolidate supported Template Engines
• atpl
• dust
• eco
• ejs
• haml
• haml-coffee
• handlebars
• hogan
• jade
• jazz
31
• jqtpl
• JUST
• liquor
• mustache
• QEJS
• swig
• templayed
• toffee
• underscore
• walrus
• whiskers
32
Using Consolidate
• Assign file extension to view
engine
• specify views folder
• render() instead of write()
32
33
Socket IO
• Realtime web apps
• Broad browser support
• Internet Explorer 5.5+
• Safari 3+
• Google Chrome 4+
• Firefox 3+
• Opera 10.61+
• iPhone Safari
• iPad Safari
• Android WebKit
• WebOs WebKit 33
• Falls back to next best transport
• WebSocket
• Adobe® Flash® Socket
• AJAX long polling
• AJAX multipart streaming
• Forever Iframe
• JSONP Polling
34
Socket.IO vs SignalR
• Socket.IO
• Broader browser support
• More fallback transports
• JavaScript for client and
Server
34
• SignalR
• Less Browser support
• Less transports
• .NET code on server
35
Data Access
• Drivers exists for most databases
• Mongo
• CouchDB
• SQL Server
• MySQL
• PostgreSQL
• unixODBC
35
36
SQL Server
• node-sqlserver
• Microsoft Provided module
• https://github.com/WindowsAzure/node-sqlserver
• edge.js
• execute SQL using the .NET SQL Client
• supports CRUD operations
36
37
SQL DRIVER
• node-sqlserver
• Developed by Microsoft
• Not a lot of activity on
GitHub. (38 open
issues)
• Not production ready
37
38
SQL with EDGE.JS
38
39
Other options (SQL Server)
• node-tds
• TDS implementation for node (Pure JS)
• tedious
• TDS implementation for node
• odbc
• Good ole’ ODBC
• uses unixODBC library
• Windows Support?
39
40
Deployment Models
• node process
• nginx
• iisnode
• cloud
40
41
Node Process Direct
• Simplest option
• Doesn’t reload changed files
• requires restart
• Not a service out of the box on windows
• Easily fixed (winser npm module)
• Not good at serving static content
• Good for development, though nodemon is better choice
41
42
nginx
• Extremely fast HTTP server
• Great for static content
• Proxy Dynamic Calls to Node
• Much faster than Apache
• Poor windows support
• current version considered beta
• “high performance and scalability should not be expected”
42
43
iisnode
• Created by Tomas Janczuk
• Native IIS module
• Powers Node on Windows Azure
• Windows only (if that’s not obvious you’re at the wrong conference)
43
44
Configuration
44
45
performance
• Great when serving static content with application
• Large overhead for pure dynamic app
45
46
Cloud
• Heroku
• Nodejitsu
• Engine Yard
• Windows Azure
• Longer list at https://github.com/joyent/node/wiki/Node-Hosting
46
47
Windows Azure
• MS Deploy
• Git deploy
• Same config as iisnode
47
48
Node azure sdk
• npm install azure-cli -g
• Windows, linux, OS X
48
49
SDK Features
• Tables
• create and delete tables
• create, query, insert, update, merge, and delete entities
• Blobs
• create, list, and delete containers, work with container metadata and permissions, list blobs in
container
• create block and page blobs (from a stream, a file, or a string), work with blob blocks and pages,
delete blobs
• work with blob properties, metadata, leases, snapshot a blob
• HD Insight
• create, list and delete HDInsight clusters
49
50
SDK Features Continued
• Storage Queues
• create, list, and delete queues, and work with queue metadata
• create, get, peek, update, delete messages
• Service Bus
• Queues: create, list and delete queues; create, list, and delete subscriptions; send, receive, unlock and delete messages
• Topics: create, list, and delete topics; create, list, and delete rules
• Notification hubs: create hubs, register for messages, send messages
• Azure SQL Database
• create, list and delete Azure SQL Database servers, databases and firewall rules
• Service Runtime
• discover addresses and ports for the endpoints of other role instances in your service
• get configuration settings and access local resources
• get role instance information for current role and other role instances
• query and set the status of the current role
50
51
Deploying to azure
npm install azure
git commit -m "My first Node app"
git push azure master
•IT’S THAT EASY!
51
52
Azure SDK Example
52
53
Using .NET with Node
• Edge.js
• Also created by Tomas Janczuk
• Supported on Azure
• http://tjanczuk.github.io/edge/#/
53
54
Edge.js
54
55
Edge.js
55
56
Resources
• Learning Node
• Books
• Node.js in Action (Manning)
• Professional Node.js (Wrox)
• Pro Node.js (Apress)
• Node (O’reilly)
• WebSites
• nodejs.org
• howtonode.org
• codeschool.com
• education.10gen.com
56
LinkedIn - HTML5 Lessons from LinkedIn using Node.js
by Kiran Prasad
https://www.youtube.com/watch?v=hMd45Ij2DYQ
linkedin.com/techtalks
57
Webstorm
• Based on
IntelliJ IDEA
• Great if you like
ReSharper
• Windows, OS X
Linux
57
58
webmatrix
• IntelliSense
• Support for Jade and EJS
• LESS and Sass support
• Coffeescript support
58
59
Visual Studio
• Node.js tools for Visual Studio
• Node projects, debugger, npm console
• Syntax highlighting
• Visual Node
• Node projects, debugger, packages as references, REPL
• IntelliSense, Syntax highlighting
• Created by redgate
• Private beta (http://www.visualnode.info/)
59
60
Cloud9 IDE
• Built with node ;-)
• Runs in the
browser
• jsfiddle for node
60
61
FInal Thoughts
• Node is for IO intensive applications
• Web Applications
• 1000s of concurrent connections
• NOT for Compute bound operations
• Don’t try to calculate PI and expect a responsive server
• Fast development, easy deployment
• No more edit, build, wait, refresh -- just edit and refresh!
61
62
Questions?
62

Weitere ähnliche Inhalte

Was ist angesagt?

Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Apache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeApache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeAndrus Adamchik
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
Hey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemHey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemColdFusionConference
 
Alfresco Content Modelling and Policy Behaviours
Alfresco Content Modelling and Policy BehavioursAlfresco Content Modelling and Policy Behaviours
Alfresco Content Modelling and Policy BehavioursJ V
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewCraig Dickson
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
Eureka Moment UKLUG
Eureka Moment UKLUGEureka Moment UKLUG
Eureka Moment UKLUGPaul Withers
 
Open source identity management 20121106 - apache con eu
Open source identity management   20121106 - apache con euOpen source identity management   20121106 - apache con eu
Open source identity management 20121106 - apache con euFrancesco Chicchiriccò
 
Create a welcoming development environment on IBM i
Create a welcoming development environment on IBM iCreate a welcoming development environment on IBM i
Create a welcoming development environment on IBM iAlan Seiden
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend frameworkAlan Seiden
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaGeorge Wilson
 
Penny coventry fiddler-spsbe23
Penny coventry fiddler-spsbe23Penny coventry fiddler-spsbe23
Penny coventry fiddler-spsbe23BIWUG
 
Json api dos and dont's
Json api dos and dont'sJson api dos and dont's
Json api dos and dont'sNeven Rakonić
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumNgoc Dao
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureToru Kawamura
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns Alex Theedom
 
DB2 and PHP in Depth on IBM i
DB2 and PHP in Depth on IBM iDB2 and PHP in Depth on IBM i
DB2 and PHP in Depth on IBM iAlan Seiden
 

Was ist angesagt? (20)

Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Apache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeApache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM Alternative
 
Require js training
Require js trainingRequire js training
Require js training
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
Hey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemHey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the Problem
 
Alfresco Content Modelling and Policy Behaviours
Alfresco Content Modelling and Policy BehavioursAlfresco Content Modelling and Policy Behaviours
Alfresco Content Modelling and Policy Behaviours
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief Overview
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Eureka Moment UKLUG
Eureka Moment UKLUGEureka Moment UKLUG
Eureka Moment UKLUG
 
Open source identity management 20121106 - apache con eu
Open source identity management   20121106 - apache con euOpen source identity management   20121106 - apache con eu
Open source identity management 20121106 - apache con eu
 
Create a welcoming development environment on IBM i
Create a welcoming development environment on IBM iCreate a welcoming development environment on IBM i
Create a welcoming development environment on IBM i
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and Joomla
 
Penny coventry fiddler-spsbe23
Penny coventry fiddler-spsbe23Penny coventry fiddler-spsbe23
Penny coventry fiddler-spsbe23
 
Json api dos and dont's
Json api dos and dont'sJson api dos and dont's
Json api dos and dont's
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the future
 
End-to-end W3C APIs
End-to-end W3C APIsEnd-to-end W3C APIs
End-to-end W3C APIs
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
 
DB2 and PHP in Depth on IBM i
DB2 and PHP in Depth on IBM iDB2 and PHP in Depth on IBM i
DB2 and PHP in Depth on IBM i
 

Ähnlich wie Node and Azure

End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012Alexandre Morgaut
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Docker With Asp.net Core
Docker With Asp.net CoreDocker With Asp.net Core
Docker With Asp.net CoreFatih Şimşek
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Dockervisual28
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeAlexandre Morgaut
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET DevelopersDavid Neal
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Conference
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Offience's Node showcase
Offience's Node showcaseOffience's Node showcase
Offience's Node showcasecloud4le
 
OpenStack Deployments with Chef
OpenStack Deployments with ChefOpenStack Deployments with Chef
OpenStack Deployments with ChefMatt Ray
 
Benefits of an Open environment with Wakanda
Benefits of an Open environment with WakandaBenefits of an Open environment with Wakanda
Benefits of an Open environment with WakandaAlexandre Morgaut
 

Ähnlich wie Node and Azure (20)

End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Docker With Asp.net Core
Docker With Asp.net CoreDocker With Asp.net Core
Docker With Asp.net Core
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Node
NodeNode
Node
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
.NET7.pptx
.NET7.pptx.NET7.pptx
.NET7.pptx
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) Europe
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET Developers
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
.NET6.pptx
.NET6.pptx.NET6.pptx
.NET6.pptx
 
Offience's Node showcase
Offience's Node showcaseOffience's Node showcase
Offience's Node showcase
 
OpenStack Deployments with Chef
OpenStack Deployments with ChefOpenStack Deployments with Chef
OpenStack Deployments with Chef
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Node azure
Node azureNode azure
Node azure
 
Benefits of an Open environment with Wakanda
Benefits of an Open environment with WakandaBenefits of an Open environment with Wakanda
Benefits of an Open environment with Wakanda
 

Kürzlich hochgeladen

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Kürzlich hochgeladen (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Node and Azure

  • 1. 1 Node.js and Azure 1 Building Applications for the Web
  • 2. 2 Jason Gerard •Director of Product Development, PaySpan Inc. (www.payspan.com) •Developing software for 15 years (VB, COM, JAVA, .NET) •Focus on SaaS •Married with 3 kids
  • 3. 3 What is node.js •Created by Ryan Dahl in 2009 •Platform for asynchronous JavaScript •Event based programming • Event loop fundamental structure •DIRTy • Data Intensive Real Time •Solution for c10k problem
  • 4. 4 Architecture • Written in C++ and JavaScript • 20k lines of C++, 2k lines of JavaScript • Built with Chrome’s V8 JavaScript Engine • Libev • Native Event Loop • Libeio • uses POSIX threads to provide async IO • Evcom • Stream socket library built on libev • udns
  • 5. 5 Events vs. Threads • Threads • Each request gets its own thread • Thread can’t process another request until it’s done with current • 2 MB stack per thread • Context Switching • Events • Each request is added to a queue • Processed by single thread • Only one thread, no context switching 5
  • 6. 6 Why JavaScript? •Ubiquitous • Everyone knows it •“WORA” • Stole Java’s name and beat it at it’s own game •Front end developers can easily transition to server development • Already used to event based programming
  • 7. 7 ASYNCHRONOUS JAVASCRIPT • Same programming model as web browser • Wait for events • Non Blocking IO • Uses Callbacks 7
  • 8. 8 Callbacks • “Everything” is a callback • Only one thread, don’t block it • Building Blocks of Async Programming 8
  • 10. 10 Event Emitters • EventEmitter class • emitter.addListener(event, listener) • emitter.on(event, listener) • emitter.once(event, listener) • emitter.removeListener(event, listener) • emitter.removeAllListeners([event]) • emitter.setMaxListeners(n) • emitter.listeners(event) • emitter.emit(event, [arg1], [arg2], [...])
  • 12. 12 Nodemon • Monitors for file changes • Automatically restarts node process • nodemon app.js 12
  • 13. 13 Package Management • npm • command for creating, installing, updating packages • npm test (runs test scripts) • package.json • JSON file describing package 13
  • 14. 14 npm • npm install • npm install module_name • npm install -g module_name (don’t forget to sudo) 14
  • 16. 16 Web Development • Node’s bread and butter • Basic HTTP server right in the box 16
  • 17. 17 Connect • Extends HTTP support • Adds concept of “middleware” • function (req, res, next){ //do something next();} • Configured with use() method • Order IS important 17
  • 19. 19 Express • Framework built on top of connect • Provides view engine facilities • Routes • Many helper functions 19
  • 20. 20 Express Routing • Inspired by Sinatra (ruby) • /users • /users/:id • regex 20
  • 21. 21 Express Routing • app.VERB() where verb is an HTTP verb (get, post, etc...) • app.all() execute for all verbs • req.query for querystring parameters • req.body for POST, must use bodyParser middleware 21
  • 22. 22 Error Handling • Basic middleware • function handler(err, req, res, next) 22
  • 23. 23 View Engines • EJS • Jade • Mustache • Hogan • Dust • Swig • Flatiron Plates 23
  • 28. 28 Mustache derivatives • Hogan (builded with express, built by twitter) • Handlebars 28
  • 29. 29 Flatiron Plates • Created by nodejitsu • Pure HTML binding 29
  • 30. 30 Consolidate • Provides support for many view engines • Exposes each view engine as Express middleware • Wraps each view invocation in function • function x(path[, locals], callback) • Same format Express uses 30
  • 31. 31 Consolidate supported Template Engines • atpl • dust • eco • ejs • haml • haml-coffee • handlebars • hogan • jade • jazz 31 • jqtpl • JUST • liquor • mustache • QEJS • swig • templayed • toffee • underscore • walrus • whiskers
  • 32. 32 Using Consolidate • Assign file extension to view engine • specify views folder • render() instead of write() 32
  • 33. 33 Socket IO • Realtime web apps • Broad browser support • Internet Explorer 5.5+ • Safari 3+ • Google Chrome 4+ • Firefox 3+ • Opera 10.61+ • iPhone Safari • iPad Safari • Android WebKit • WebOs WebKit 33 • Falls back to next best transport • WebSocket • Adobe® Flash® Socket • AJAX long polling • AJAX multipart streaming • Forever Iframe • JSONP Polling
  • 34. 34 Socket.IO vs SignalR • Socket.IO • Broader browser support • More fallback transports • JavaScript for client and Server 34 • SignalR • Less Browser support • Less transports • .NET code on server
  • 35. 35 Data Access • Drivers exists for most databases • Mongo • CouchDB • SQL Server • MySQL • PostgreSQL • unixODBC 35
  • 36. 36 SQL Server • node-sqlserver • Microsoft Provided module • https://github.com/WindowsAzure/node-sqlserver • edge.js • execute SQL using the .NET SQL Client • supports CRUD operations 36
  • 37. 37 SQL DRIVER • node-sqlserver • Developed by Microsoft • Not a lot of activity on GitHub. (38 open issues) • Not production ready 37
  • 39. 39 Other options (SQL Server) • node-tds • TDS implementation for node (Pure JS) • tedious • TDS implementation for node • odbc • Good ole’ ODBC • uses unixODBC library • Windows Support? 39
  • 40. 40 Deployment Models • node process • nginx • iisnode • cloud 40
  • 41. 41 Node Process Direct • Simplest option • Doesn’t reload changed files • requires restart • Not a service out of the box on windows • Easily fixed (winser npm module) • Not good at serving static content • Good for development, though nodemon is better choice 41
  • 42. 42 nginx • Extremely fast HTTP server • Great for static content • Proxy Dynamic Calls to Node • Much faster than Apache • Poor windows support • current version considered beta • “high performance and scalability should not be expected” 42
  • 43. 43 iisnode • Created by Tomas Janczuk • Native IIS module • Powers Node on Windows Azure • Windows only (if that’s not obvious you’re at the wrong conference) 43
  • 45. 45 performance • Great when serving static content with application • Large overhead for pure dynamic app 45
  • 46. 46 Cloud • Heroku • Nodejitsu • Engine Yard • Windows Azure • Longer list at https://github.com/joyent/node/wiki/Node-Hosting 46
  • 47. 47 Windows Azure • MS Deploy • Git deploy • Same config as iisnode 47
  • 48. 48 Node azure sdk • npm install azure-cli -g • Windows, linux, OS X 48
  • 49. 49 SDK Features • Tables • create and delete tables • create, query, insert, update, merge, and delete entities • Blobs • create, list, and delete containers, work with container metadata and permissions, list blobs in container • create block and page blobs (from a stream, a file, or a string), work with blob blocks and pages, delete blobs • work with blob properties, metadata, leases, snapshot a blob • HD Insight • create, list and delete HDInsight clusters 49
  • 50. 50 SDK Features Continued • Storage Queues • create, list, and delete queues, and work with queue metadata • create, get, peek, update, delete messages • Service Bus • Queues: create, list and delete queues; create, list, and delete subscriptions; send, receive, unlock and delete messages • Topics: create, list, and delete topics; create, list, and delete rules • Notification hubs: create hubs, register for messages, send messages • Azure SQL Database • create, list and delete Azure SQL Database servers, databases and firewall rules • Service Runtime • discover addresses and ports for the endpoints of other role instances in your service • get configuration settings and access local resources • get role instance information for current role and other role instances • query and set the status of the current role 50
  • 51. 51 Deploying to azure npm install azure git commit -m "My first Node app" git push azure master •IT’S THAT EASY! 51
  • 53. 53 Using .NET with Node • Edge.js • Also created by Tomas Janczuk • Supported on Azure • http://tjanczuk.github.io/edge/#/ 53
  • 56. 56 Resources • Learning Node • Books • Node.js in Action (Manning) • Professional Node.js (Wrox) • Pro Node.js (Apress) • Node (O’reilly) • WebSites • nodejs.org • howtonode.org • codeschool.com • education.10gen.com 56 LinkedIn - HTML5 Lessons from LinkedIn using Node.js by Kiran Prasad https://www.youtube.com/watch?v=hMd45Ij2DYQ linkedin.com/techtalks
  • 57. 57 Webstorm • Based on IntelliJ IDEA • Great if you like ReSharper • Windows, OS X Linux 57
  • 58. 58 webmatrix • IntelliSense • Support for Jade and EJS • LESS and Sass support • Coffeescript support 58
  • 59. 59 Visual Studio • Node.js tools for Visual Studio • Node projects, debugger, npm console • Syntax highlighting • Visual Node • Node projects, debugger, packages as references, REPL • IntelliSense, Syntax highlighting • Created by redgate • Private beta (http://www.visualnode.info/) 59
  • 60. 60 Cloud9 IDE • Built with node ;-) • Runs in the browser • jsfiddle for node 60
  • 61. 61 FInal Thoughts • Node is for IO intensive applications • Web Applications • 1000s of concurrent connections • NOT for Compute bound operations • Don’t try to calculate PI and expect a responsive server • Fast development, easy deployment • No more edit, build, wait, refresh -- just edit and refresh! 61

Hinweis der Redaktion

  1. c10k - Ten Thousand Clients - solves problem through async IO
  2. Libeio uses a threadpool to provide an async version of the POSIX IO libraries
  3. Starbucks analogy Events: Order and then step aside until order is called Walmart - Threads: Order and wait until food is ready, no one else can order on that register until done Event LOOP - talk about it
  4. Only the IO is non blocking. Compute bound operations (like calculating PI) will still block. Web apps shouldn’t be compute bound though.
  5. Show example with setTimeout and c# (sleep.js and sleep.cs)
  6. events1.js -- use telnet, not nc
  7. addListener and on are synonymous once - removes listener the first time the event is received all methods return the emit so chaining is possible
  8. events2.js MyEventClass.js
  9. console example
  10. http.js example
  11. Connect has a router now
  12. Supports filters
  13. if empty was false, the last <p> tag would be gone
  14. db.getUsers() - Remember, everything is a callback
  15. Example... socketio express app
  16. Unless otherwise noted below, all measurements were taken at server CPU utilization > 90%. The configuration involved one quad core Windows 2008 server with node.js v0.6.6 and iisnode v0.1.13. Depending on scenario, one or two WCAT client machines were required to saturate the server. Clients and server were connected to the same switch but were not on private network.   [1] See test code . In this scenario node.js application returns a simple “hello, world” plaintext response to an HTTP GET request. This is the only scenario that uses a single node.exe instance (both self-hosted and IIS hosted). Given the single-threaded nature of node.exe, the multi-core server CPU is never fully utilized. However, the node.exe process has consistently utilized > 23% of CPU, which corresponds to almost full utilization of a single core of the quad-core server.   [1.1] Although in this scenario iisnode achieved better throughput than self-hosted node.exe, it was accomplished with almost twice as large CPU utilization (~60% in case of iisnode compared to ~30% in case of node.exe).   [2] See test code . This scenario uses the same node.js “hello world” application as scenario #1, but it utilizes 4 node.exe processes to saturate the CPU on the quad core server. In case of self-hosting node.exe, the built-in cluster functionality is employed. In case of iisnode, the built-in capability to spawn and route to multiple node.exe processes per application is used.   [3] See test code . This scenario simulates using node.js to serve a web site using express - one of the most popular MVC frameworks for node. The web site consists of an HTTP endpoint that dynamically generates HTML that displays a randomly generated order information using the jade rendering engine. The HTML refers to a static CSS file. As part of each WCAT transaction, one request is made to the HTML endpoint that generates dynamic content and the another to get the static CSS file. In case of self-hosted node.js application, the static file is served by the express framework using the connect.static middleware (which is built into express and a most likely mechanism to be used by someone serving static content from express). In case of IIS, requests for static content are actually not handled by iisnode at all – a URL rewrite module causes that request to be handled by the native static file handler (which plays to the “side by side with other content types” benefits of iisnode).   [4] See test code . This scenario simulates using node.js to implement web APIs: HTTP endpoints that generate dynamic content. In this particular case we are reusing the order generation and HTML rendering endpoint from scenario #3, without including a request for static CSS file in the WCAT transaction.