Your SlideShare is downloading. ×
0
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 require...
Why we need JavaScript
                  You already use it in the client.
                  It’s already event based and ...
Node's goal is to provide an easy way to build
       performant network programs.

       This is in contrast to today's ...
Hello World in Node.js
        // Load the http module
        var http = require('http');

        // Setup a request han...
Hello World in Connect
             // Load the connect module
             Connect = require('connect');
             // ...
Stacking in Middleware
                  Node provides very low level APIs

                  There is no cookie handling ...
Bundled Modules
                  Static File Server   Fancy Error Handler

                  Apache Style Logs    Cache M...
Connect with Layers
                  Connect.createServer(
                     Connect.logger(),
                     Co...
Express is even easier
                  Connect is a framework maker’s framework.

                  It’s much easier tha...
Express Example
                   // Create an express app
                   var app = express.createServer();

        ...
DEMO TIME!


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

            http://expressjs.com

            htt...
Upcoming SlideShare
Loading in...5
×

SenchaLabs Connect & Express

4,867

Published on

This is a talk I gave at a local ExtJS users group at Sencha headquarters.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,867
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
44
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "SenchaLabs Connect & Express"

  1. 1. SenchaLabs Connect & Express High Performance Servers written in JavaScript Monday, September 20, 2010
  2. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  12. 12. DEMO TIME! Monday, September 20, 2010
  13. 13. Links to Projects Used http://senchalabs.github.com/connect http://expressjs.com http://nodejs.org http://raphaeljs.com Monday, September 20, 2010
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×