3. Claudio Cicali
Freelance Web Developer
claudio.cicali@gmail.com
@caludio
http://ccl.me
“Fighting Internet Explorer since 1999”
Claudio Cicali - Better Software 2011
6. Un interprete JavaScript (Google V8)
+
Alcuni componenti
+
Codice di collegamento
=
Un programma che esegue JavaScript
(server side - no browser)
Claudio Cicali - Better Software 2011
7. JavaScript Node standard library
C Node bindings
thread event
pool loop
V8
(libeio) (libev)
Claudio Cicali - Better Software 2011
8. Scopo:
Una piattaforma per sviluppare
applicazioni di rete
scalabili e veloci
in JavaScript
Ruby Event Machine
Python Twisted / Tornado
Claudio Cicali - Better Software 2011
9. Creato da
Ryan Dahl
nel 2009
Sponsorizzato da Joyvent
(San Francisco)
Claudio Cicali - Better Software 2011
17. Guardare al futuro
Progetto molto “dinamico”:
nessun problema a non garantire
la retrocompatibilità
Claudio Cicali - Better Software 2011
18. Caratteristiche
tecniche peculiari
Architettura “singolo processo” con event loop
(no multiprocesso, no multi-thread)
Qualsiasi operazione di I/O è asincrona
(file system compreso, of course)
Supporto nativo per HTTP, DNS, TLS
Claudio Cicali - Better Software 2011
19. This is the node.js project:
To provide a purely evented,
non-blocking infrastructure to
script highly concurrent programs.
Claudio Cicali - Better Software 2011
20. Caratteristiche conseguenti
Ottime prestazioni (veloce e scalabile)
Basso impegno di risorse
Soffre l’impegno della CPU
(migliorerà con gli Web Workers)
La programmazione a eventi
non è per definizione lineare...
Claudio Cicali - Better Software 2011
21. (grafico del 2010)
Smaller is Better
80
60
response time (ms)
server
40 nginx
thin
tornado
node
20
50 100 150 200 250 300
concurrency
Claudio Cicali - Better Software 2011
22. Caratteristiche indirette
Ben documentato
Community molto attiva
~5000 utenti su google groups
~2000+ domande su StackOverflow
~600 persone su #freenode
832 moduli, so far
Ehi, è JavaScript!
Claudio Cicali - Better Software 2011
23. Ambiente reale
Browser Server
Socket.io Node
Script X
Script Y
Ambiente di test
Test suite Server
Node Socket.io Node
Script X Script Y
Claudio Cicali - Better Software 2011
24. Che tipi di applicazione?
Servizi di rete
(HTTP, proxy, gateway, messaging)
Backend per API JSON
Real time (“soft”). Con Socket.io
Streaming (up & down)
Siti “one page”
Command line tools
Bot
Claudio Cicali - Better Software 2011
25. Non è (ancora?) adatto per...
Applicazioni che fanno uso intensivo di CPU
Medie applicazioni web
Claudio Cicali - Better Software 2011
32. “The guys that are getting paid the big bucks to
deliver scalable solutions aren’t up at night
feverishly rewriting their systems in Node.
They’re doing what they’ve always done:
measuring, testing, benchmarking, thinking hard,
keeping up with the academic literature that
pertains to their problems.”
-- Alex Payne
http://al3x.net/2010/07/27/node.html
Claudio Cicali - Better Software 2011