Cloud Foundry: Design and Architecture
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Werner Schuster on Nov 24, 2009
Node.js allows standalone Javascript programs to use evented I/O like EventMachine or Python's Twisted, Grand Central Dispatch's Dispatch Sources and queues and many other similar systems.
This presentation discusses implementation and design ideas behind Node.js (PDF Link). Essentially, Node.js allows to write code like this (from the linked slides):
http.createServer( function (req,res) {
res.sendHeader(200, {"Content-Type": "text/plain"});
res.sendBody("Hello\r\n");
res.sendBody("World\r\n");
res.finish();
}).listen(8000);
The createServer call sets up the system to listen to port 80; when a connection comes in, the anonymous function that is passed in is invoked. There's no need to manually fire up threads or dispatch incoming requests, Node.js takes care of that.
This is just one example, a lot of other I/O, both reading and writing, can also be handled with callbacks and events. Non-blocking reads from stdin are possible as well.
The the event concept is used throughout Node.js' APIs. Many different systems allow to register listeners for all kinds of events, simply by using the addListener method. For instance, the global process object, allows to listen to OS signals with this code (from the presentation slides):
process.addListener("SIGINT",
function () {
puts("good bye");
process.exit(0)
}
);
Other libraries return Promise objects which emit one of these events: "success", "error", "cancel". An example from the Node.js API docs:
var posix = require("posix"),
sys = require("sys");
var promise = posix.unlink("/tmp/hello");
promise.addCallback(function () {
sys.puts("successfully deleted /tmp/hello");
});
The promise.addCallback call registers a listener that's called when the Promise emits the "success" event - in this example, when the API call has finished successfully. Something similar can be achieved by wait or timeout calls on the Promise object, which block indefinitely or until the timeout is triggered.
With the Promise concepts, Node.js can execute blocking calls without actually blocking the Javascript code. These calls are performed on a background thread which, after completion, triggers the Promise events.
To achieve its design goals, Node.js takes Google's V8 and bundles it with a few libraries:
select, epoll, etc)There are already quite a few libraries built upon Node.js, bindings to databases, protocols like BERT-RPC and many others.
Support for the HTML5 Web Workers API is considered; Web Workers allow Javascript to start new workes that executes tasks. Unlike shared memory threads, Web Workers don't see each other's (or their creator's) memory; communication happens only via message passing, which makes them a bit like Erlang processes.
Node.js ships with an executable that runs Javascript files, as well as a shell (REPL) that makes it easy to try out Javascript code.
For more information, Simon Willison has an article covering Node.js; the article also provides some examples of Node.js libraries, eg. for accessing Redis or building web apps.
Node.js allows to use Javascript as more than a GUI scripting language. It does inherit one problem from Javascript, though: the lack of a standard Javascript library. Node.js comes with libraries, and the mentioned 3rd party libraries certainly help, but it's still not close to the functionality found in Java's or Ruby's standard libraries. With Javascript's increasing popularity for writing client applications, it's possible more general purpose, non-browser-based libraries will appear.
Would you consider using Node.js? What would you use it for?
Introducing SQLFire: a memory-optimized, high performance SQL database
Taming HTML5 and JS: High Performance Mobile, WebKit, FireFox Dev Tools @QCon New York
RDBMS to NoSQL: Managing the Transition
VMware vFabric SQLFire - Test drive the data management system with memory speed, horizontal scalability and a familiar SQL interface
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
Andrew Watson talks about the work of the OMG, where CORBA is alive and well (hint: in your car), UML and UML Profiles vs. custom Modeling languages, DDS and other middleware, and much more.
Sohil Shah discusses creating iPhone and Android enterprise mobile applications based on cloud services using the open source platform OpenMobster.
Paul Sanford presents the transformations supported by data throughout its life cycle, and how that can be better done with Splunk, an engine for monitoring and analyzing machine-generated data.
A common “best practice” for unit tests is to only write a one assertion in each test. I intend to question this advice by showing that multiple assertions per test are both necessary and beneficial.
John Rauser presents the architectural and technological evolution of Amazon retail websites starting with 1994 and ending with adopting Amazon Web Services.
Michael Stal discusses system architecture quality, how to avoid architectural erosion, how to deal with refactoring, and design principles for architecture evolution.
Every developer has had to integrate with another system, API or component. Tis article provides strategies to handle the change and for he separating system boundaries.
No comments
Watch Thread Reply