Node.js is a platform built on Google's V8 JavaScript engine that allows for non-blocking and event-driven web servers. It is well-suited for building real-time applications using techniques like Comet that require persistent connections to clients. The speaker demonstrates how to implement a basic chat application using WebSockets with node.js that maintains open connections to allow real-time messaging between users. Node.js's asynchronous and non-blocking model makes it a natural fit for Comet-style programming compared to traditional threaded server models.
Slides from my talk "Node.js Patterns for Discerning Developers" given at Pittsburgh TechFest 2013. This talk detailed common design pattern for Node.js, as well as common anti-patterns to avoid.
Slides from my talk "Node.js Patterns for Discerning Developers" given at Pittsburgh TechFest 2013. This talk detailed common design pattern for Node.js, as well as common anti-patterns to avoid.
Node.js and How JavaScript is Changing Server Programming Tom Croucher
Node.js is a highly concurrent JavaScript server written on top of the V8 JavaScript runtime. This is awesome for a number of reasons. Firstly Node.js has re-architected some of the core module of V8 to create a server implementation that is non-blocking (similar to other event driven frameworks like Ruby’s Event Machine or Python’s Twisted). Event driven architectures are a natural fit for JavaScript developers because it’s already how the browser works. By using an event driven framework Node is not only intuitive to use but also highly scalable. Tests have shown Node instances running tens of thousands of simultaneous users.
This session will explore the architectural basics of Node.js and how it’s different from blocking server implementations such as PHP, Rail or Java Servlets. We’ll explore some basic examples of creating a simple server, dealing with HTTP requests, etc.
The bigger question is once we have this awesome programming environment, what do we do with it? Node already has a really vibrant collection of modules which provide a range of functionality. Demystifying what’s available is pretty important to actually getting stuff done with Node. Since Node itself is very low level, lot’s of things people expect in web servers aren’t automatically there (for example, request routing). In order to help ease people into using Node this session will look at a range of the best modules for Node.js.
This is a presentation I prepared for a local meetup. The audience is a mix of web designers and developers who have a wide range of development experience.
Has the traditional intro to event looped servers (thanks Ryan!) with a couple of examples of why I think node.js is particularly exciting today. Code for the demos can be found at https://github.com/davidpadbury/node-intro.
Get on board the NodeJS Express as we take a journey through what makes NodeJS special. Server-side JavaScript that has an event loop for a heart, we'll delve into its single threaded nature and the advantages provided. From there we'll pass through the land of the Node Package Management tool, how to set up your own package and bring in useful 3rd party packages as dependencies. Our final destination is ExpressJS, a Sinatra inspired framework for NodeJS.
Node.js and How JavaScript is Changing Server Programming Tom Croucher
Node.js is a highly concurrent JavaScript server written on top of the V8 JavaScript runtime. This is awesome for a number of reasons. Firstly Node.js has re-architected some of the core module of V8 to create a server implementation that is non-blocking (similar to other event driven frameworks like Ruby’s Event Machine or Python’s Twisted). Event driven architectures are a natural fit for JavaScript developers because it’s already how the browser works. By using an event driven framework Node is not only intuitive to use but also highly scalable. Tests have shown Node instances running tens of thousands of simultaneous users.
This session will explore the architectural basics of Node.js and how it’s different from blocking server implementations such as PHP, Rail or Java Servlets. We’ll explore some basic examples of creating a simple server, dealing with HTTP requests, etc.
The bigger question is once we have this awesome programming environment, what do we do with it? Node already has a really vibrant collection of modules which provide a range of functionality. Demystifying what’s available is pretty important to actually getting stuff done with Node. Since Node itself is very low level, lot’s of things people expect in web servers aren’t automatically there (for example, request routing). In order to help ease people into using Node this session will look at a range of the best modules for Node.js.
This is a presentation I prepared for a local meetup. The audience is a mix of web designers and developers who have a wide range of development experience.
Has the traditional intro to event looped servers (thanks Ryan!) with a couple of examples of why I think node.js is particularly exciting today. Code for the demos can be found at https://github.com/davidpadbury/node-intro.
Get on board the NodeJS Express as we take a journey through what makes NodeJS special. Server-side JavaScript that has an event loop for a heart, we'll delve into its single threaded nature and the advantages provided. From there we'll pass through the land of the Node Package Management tool, how to set up your own package and bring in useful 3rd party packages as dependencies. Our final destination is ExpressJS, a Sinatra inspired framework for NodeJS.
Presented at the Yahoo! Web Development Summit in December 2007. Comet is the new name for the old trick of streaming events down to the browser from the server. This talk introduces Comet and shows how, despite the terrifying browser tricks needed, it's actually now very simple to build against.
Kat, one of the core developers on the npm CLI, will give an overview of the current state of the CLI, the ongoing work this year, and give a few hints about what you can expect to see in the (near?) future!
Hitchhiker's Guide to"'Serverless" Javascript - Steven Faulkner, BustleNodejsFoundation
Tools like AWS’s Lambda, Google's Cloud Functions, and many others are allowing us to create “serverless” applications.
At Bustle (a top 30 website in the US) we are taking full advantage of this new infrastructure. APIs, databases, searching, indexing, server side rendered javascript, are all being handled without deploying any of our own servers. And the best part? It costs orders of magnitude less than our old VM based deployments.
I’ll walk attendees through our entire serverless stack. I'll talk about the good, the bad, and the ugly. I'll share real numbers from production systems.
The goal is that attendees will leave with concrete knowledge of what going serverless really means and be able to decide if it makes sense for their own infrastructure.
Take Data Validation Seriously - Paul Milham, WildWorksNodejsFoundation
Why is data validation important? What are effective ways to ensure data is valid? In this session we'll explore how data validation is directly linked to security, stability and developer productivity when dealing with untrusted or unknown data sources. We'll discuss the dangers of code that does not validate its data - everything from injection to DOS attacks. We'll go hands on with joi (https://github.com/hapijs/joi) and Express (http://expressjs.com/) to see how data validation can make code easier to work with. No more "Uncaught ReferenceError" or if null checks littered around the code base. In the end, we'll see how code can be secure, stable and magically awesome to work with.
When building a large enough set of services using node.js, there will be a point when you find that your application is suffering from performance or memory issues. When this happens, you have to roll up your sleeves, get your tools and start digging. This talk explains how you can use tools such as ab, flame graphs, heap snapshots and Chrome's memory inspector to find the cause of these. We will go over two real life issues, a CPU bottleneck and a memory leak, we found while building our services at Auth0, and also explain how we fixed them.
Multimodal Interactions & JS: The What, The Why and The How - Diego Paez, Des...NodejsFoundation
The term 'multimodal interactions' (MMI) on the HCI field refers to the situation where a system offers many ways of interaction.
This talk combines an academic subject with the daily JS we already know. It is an effort to bring together two, at first, different worlds looking for a win-win situation. On the one hand, academia could enjoy getting a novel approach to a particular problem thanks to our awesome JS. On the other, the industry can get new ways of interaction which can be applied on a variety of context and/or products. In short, the talk contains: - A quick introduction to MMI (Multimodal Interactions) - A particular novel approach to add support for MMI on Web Apps. - Short list of related open problems or possible research lines to pursuit.
It is common to hear how much impact user experience has on the success of an application. Similarly, developer experience (DX) has a huge impact on the quality and usefulness of code. Why are some libraries so popular while others disappear? How do you create code people will actually use? In this talk, Corey Butler will review the oft-overlooked art of developer workflow. He will share tips and tricks used to make life sane, and even pleasurable, acquired on his journey through open source projects like NVM for Windows, Fenix Web Server, and node-windows/linux/mac. Find out how a focus on DX can elevate you and your code from obscurity to nirvana.
From Pterodactyls and Cactus to Artificial Intelligence - Ivan Seidel Gomes, ...NodejsFoundation
Among many things I love, what I really appreciate doing is the different, and learn with it.
Breaking barriers is complicated for any person. Knowledge barriers many times are formed by ourselves by incomplete parts of our mind's puzzle. What If I could help you out with some piece of Artificial Intelligence, without "puzzling" your head?
This project consists of an A.I. coded in Node.JS that learns by itself to play the "Google Chrome"'s Dino game (the one that pops up when there is no internet).
Using Neural Networks, and a Genetic Algorithm, I could manage to let the computer learn by itself how to play the game like a ninja. The project has been hosted in github (https://github.com/ivanseidel/IAMDinosaur) and it's called IAMDinosaur.
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...NodejsFoundation
In this talk, Joyee will talk about alinode's experiences in analyzing the V8 garbage collection logs and diagnosing performance problems caused by V8 GC pauses and memory leaks.
Node's Event Loop From the Inside Out - Sam Roberts, IBMNodejsFoundation
Do you think Node is asynchronous because it uses a thread pool for network interactions? Do you there is a relationship between "event emitters" and the "event loop"? I will be working through these misaprehensions as well as others, showing how the Node.js event loop really works. There are many, many pictures and blogs on this topic, but many of them are subtly wrong, or outright misleading. Despite that its event loop that is key to Node's scalability and performance, it remains a misunderstood black box to many. I will show how it works - C code may be seen! - talk about why it works that way, and what some of the implications are for Node developers, as well as briefly describe some changes that the Node core team are considering with respect to how Node uses libuv.
Real-Time Machine Learning with Node.js - Philipp Burckhardt, Carnegie Mellon...NodejsFoundation
Real-time machine learning provides statistical methods to obtain actionable, immediate insights in settings where data becomes available in sequential order. After providing an overview of state of the art real-time machine learning algorithms, we discuss how these algorithms can be leveraged from within a Node.js application. We will see why the powerful API of the core stream module makes Node.js a more attractive platform for such tasks compared to languages traditionally used for scientific computing such as R, Python or Julia. Finally, we will discuss best-practices and common pitfalls that one faces when using these algorithms.
Math in V8 is Broken and How We Can Fix It - Athan Reines, FourierNodejsFoundation
The built-in JavaScript Math library is used in virtually every Node.js application, from generating random ids to calculating exponential back-off times to computing basic performance metrics. When using the Math library, most developers simply assume that the underlying implementations are accurate, performant, and correctly implemented. In this presentation, Athan Reines will discuss why this assumption is often false and show the various ways in which the standard library is broken.
The presentation will present the algorithms used, their performance and accuracy, and how they have downstream effects on users of these libraries. The presentation will conclude by highlighting how community solutions are stepping up to fix these problems and identity opportunities for additional improvements.
Nodifying the Enterprise - Prince Soni, TO THE NEWNodejsFoundation
Node has transcended from being the cool tech stack for fledgling start ups to the darling of enterprise CIOs and CTOs.
It is no longer just the rapid development language for moving ideas to production fast. It is now very much the responsible mature technology that large enterprises need to solve their myriad problems of scale, user engagement, faster go-live cycles, security, performance and more and how this is achieved by Node is what we will be talking about in this presentation.
1. The JavaScript landscape and why it is the language of the next decade.
2. Evolution of Node and apps built on it
3. Solving the problems of scale, high uptime, multi channel and secure applications with Node
4. Node toolkit (various frameworks and supporting technologies)
5. Pitfalls to guard against
Text Mining with Node.js - Philipp Burckhardt, Carnegie Mellon UniversityNodejsFoundation
Today, more data is accumulated than ever before. It has been estimated that over 80% of data collected by businesses is unstructured, mostly in the form of free text. The statistical community has developed many tools for analysing textual data, both in the areas of exploratory data analysis (e.g. clustering methods) and predictive analytics. In this talk, Philipp Burckhardt will discuss tools and libraries that you can use today to perform text mining with Node.js. Creative strategies to overcome the limitations of the V8 engine in the areas of high-performance and memory-intensive computing will be discussed. You will be introduced to how you can use Node.js streams to analyse text in real-time, how to leverage native add-ons for performance-intensive code and how to build command-line interfaces to process text directly from the terminal.
Mathilde Lemée & Romain Maton
La théorie, c’est bien, la pratique … aussi !
Venez nous rejoindre pour découvrir les profondeurs de Node.js !
Nous nous servirons d’un exemple pratique pour vous permettre d’avoir une premiere experience complete autour de Node.js et de vous permettre de vous forger un avis sur ce serveur Javascript qui fait parler de lui !
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/01/hands-on-nodejs.html
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
These are the original slides from the nodejs talk. I was surprised not find them on slideshare so adding them. The video link is here https://www.youtube.com/watch?v=ztspvPYybIY
These are the slides to a talk I gave at Pittsburgh techFest 2012. The topic was an overview of the Node.js framework, and how you can use it to build amazing things.
* See more of my work at http://www.codehenge.net
Node.js uses JavaScript - a language known to millions of developers worldwide - thus giving it a much lower learning curve even for complete beginners. Using Node.js you can build simple Command Line programs or complex enterprise level web applications with equal ease. Node.js is an event-driven, server-side, asynchronous development platform with lightning speed execution. Node.js helps you to code the most complex functionalities in just a few lines of code.
This is a presentation given on October 24 by Michael Uzquiano of Cloud CMS (http://www.cloudcms.com) at the MongoDB Boston conference.
In this presentation, we cover Hazelcast - an in-memory data grid that provides distributed object persistence across multiple nodes in a cluster. When backed by MongoDB, objects are naturally written to Mongo by Hazelcast. The integration points are clean and easy to implement.
We cover a few simple cases along with code samples to provide the MongoDB community with some ideas of how to integrate Hazelcast into their own MongoDB Java applications.
Presented at JAX London 2015.
The last few years have seen a huge growth in the usage of JavaScript, to the extent that it is often reported to be the #1 programming language in use today. Additionally, the arrival of server-side JavaScript through frameworks such as Node.js and Ringo.js, and JavaScript on the JVM through Nashorn and Avatar.js, means that enterprise web applications written in JavaScript are not just a possibility—but a reality for companies such as LinkedIn, eBay, Yahoo, ADP and Dow Jones. This session will compare and contrast the two platforms and describe the advantages of each for deploying, managing and monitoring highly scalable applications.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
2. About me
• Cofounder and lead developer of Plurk.com
Coded most of the frontend and backend
• Mostly code in Python and JavaScript
But I am proficient in other languages as well (C, Java, Lisp, Lua etc.)
• I have coded since I was 12
24 years old now and still love to program :-)
• Not a node.js expert...
But I find it very interesting
3. Overview of the talk
• Why JavaScript matters
• What makes V8 VM special
• node.js in some details
• Characteristics of comet communication
• Implementing comet using node.js and WebSockets
• Perspective: JavaScript as the future platform
4. Why JavaScript matters
• The pool of JavaScript programmers is huge
and it’s getting bigger
• JavaScript’sbrowsers that support it and allthe mobile
think of all the
distribution is among
the
largest
platforms that support it or will support it... Think of Flash
• Big companies like Adobe, Google, Apple and Microsoft
are spending tons of $ in improving JavaScript
• JavaScript is likely to become one of the
most popular languages
• JavaScript is gaining ground on the backend
5. What makes V8 special
• V8 JavaScript VM is used in Google Chrome
and is developed by a small Google team in
Denmark. V8 is open-source
• V8 team is led by Lars Bak, one of the
leading VM engineers in the world with 20
years of experience in building VMs
• Lars Bak was the technical lead behind
HotSpot (Sun’s Java VM). HotSpot improved
Java’s performance 20x times
• Before HotSpot Lars Bak worked on a Smalltalk VM
6. What makes V8 special
• No JIT, all JavaScript is compiled to assembler
• Hidden classes optimization properties, instead it
V8 does not dynamically lookup access
from Self
uses hidden classes that are created behind the scene
• Improved garbage collector garbage collector
stop-the-world, generational, accurate,
• V8 is independent of Google Chrome
• Remarks / “limitations”: threads, no processes
No bytecode language, no
7. What is node.js?
• A system built on top of V8
• Introduces: IO
- non-blocking
- ability to do system calls
- HTTP libraries
- module system (+ other things)
• The non-blocking nature makes node.js a
good fit for comet and next generation
realtime web-applications
• 8000 lines of C/C++, 2000 lines of Javascript, 14 contributors
8. Advantages of non-blocking
• nginx: non-blocking apache: threaded
• non-blocking can handle more req. pr. sec
and uses a lot less memory
• comet does not scale at all for threaded servers...
graph source: http://blog.webfaction.com/a-little-holiday-present
9. Major point
JavaScript programming is already geared
towards event based programming:
• Events in browsers....
• Closures (anonymous functions) are natural part
of the language
document.addEventListener("click", function(event) {
alert(event)
}, false)
10. Hello world using node.js
var
sys
=
require('sys'),
http
=
require('http')
http.createServer(function
(req,
res)
{
setTimeout(function
()
{
res.sendHeader(200,
{'Content-‐Type':
'text/plain'})
res.sendBody('Hello
World')
res.finish()
},
2000)
}).listen(8000)
sys.puts('Server
running
at
http://127.0.0.1:8000/')
hello_world.js
11. Blocking vs. non-blocking
The way to do it The way to do
in most other it in node.js!
languages: puts("Enter your name: ")
gets(function (name) {
puts("Name: " + name)
puts("Enter your name: ") })
var name = gets()
puts("Name: " + name)
node.js design philosophy:
To receive data from disk, network or
another process there must be a callback.
12. Events in node.js
• All objects which emit events are are
instances of process.EventEmitter
• A promise is a EventEmitter which emits
either success or error, but not both
var tcp = require("tcp") var stat = require("posix").stat,
puts = require("sys").puts
var s = tcp.createServer()
var promise = stat("/etc/passwd")
s.addListener("connection",
promise.addCallback(function (s) {
function (c) {
puts("modified: " + s.mtime)
c.send("hello nasty!")
})
c.close() promise.addErrback(function(orgi_promise) {
}) puts("Could not fetch stats on /etc/passwd")
s.listen(8000) })
13. Comet vs. Ajax
Ajax is so yesterday...
Comet is the new superhero on the block
Comet can be used to create real time web-applications
Examples include Plurk and Google Wave. Demo of Plurk real time messaging
14. Ajax vs. Comet
Ajax Comet (long poll) Comet (streaming)
Browser Server Browser Server Browser Server
request request request
response
x seconds
event
response response
request
event event
request
response
response
event
How most do it today How some do it today How we will do it soon
15. Major point
• Comet servers need to have a lot of open
connections
• One thread pr. connection does not scale
• The solution is to use event based servers
• It’s only possible to create event based
servers in node.js!
16. Implementing comet
• Long polling parts. Used in Plurk
- works for most
- is more expensive and problematic than streaming
• Streaming withoutto proxies and firewalls
- Very problematic due
WebSockets:
• Streaming with WebSockets (HTML5):side
- Makes comet trivial on both client and server
• In this presentation we will focus on the
future: Building a chat application with
WebSockets and node.js
17. WebSockets
• Aims to expose TCP/IP sockets to browsers,
while respecting the constraints of the web
(security, proxies and firewalls)
• A thin layer on top of TCP/IP that adds:
• origin based security model
• Addressing and protocol naming mechanism for supporting multiple
services on one port and multiple host names on one IP address
• framing mechanism for data transporation
• More information: http://dev.w3.org/html5/websockets/
• Currently implemented in Google Chrome
18. node.websocket.js implementation
demo
var
sys
=
require('sys') Room = {
members
=
[] init: function() {
Room.ws = new WebSocket('ws://127.0.0.1:8080/chat')
var
Module
=
this.Module
=
function()
{
} Room.ws.onopen = Room._onopen
Room.ws.onmessage = Room._onmessage
Module.prototype.onData
=
function(data,
connection)
{ Room.ws.onclose = Room._onclose
for(var
i
in
members) },
//...
members[i].send(data)
_send: function(user, message){
};
Room.ws.send(serializeJSON({
'from': user,
Module.prototype.onConnect
=
function(connection)
{ 'message': message
members.push(connection) }))
} },
_onmessage: function(m) {
Module.prototype.onDisconnect
=
function(connection)
{ if (m.data) {
for(var
i
in
members)
{ var data = evalTxt(m.data)
if(members[i]
==
connection)
{
members.splice(i,
1) from = data.from
break; message = data.message
} //...
}
}
Note: I have patched
node.websocket.js to include onConnect...
19. Other comet servers
• JBoss Netty: Java library for doing non-
blocking networking, based on java.nio
used by Plurk to handle 200.000+ open connections
• erlycomet: Erlang comet server based on
MochiWeb
• Tornado: FriendFeed’s Python non-
blocking server
• I have tried most of the popular approaches
and none of them feel as natural as node.js!
20. How does node.js perfrom?
• Hello World benchmark node.js vs. Tornado
non scientific - take it with a grain of salt!
• Tornado is one of the fastest Python based servers
$ ab -c 100 -n 1000 http://127.0.0.1:8000/ $ ab -c 100 -n 1000 http://127.0.0.1:8000/
Concurrency Level: 100 Concurrency Level: 100
Time taken for tests: 0.230 seconds Time taken for tests: 0.427 seconds
Complete requests: 1000 Complete requests: 1000
Failed requests: 0 Failed requests: 0
Write errors: 0 Write errors: 0
Total transferred: 75075 bytes Total transferred: 171864 bytes
HTML transferred: 11011 bytes HTML transferred: 12276 bytes
Requests per second: 4340.26 [#/sec] (mean) Requests per second: 2344.36 [#/sec] (mean)
Time per request: 23.040 [ms] (mean) Time per request: 42.656 [ms] (mean)
Time per request: 0.230 [ms] Time per request: 0.427 [ms]
Transfer rate: 318.21 [Kbytes/sec] Transfer rate: 393.47 [Kbytes/sec]
node.js Tornado
21. CoffeScript
• A Ruby inspired language that compiles to JavaScript
CoffeScript JavaScript
square: x => x * x. var cube, square;
cube: x => square(x) * x. square = function(x) {
return x * x
}
cube = function(x) {
return square(x) * x
}
sys = require('sys') var sys = require('sys'),
http = require('http') http = require('http')
http.createServer( req, res => http.createServer(function (req, res) {
setTimeout( => setTimeout(function () {
res.sendHeader(200, {'Content-Type': 'text/plain'}) res.sendHeader(200, {'Content-Type': 'text/plain'})
res.sendBody('Hello World') res.sendBody('Hello World')
res.finish()., 2000). res.finish()
).listen(8000) }, 2000)
}).listen(8000)
JavaScript: The platform of the future?
23. PS: Plurk API
• Plurk API is now available:
http://www.plurk.com/API
• Python, Ruby, PHP and Java implementations are under
development
• Use it to build cool applications :-)
24. Questions?
• These slides will be posted to:
www.amix.dk (my blog)
• You can private plurk me on Plurk:
http://www.plurk.com/amix