1. Node.js on Cloud Foundry NPMNode.js Cloud Foundry Supports
Node.js Modules with
NPMhttp://blog.cloudfoundry.com/2012/05/24/cloud-foundry-supports-node-js-modules-with-npm/
2012/7/26 2011 VMware Inc. All rights reserved
2. Toshihiko Ikeda! [email protected] / @tikeda123! 12 years in
enterprise middleware(java application server)! /SOA!
c/c++/Java/Ruby/JavaScript! Spring
Framework(core)/rails/grails?!2
3. Node.js 1. Google ChromeJavaScriptV8 JavaScript 2. I/O
Chrome TCP/HTTP/ Async Event Other JS V8 DNS I/O Support C/C++
libcv Modules C++ lib C/C++ lib C/C++ lib C/C++ libcv C/C++
Environment JS Env Node.js Under-the-hood3
5. Multi-threaded server - Threads are spawned for every
connection User1 i/o request T1 DB User2 i/o request T2 Blocking
I/O User3Refreshes 2 times T3 T4 T5 T6 T7 T8 FS User4refreshes 3
times T9 Multi threaded server T Thread Because every I/o is
blocking, server spawns a thread per connection* to support
multiple requests 5
6. Non-blocking & Evented I/O (Node.js server) JS C/C++ T1
User1 i/o request V8 DB T1 Libio T1 POSIX V8 Event loop V8 Async
User2 i/o request (Libev) Threads T1 delegate i/o to Non-blocking
t2 I/O V8 libeio t1 User3Refreshes 2 times Single t4 thread t3
serves T1 t6 all users V8 t5 User4refreshes 3 times T1 t7 FS V8 i/o
result returned T1 T1 2 EL after x time V8 T1 V8 T1 JS Thread
running V8 V8 your code (Single threaded) Node.js t1 POSIX threads
doing t2 async I/O (multi-threaded) t3 Everything except your (JS)
code is runs in parallel (by libio) 6
7. Multi-threaded blocking server (Apache) VS Event-driven,
non-blocking server (Nginx) performance Reqs/sec v/s concurrent
connections At ~4000 concurrent connections, - Nginx can serve
~9000 reqs/sec - Apache can serve ~3000 reqs/sec Ref:
http://blog.webfaction.com/a-little-holiday-present 7
10. NPMNode.js cloudfoundry.jsonignoreNodeModules true
node_modules bcrypt,bers,nowjsNative cloudfoundry.json
cloudfoundry.json { "ignoreNodeModules" : true } vmc push vmc push
runtime=node06(Node.js $vmc push runtime=node06 Would you like to
deploy from the current directory? [Yn]: Y Application Name:
ike-node Detected a Node.js Application, is this correct? [Yn]: Y
Application Deployed URL [ike-node.cloudfoundry.com]: Creating
Application: OK Uploading Application: Checking for available
resources: OK Processing resources: OK Packing application: OK
Uploading (15K): OK Push Status: OK Staging Application ike-node:
OK Starting Application ike-node: OK 10