background preloader

Node.js

Facebook Twitter

Node.js. Node.js is an open source, cross-platform runtime environment for server-side and networking applications.

Node.js

Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, Linux, FreeBSD, NonStop and IBM i. Node.js provides an event-driven architecture and a non-blocking I/O API that optimizes an application's throughput and scalability. These technologies are commonly used for real-time web applications. Node.js is gaining adoption as a server-side platform[4] and is used by Microsoft,[5][6] Yahoo! ,[7] Walmart,[8] Groupon,[9] SAP,[10] LinkedIn,[11][12] Rakuten, PayPal,[13][14] Voxer,[15] and GoDaddy.[16] History[edit] Ryan Dahl, creator of Node.js Node.js was invented in 2009 by Ryan Dahl, and other developers working at Joyent.[17] Node.js was created and first published for Linux use in 2009.

Memory management. Several methods have been devised that increase the effectiveness of memory management.

Memory management

Virtual memory systems separate the memory addresses used by a process from actual physical addresses, allowing separation of processes and increasing the effectively available amount of RAM using paging or swapping to secondary storage. The quality of the virtual memory manager can have an extensive effect on overall system performance. Dynamic memory allocation[edit] An example of external fragmentation Details[edit] The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size.

Context switch. This article is about computer task switching.

Context switch

For the term in human cognition, see human multitasking. The process of a Context Switch Cost[edit] When to switch? Debugging Node.js in Production. By Kim Trott, Yunong Xiao We recently hosted our latest JavaScript Talks event on our new campus at Netflix headquarters in Los Gatos, California.

Debugging Node.js in Production

Yunong Xiao, senior software engineer on our Node.js platform, presented on debugging Node.js in production. Yunong showed hands-on techniques using the scientific method to root cause and solve for runtime performance issues, crashes, errors, and memory leaks. We’ve shared some useful links from our talk: Videos from our past talks can always be found on our Netflix UI Engineering channel on YouTube. Event-driven programming. Computer programming paradigm Event handlers[edit] A trivial event handler[edit] Because the code is for checking for events and the main loop are common amongst applications, many programming frameworks take care of their implementation and expect the user to provide only the code for the event handlers.

Event-driven programming

In this simple example, there may be a call to an event handler called OnKeyEnter() that includes an argument with a string of characters, corresponding to what the user typed before hitting the ENTER key. To add two numbers, storage outside the event handler must be used. Globally declare the counter K and the integer T. While keeping track of history is normally trivial in a sequential program because event handlers execute in response to external events, correctly structuring the handlers to work correctly when called in any order can require special attention and planning in an event-driven program.

Asynchronous I/O. Input and output (I/O) operations on a computer can be extremely slow compared to the processing of data.

Asynchronous I/O

An I/O device can incorporate mechanical devices that must physically move, such as a hard drive seeking a track to read or write; this is often orders of magnitude slower than the switching of electric current. For example, during a disk operation that takes ten milliseconds to perform, a processor that is clocked at one gigahertz could have performed ten million instruction-processing cycles. A simple approach to I/O would be to start the access and then wait for it to complete. But such an approach (called synchronous I/O or blocking I/O) would block the progress of a program while the communication is in progress, leaving system resources idle. When a program makes many I/O operations, this means that the processor can spend almost all of its time idle waiting for I/O operations to complete.

Asynchronous I/O is used to improve throughput, latency, and/or responsiveness. Jump up ^ Closure (computer programming) Not to be confused with the programming language Clojure.

Closure (computer programming)

Example. The following program fragment defines a higher-order function startAt with a parameter x and a nested function incrementBy. The nested function incrementBy has access to x, because incrementBy is in the lexical scope of x, even though x is not local to incrementBy. The function startAt returns a closure containing the function incrementBy, which adds the y value to the x value, and a reference to the variable x from this invocation of startAt, so incrementBy will know where to find it once invoked: function startAt(x) function incrementBy(y) return x + y return incrementBy variable closure1 = startAt(1) variable closure2 = startAt(5) Note that, as startAt returns a function, the variables closure1 and closure2 are of function type.