a Simple Powerful Platform

Hendri Karisma
CodeLabs UNIKOM
2014
What is NodeJS?
“Node.js is a platform built on Chrome’s JavaScript runtime
for easily building fast, scalable network applications.
Node.js uses an event-driven, non-blocking I/O model
that makes it lightweight and efficient, perfect for dataintensive real-time applications that run across
distributed devices.”
How Fast
Against Python3, JavaScript V8 Engine has
a median benchmark 13 times as fast with
a roughly similar code size. 3 Against
Ruby 1.9, the median benchmark is eight
times as fast
Theory
• Build Google’s V8
JavaScript engine
• I/O Latency
I/O Latency
The Problem
Scale with Multi Thread
• Overhead pada switching
• Execution stask take up memory
• Complicate concurrency
Scale with Process
• High memmory Usage
• Process scheduling
The Solution in Node.js
Tantangan
• Asynchronizing I/O
• Debugging
• CPU-Intensive Tasks
– Harus berhati-hati terhadap penggunaan
thread untuk setiap tasks

• Perkembangan versi platform sangat
cepat
Keuntungan
•
•
•

Multiplatform
Lightweight
Deadlock free
– single thread, simplifies concurency

•

Monoglot Programming
– dari mulai back-end hingga front end dapat hanya menggunakan
javascript

•
•
•

Popular
Fast
Community and NPM (8,465 packages)
*2012-03-21

•
•

Small core
Short Learning Curve
NPM
• express
• socket.io
• mongoose

• connect
• async
• jade
how to install node.js
• sudo add-apt-repository ppa:chrislea/node.js
• sudo apt-get update
• sudo apt-get install nodejs
Demo
• Hello World
• SimpleChat Application
MongoDB (NoSql Database)
• Not Only SQL (NoSQL)
• Non Relastional Database Management
System
Kenapa NoSQL (MongoDB)
•
•
•
•
•

Database non relasional
Terdistribusi dan scale out (secara horisontal)
Tanpa skema atau dengan skema yang longgar
Sederhana dalam pemakaian (API)
Kemudahan replikasi
Document-Oriented
• Notion of a Document
• Enkapsulasi dokumen dan enkoding
dalam format standard (XML, JSON,
YAML, PDF, dll)
• Mirip relational DB, tetapi setiap ‘row’ tidak
harus memiliki struktur yang sama.
Demo
• Simple CRUD with express and MongoDB
Thanks....

Hendri Karisma
http://about.me/hendriKarisma
source code sample program demo dapat di download di
https://github.com/situkangsayur?tab=repositories

Slide Seminar Open Source (CodeLabs UNIKOM Bandung)