SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
SenchaLabs Connect & Express
           High Performance Servers written in JavaScript
Monday, September 20, 2010
Why we need non-blocking
                  Polling is too slow and inefficient.

                  Live interaction requires the server to push data.

                  In order to push data, the connections need to be
                  persistent.

                  The server needs to handle thousands of
                  persistent connections.

                  Threads aren’t going to scale.


Monday, September 20, 2010
Why we need JavaScript
                  You already use it in the client.
                  It’s already event based and not threaded.
                  It’s actually a good language if used right.
                  Lambdas, closures, garbage collection.
                  V8 is a really fast VM


Monday, September 20, 2010
Node's goal is to provide an easy way to build
       performant network programs.

       This is in contrast to today's more common
       concurrency model where OS threads are
       employed.

       Node programs are written in JavaScript.
Monday, September 20, 2010
Hello World in Node.js
        // Load the http module
        var http = require('http');

        // Setup a request handler for a simple HTTP server.
        // Listen on port 3000
        http.createServer(function (req, res) {
          res.writeHead(200, {'Content-Type': 'text/
        plain'});
          res.end('Hello Worldn');
        }).listen(3000, "127.0.0.1");

        // Print a pretty message to the terminal
        console.log('Server running at http://
        127.0.0.1:3000/');

Monday, September 20, 2010
Hello World in Connect
             // Load the connect module
             Connect = require('connect');
             // Setup a simple Connect server
             server = Connect.createServer(
                function (req, res) {
                  res.writeHead(200, {
                    'Content-Type': 'text/plain'
                  });
                  res.end('Hello Worldn');
                }
             );
             // Export the server so Spark can run it
             module.exports = server;

Monday, September 20, 2010
Stacking in Middleware
                  Node provides very low level APIs

                  There is no cookie handling or parsing.

                  There is no session support built-in.

                  There is no routing built-in.

                  There is no static file serving.

                  Connect makes this easy!


Monday, September 20, 2010
Bundled Modules
                  Static File Server   Fancy Error Handler

                  Apache Style Logs    Cache Manifest

                  Body Decoder         Conditional Get

                  Cookie Decoder       Inline Gzipping

                  Session Provider     Virtual Host Router

                  Request Router       Sass/Less Compiler



Monday, September 20, 2010
Connect with Layers
                  Connect.createServer(
                     Connect.logger(),
                     Connect.conditionalGet(),
                     Connect.cache(),
                     Connect.gzip(),
                     Connect.staticProvider("public"),
                     Connect.bodyDecoder(),
                     Connect.cookieDecoder(),
                     Connect.session(),
                     Connect.router(routes),
                     Connect.errorHandler({showStack:
                  true})
                  );

Monday, September 20, 2010
Express is even easier
                  Connect is a framework maker’s framework.

                  It’s much easier than raw node.js, but still low
                  level.

                  Express is a simple framework for application
                  developers.

                  It’s inspired by Sinatra from the Ruby world.



Monday, September 20, 2010
Express Example
                   // Create an express app
                   var app = express.createServer();

                   // Setup a route handler
                   app.get('/', function(req, res){
                       res.send('Hello World');
                   });

                   // Start the HTTP server
                   app.listen(3000);


Monday, September 20, 2010
DEMO TIME!


Monday, September 20, 2010
Links to Projects Used
            http://senchalabs.github.com/connect

            http://expressjs.com

            http://nodejs.org

            http://raphaeljs.com




Monday, September 20, 2010

Weitere ähnliche Inhalte

Was ist angesagt?

Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
Wyatt Fang
 

Was ist angesagt? (18)

Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.js
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSS
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
 
Nodejs Intro
Nodejs IntroNodejs Intro
Nodejs Intro
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 Workshop
 
Ember and WebSockets
Ember and WebSocketsEmber and WebSockets
Ember and WebSockets
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Windows vps hosting providers
Windows vps hosting providersWindows vps hosting providers
Windows vps hosting providers
 
Session#1
Session#1Session#1
Session#1
 
Express js
Express jsExpress js
Express js
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
 
Why Bundler 1.1 will be much faster
Why Bundler 1.1 will be much fasterWhy Bundler 1.1 will be much faster
Why Bundler 1.1 will be much faster
 
Vi
ViVi
Vi
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de Vagrant
 

Ähnlich wie SenchaLabs Connect & Express

WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
Rajarshi Guha
 

Ähnlich wie SenchaLabs Connect & Express (20)

The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
 
Muduo network library
Muduo network libraryMuduo network library
Muduo network library
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
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
 
Proposal
ProposalProposal
Proposal
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows Azure
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
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
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
 
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerryjWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+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@
 
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
 

Kürzlich hochgeladen (20)

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​
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+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...
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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, ...
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 

SenchaLabs Connect & Express

  • 1. SenchaLabs Connect & Express High Performance Servers written in JavaScript Monday, September 20, 2010
  • 2. Why we need non-blocking Polling is too slow and inefficient. Live interaction requires the server to push data. In order to push data, the connections need to be persistent. The server needs to handle thousands of persistent connections. Threads aren’t going to scale. Monday, September 20, 2010
  • 3. Why we need JavaScript You already use it in the client. It’s already event based and not threaded. It’s actually a good language if used right. Lambdas, closures, garbage collection. V8 is a really fast VM Monday, September 20, 2010
  • 4. Node's goal is to provide an easy way to build performant network programs. This is in contrast to today's more common concurrency model where OS threads are employed. Node programs are written in JavaScript. Monday, September 20, 2010
  • 5. Hello World in Node.js // Load the http module var http = require('http'); // Setup a request handler for a simple HTTP server. // Listen on port 3000 http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/ plain'}); res.end('Hello Worldn'); }).listen(3000, "127.0.0.1"); // Print a pretty message to the terminal console.log('Server running at http:// 127.0.0.1:3000/'); Monday, September 20, 2010
  • 6. Hello World in Connect // Load the connect module Connect = require('connect'); // Setup a simple Connect server server = Connect.createServer( function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); } ); // Export the server so Spark can run it module.exports = server; Monday, September 20, 2010
  • 7. Stacking in Middleware Node provides very low level APIs There is no cookie handling or parsing. There is no session support built-in. There is no routing built-in. There is no static file serving. Connect makes this easy! Monday, September 20, 2010
  • 8. Bundled Modules Static File Server Fancy Error Handler Apache Style Logs Cache Manifest Body Decoder Conditional Get Cookie Decoder Inline Gzipping Session Provider Virtual Host Router Request Router Sass/Less Compiler Monday, September 20, 2010
  • 9. Connect with Layers Connect.createServer( Connect.logger(), Connect.conditionalGet(), Connect.cache(), Connect.gzip(), Connect.staticProvider("public"), Connect.bodyDecoder(), Connect.cookieDecoder(), Connect.session(), Connect.router(routes), Connect.errorHandler({showStack: true}) ); Monday, September 20, 2010
  • 10. Express is even easier Connect is a framework maker’s framework. It’s much easier than raw node.js, but still low level. Express is a simple framework for application developers. It’s inspired by Sinatra from the Ruby world. Monday, September 20, 2010
  • 11. Express Example // Create an express app var app = express.createServer(); // Setup a route handler app.get('/', function(req, res){ res.send('Hello World'); }); // Start the HTTP server app.listen(3000); Monday, September 20, 2010
  • 13. Links to Projects Used http://senchalabs.github.com/connect http://expressjs.com http://nodejs.org http://raphaeljs.com Monday, September 20, 2010