SlideShare una empresa de Scribd logo
1 de 25
Jesang Yoon
CTO / Kanizsa Lab Co., Ltd
• LinkedIn: https://kr.linkedin.com/in/jesangyoon
• Rocket Punch:https://www.rocketpunch.com/@JeSangYoon
• yoonjs2@kanizsalab.com
• Yoonjs2@naver.com
• Javascript를이용하여 (Web)서버 프로그래밍을
할 수 있도록 도와주는 Framework
• GoogleChrome V8 Engine 을 Runtime으로 사용
• POSIX AsyncThread를 이용하여
Non Blocking Asynchronous I/O를 지원
• Single Threaded, MessageQueue, Event Based
• Joyent라는 회사가 Maintain을 하고 있는 오픈소스 프로젝트https://nodejs.org
TJ Fontaine
3rd BDFL of node.js
Issac Schlueter
2nd BDFL of node.js
Founder or NPM
Ryan Dahl
Founder of node.js
2011
2012
2013
2014
2015
2009
Mikael Rogers
Core Maintainer of io.js
https://nodejs.org/en/download/releases/
분열된 커뮤니티 통합
node.js + io.js
Joyent 와 의견차이로 인해
node 핵심 개발자들이
io.js 로 분열
Tomcat
reference: http://strongloop.com
Multithreaded Model
Tomcat 등의 Java기반 Webserver
• Pro
• Simple to implement
• Many, Many references
• Con
• 1 Thread/Request = Memory Inefficient
• Concurrency Problems
• Blocking IO = Bottleneck
reference: http://strongloop.com
node.js
Event Loop Model
node.js, Vert.x 등의 최신 Webserver
• Pro
• Blazingly Fast = Non-blocking I/O Advantage
• Memory efficient (? = Message Queue Cost)
• Single threaded = Less Concurrency Problem
• Con
• Hard to Implement (Callbacks)
• Inefficient CPU Performance
• Hard to Scale-up
• Hard to build large application
(better to be Lambda or Microservices)
Frontend Server
AWS t2.mirco x 2 ~
3.3GHz Xeon, 1G Ram
Clustered Mode (3 process)
1 Year 2 Month
in production
Frontend Server
AWS t2.mirco x 2 ~
3.3GHz Xeon, 1G Ram
Clustered Mode
In preparation
Tool Pro Con Suggestion
Vim Directly edit in server
No auto-completion
No syntax checking
Emergency hot fix in server
Sublime Text
Light weight than IDE
Many plugins
No auto-completion
No syntax checking
Replacement of notepad
Visual Studio
Convenient Scheme
Many functions
Too heavy
Full support only for Windows (sucks)
If you are big fan of Windows
PyCharm
Many functions
Nice remote features
Less heavy
Must install node.js plugin
If you working with Python and
node.js same time
IntelliJ IDEA
Many functions
Built-in node.js support
Too heavy (Multi-purpose) If you are big fan of all-in-one
Because of dynamic/interpreter aspect of JS, IDE may nice for productivity,
but mix tools for purpose may required also.
There is no common structure for node.js applications
but you’d better to stick with CommonJS way (Although may not good for web compatibility)
Root
Module_A
application.js
index.js
module_1.js
var module_A = require(“./Module_A”)(a);
module_A.foo(x);
module.export = function(a) {
return {
foo: function(x) { console.log(x) }
};
}
module.export = function(a) {
require(“./module_1.js”)(a);
// require(“./module_2.js”);
}
main
Due to the difference language paradigm and conceptually incomplete to support OOP,
Using OOP style in node.js is possible but better not to strictly rely on it.
Better to apply only for specific objects (like Error/Exception Object)
Error
HttpError
function Error(message) { // In JS world, function is object too
this.message = “I am error”;
};
var util = require(”util”);
function HttpError(responseCode, message) {
Error.call(message); // call parent constructor
this.responseCode = responseCode;
this.name = ”HttpError”;
};
util.inherits(HttpError, Error); // explicitly use node.js inheritence
BadRequestError
If you need compatibility between Web JS and node.js, Do not use this way.
Instead, use inheritance using JS prototype
Its very prone to be encounter complex callbacks since asynchronous feature of node.js (or async JS)
It’s very bad practice of JS programming and should be avoided.
Trivia: Joyent core developer still sticks with callbacks since they want to keep low-level simplicity
but It’s very controversy between many node.js developers. (and they blame joyent about that)
To overcome drawbacks of callbacks, Promise like techniques are widely used.
The concept of Promise is using Object to communicate between callbacks.
Promise (Promise A+) had become standard feature of ES6 Javascript.
var file = reqire(“./file”);
file.open(function(err, fp) {
// How to handle errors?
file.read(fp, function(err, content) {
for (var item in content) {
file.replace(item, “new item”, function (err, fp) {
file.commit(fp, function(err) {
// How to close file when its done?
});
});
}
});
});
var file = reqire(“./file”);
file.open()
.then(function (fp) {
return file.read(fp);
})
.all(function (item) {
return file.replace(item, ‘new item’);
})
.then(function(fp) {
return file.commit(fp);
})
.then(function() {
return file.close();
})
.catch(function(err) {
console.log(‘Errors are handled:’ + err);
return file.revert();
});
https://promisesaplus.com/
Old Javascript callback hell
New programming concept born from resolving callback hell
Must see: http://blog.namangoel.com/dealing-with-callback-hell
Promise A+ Reactive
Programming
Generators
Library Purpose Pro Con Suggestion
Restify
RESTful Server
Framework
- Light-weight
- Very focused for RESTful API
Implementation
- Less middleware feature
- Poor documentation
If you fed up with Express JS and
only you need is RESTful API
Sequelize ORM
- Best ORM Library
- Well documented
- Lack of some GIS feature
- Auto sync may bad
Be safe to use sync()
Underscore
Common
Utilities
- 100% Web compatible
- Light and easy to use
- Lack of function for arguments
object
If you not on ES6, use it.
Bluebird Promise A+
- 100% Compatible with
ES 6 Promise
- Best Promise A+ Library
- Has some memory leaks
- Less documentation
If you not on ES6, use it.
Mocha TDD/BDD
- Best BDD/TDD Framework
- Best with should.js
- May be old If you have no preference, use it.
Passport JS
Oauth
/ Social Login
- Best Login Library
- Many Strategies
- Some strategies may need to be
fixed on your own.
If you don’t want to build your own
login feature, use it.
node.js and JS community is very large and rapidly growing,
So you have to checkout good libraries at NPM and Github to reduce time to search.
Many web frameworks exists for node.js but all of them has pro/cons = no superb one.
You have to choose right tool for your right purposes. (Avoid Tech Masturbation)
Name Express JS Hapi Restify Strongloop
Pro • All-in-one (Web/RESTful)
• Many 3rd party middlewares
• Service by Manifest
• Walmart Support
• Light weight
• Dtrace support
• Only for RESTful Service
• For Enterprise
• Nice dashboard, Profiler
• Swagger included
Con
• Very complex to use/fix
• Soon will be decayed
• Static content can be
served via nginx or apache
• Less middleware
• Express code cannot be used
• Poor documentation
• Have to build everything you
needed.
• Only for Enterprise
• Memory leaks
• Very heavy
• No OSS
Due to the structure limitations, node.js may very bad choice for certain applications
If you need intensive CPU jobs, consider use Python or Java. (http://imjuni.tistory.com/694)
Events are not processed in enough time.
Event queue is rapidly grow
Memory is growing fast
Heavy CPU process/wait in callbacks
Segmentation Fault may happen
V8 Engine GC has two way in memory management, each will executed respectively
https://strongloop.com/strongblog/node-js-performance-garbage-collection/
Full GC
(Mark and Sweep & Mark and Compact)
Short GC
(Scavengering)
Checkout RSS/Heap Size/Heap total to checkout memory leaks.
Watch your Heap growth pattern before and after GC using Continuous request for period
Full GC
(Mark and Sweep & Mark and Compact)
Short GC
(Scavengering)
Normal
Memory Leaking
Segment Fault
OS kills app
Heap & RSS are kepp growing
Running server with high pressure of request may not help to find out actual problem.
Using google chrome dev tools and few other libraries, you can profile your applications
Must see: https://www.joyent.com/blog/walmart-node-js-memory-leak
Golden rules
1. Narrow down causes
2. Wait, Collect, Compare
3. Check your throught-put
4. Most of all: Build with KISS
Wallmart Memory LeakCase (Running for 15 hours )
Due to the Javascripts less type safe and very dynamic features,
Unit Testing is very crucial to assure quality of Application (NO TDD, NO DEV)
Type What to Test Goal How to Test Together with
Module Test Module To assure quality
of module
UT/TDD with
randominputs
Feature Test API To assure quality
of each features
UT/BDD with
random inputs
Load Runner
Scenario Test Business Logic To assure quality
of scenario
UT/BDD with
random inputs
Load Runner
You have to run regression Test for all above 3 (If possible).
Managing bulk of codes in Unit Testing is not that easy
Kanizsa Lab's Software Testing Policy
Single Mode Clustered Mode
PID: 1
PID: 1
master
PID: 2
slave 1
PID: 3
slave 2
PID: 1
master
PID: 2
slave 1
PID: 3
slave 2
Clustered Mode
with Forever
Forever
To enable scalability in node.js, Clustered Mode is supported (Process Fork) but you have to manage
slaves by yourself. Using forever daemon to watch master process status is encouraged.
Recommended size of slaves = number of CPUs (But you’d better check out enough memory exists)
Logging is very important but have to keep a “golden mean”
1) Do not give burden to process 2) Enough to be detailed 3) Machine Understandable 4) Server wide standard format
PID: 1
node
bunyan
CRON
JOB
Logrotate
File
AWS
S3upload
JSON
node bunyan is the best library to logging with JSON
bunyan is also main logging library of Joyent Cloud
Not recommended:
Upload to NoSQL directly via app internal library
Seems too much in early stages:
Using transport system like Flume, Kafka, Fluentd
these technology required by enough large clusters
Logrotate
node.js is still rapidly growing and expanding its supporting platforms from server to embedded
devices. the best advantage of node.js: Fast I/O with less memory and easy to start makes it a very
fascinating framework to learn for developers. So keep watch it!
IoT.js (Forked version of node.js) by Samsung node.js running on Raspberry-Pi as application framework
node.js 실무 - node js in practice by Jesang Yoon

Más contenido relacionado

La actualidad más candente

Jeffrey Richter
Jeffrey RichterJeffrey Richter
Jeffrey RichterCodeFest
 
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM Bluemix
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM BluemixPyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM Bluemix
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM BluemixJin Gi Kong
 
Tooling for the productive front-end developer
Tooling for the productive front-end developerTooling for the productive front-end developer
Tooling for the productive front-end developerMaurice De Beijer [MVP]
 
Сергей Калинец "Стероиды для Дотнетчика"
Сергей Калинец "Стероиды для Дотнетчика"Сергей Калинец "Стероиды для Дотнетчика"
Сергей Калинец "Стероиды для Дотнетчика"Fwdays
 
Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming Virtual JBoss User Group
 
Pipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWSPipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWSJimmy Ray
 
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Seven Peaks Speaks
 
Reflections On Serverless
Reflections On ServerlessReflections On Serverless
Reflections On ServerlessDiego Pacheco
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Shivam Bharadwaj
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshopAssaf Gannon
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Dev objective2015 lets git together
Dev objective2015 lets git togetherDev objective2015 lets git together
Dev objective2015 lets git togetherColdFusionConference
 
gRPC @ Weaveworks
gRPC @ WeaveworksgRPC @ Weaveworks
gRPC @ WeaveworksWeaveworks
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020Eran Stiller
 

La actualidad más candente (20)

[AWSKRUG&JAWS-UG Meetup #1] Serverless Real-Time Analysis
[AWSKRUG&JAWS-UG Meetup #1]  Serverless  Real-Time Analysis[AWSKRUG&JAWS-UG Meetup #1]  Serverless  Real-Time Analysis
[AWSKRUG&JAWS-UG Meetup #1] Serverless Real-Time Analysis
 
Jeffrey Richter
Jeffrey RichterJeffrey Richter
Jeffrey Richter
 
Swagger code motion talk
Swagger code motion talkSwagger code motion talk
Swagger code motion talk
 
Render-as-You-Fetch
Render-as-You-FetchRender-as-You-Fetch
Render-as-You-Fetch
 
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM Bluemix
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM BluemixPyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM Bluemix
PyCon APAC 2016: Django, Flask 고민없이 개발하고 서비스하는 PaaS, IBM Bluemix
 
Tooling for the productive front-end developer
Tooling for the productive front-end developerTooling for the productive front-end developer
Tooling for the productive front-end developer
 
Stripe con 2021 UI stack
Stripe con 2021 UI stackStripe con 2021 UI stack
Stripe con 2021 UI stack
 
Сергей Калинец "Стероиды для Дотнетчика"
Сергей Калинец "Стероиды для Дотнетчика"Сергей Калинец "Стероиды для Дотнетчика"
Сергей Калинец "Стероиды для Дотнетчика"
 
Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming
 
Pipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWSPipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWS
 
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Structuring node.js projects - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
 
Reflections On Serverless
Reflections On ServerlessReflections On Serverless
Reflections On Serverless
 
The busy developers guide to Docker
The busy developers guide to DockerThe busy developers guide to Docker
The busy developers guide to Docker
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
AWS elastic beanstalk
AWS elastic beanstalkAWS elastic beanstalk
AWS elastic beanstalk
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Dev objective2015 lets git together
Dev objective2015 lets git togetherDev objective2015 lets git together
Dev objective2015 lets git together
 
gRPC @ Weaveworks
gRPC @ WeaveworksgRPC @ Weaveworks
gRPC @ Weaveworks
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020
 

Similar a node.js 실무 - node js in practice by Jesang Yoon

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...Jesse Gallagher
 
Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019Andrea Tosato
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And BeyondVMware Tanzu
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWRgouthamrv
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsSadayuki Furuhashi
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksThomas Fuchs
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
J2EE Batch Processing
J2EE Batch ProcessingJ2EE Batch Processing
J2EE Batch ProcessingChris Adkin
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application developmentshelloidhq
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsManuel Eusebio de Paz Carmona
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questionstechievarsity
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 

Similar a node.js 실무 - node js in practice by Jesang Yoon (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019
 
Nodejs
NodejsNodejs
Nodejs
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
 
NodeJS
NodeJSNodeJS
NodeJS
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
J2EE Batch Processing
J2EE Batch ProcessingJ2EE Batch Processing
J2EE Batch Processing
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application development
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first steps
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questions
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 

Más de Jesang Yoon

AWS Cloud Job Fair 2022 발표자료
AWS Cloud Job Fair 2022 발표자료AWS Cloud Job Fair 2022 발표자료
AWS Cloud Job Fair 2022 발표자료Jesang Yoon
 
DevOps는 원격근무를 추구하면 안되는 걸까?
DevOps는 원격근무를 추구하면 안되는 걸까?DevOps는 원격근무를 추구하면 안되는 걸까?
DevOps는 원격근무를 추구하면 안되는 걸까?Jesang Yoon
 
Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Jesang Yoon
 
Project TIMAT - infrastructure as code
Project TIMAT - infrastructure as codeProject TIMAT - infrastructure as code
Project TIMAT - infrastructure as codeJesang Yoon
 
AWS S3를 이용한 효과적인 SPA 배포
AWS S3를 이용한 효과적인 SPA 배포AWS S3를 이용한 효과적인 SPA 배포
AWS S3를 이용한 효과적인 SPA 배포Jesang Yoon
 
AWS Lambda를 이용한 CI/CD 기법
AWS Lambda를 이용한 CI/CD 기법AWS Lambda를 이용한 CI/CD 기법
AWS Lambda를 이용한 CI/CD 기법Jesang Yoon
 
대기업에서 스타트업 까지 - 윤제상
대기업에서 스타트업 까지 - 윤제상대기업에서 스타트업 까지 - 윤제상
대기업에서 스타트업 까지 - 윤제상Jesang Yoon
 

Más de Jesang Yoon (7)

AWS Cloud Job Fair 2022 발표자료
AWS Cloud Job Fair 2022 발표자료AWS Cloud Job Fair 2022 발표자료
AWS Cloud Job Fair 2022 발표자료
 
DevOps는 원격근무를 추구하면 안되는 걸까?
DevOps는 원격근무를 추구하면 안되는 걸까?DevOps는 원격근무를 추구하면 안되는 걸까?
DevOps는 원격근무를 추구하면 안되는 걸까?
 
Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기
 
Project TIMAT - infrastructure as code
Project TIMAT - infrastructure as codeProject TIMAT - infrastructure as code
Project TIMAT - infrastructure as code
 
AWS S3를 이용한 효과적인 SPA 배포
AWS S3를 이용한 효과적인 SPA 배포AWS S3를 이용한 효과적인 SPA 배포
AWS S3를 이용한 효과적인 SPA 배포
 
AWS Lambda를 이용한 CI/CD 기법
AWS Lambda를 이용한 CI/CD 기법AWS Lambda를 이용한 CI/CD 기법
AWS Lambda를 이용한 CI/CD 기법
 
대기업에서 스타트업 까지 - 윤제상
대기업에서 스타트업 까지 - 윤제상대기업에서 스타트업 까지 - 윤제상
대기업에서 스타트업 까지 - 윤제상
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Último (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

node.js 실무 - node js in practice by Jesang Yoon

  • 1.
  • 2. Jesang Yoon CTO / Kanizsa Lab Co., Ltd • LinkedIn: https://kr.linkedin.com/in/jesangyoon • Rocket Punch:https://www.rocketpunch.com/@JeSangYoon • yoonjs2@kanizsalab.com • Yoonjs2@naver.com
  • 3. • Javascript를이용하여 (Web)서버 프로그래밍을 할 수 있도록 도와주는 Framework • GoogleChrome V8 Engine 을 Runtime으로 사용 • POSIX AsyncThread를 이용하여 Non Blocking Asynchronous I/O를 지원 • Single Threaded, MessageQueue, Event Based • Joyent라는 회사가 Maintain을 하고 있는 오픈소스 프로젝트https://nodejs.org
  • 4. TJ Fontaine 3rd BDFL of node.js Issac Schlueter 2nd BDFL of node.js Founder or NPM Ryan Dahl Founder of node.js 2011 2012 2013 2014 2015 2009 Mikael Rogers Core Maintainer of io.js https://nodejs.org/en/download/releases/ 분열된 커뮤니티 통합 node.js + io.js Joyent 와 의견차이로 인해 node 핵심 개발자들이 io.js 로 분열
  • 5. Tomcat reference: http://strongloop.com Multithreaded Model Tomcat 등의 Java기반 Webserver • Pro • Simple to implement • Many, Many references • Con • 1 Thread/Request = Memory Inefficient • Concurrency Problems • Blocking IO = Bottleneck
  • 6. reference: http://strongloop.com node.js Event Loop Model node.js, Vert.x 등의 최신 Webserver • Pro • Blazingly Fast = Non-blocking I/O Advantage • Memory efficient (? = Message Queue Cost) • Single threaded = Less Concurrency Problem • Con • Hard to Implement (Callbacks) • Inefficient CPU Performance • Hard to Scale-up • Hard to build large application (better to be Lambda or Microservices)
  • 7. Frontend Server AWS t2.mirco x 2 ~ 3.3GHz Xeon, 1G Ram Clustered Mode (3 process) 1 Year 2 Month in production Frontend Server AWS t2.mirco x 2 ~ 3.3GHz Xeon, 1G Ram Clustered Mode In preparation
  • 8.
  • 9. Tool Pro Con Suggestion Vim Directly edit in server No auto-completion No syntax checking Emergency hot fix in server Sublime Text Light weight than IDE Many plugins No auto-completion No syntax checking Replacement of notepad Visual Studio Convenient Scheme Many functions Too heavy Full support only for Windows (sucks) If you are big fan of Windows PyCharm Many functions Nice remote features Less heavy Must install node.js plugin If you working with Python and node.js same time IntelliJ IDEA Many functions Built-in node.js support Too heavy (Multi-purpose) If you are big fan of all-in-one Because of dynamic/interpreter aspect of JS, IDE may nice for productivity, but mix tools for purpose may required also.
  • 10. There is no common structure for node.js applications but you’d better to stick with CommonJS way (Although may not good for web compatibility) Root Module_A application.js index.js module_1.js var module_A = require(“./Module_A”)(a); module_A.foo(x); module.export = function(a) { return { foo: function(x) { console.log(x) } }; } module.export = function(a) { require(“./module_1.js”)(a); // require(“./module_2.js”); } main
  • 11. Due to the difference language paradigm and conceptually incomplete to support OOP, Using OOP style in node.js is possible but better not to strictly rely on it. Better to apply only for specific objects (like Error/Exception Object) Error HttpError function Error(message) { // In JS world, function is object too this.message = “I am error”; }; var util = require(”util”); function HttpError(responseCode, message) { Error.call(message); // call parent constructor this.responseCode = responseCode; this.name = ”HttpError”; }; util.inherits(HttpError, Error); // explicitly use node.js inheritence BadRequestError If you need compatibility between Web JS and node.js, Do not use this way. Instead, use inheritance using JS prototype
  • 12. Its very prone to be encounter complex callbacks since asynchronous feature of node.js (or async JS) It’s very bad practice of JS programming and should be avoided. Trivia: Joyent core developer still sticks with callbacks since they want to keep low-level simplicity but It’s very controversy between many node.js developers. (and they blame joyent about that)
  • 13. To overcome drawbacks of callbacks, Promise like techniques are widely used. The concept of Promise is using Object to communicate between callbacks. Promise (Promise A+) had become standard feature of ES6 Javascript. var file = reqire(“./file”); file.open(function(err, fp) { // How to handle errors? file.read(fp, function(err, content) { for (var item in content) { file.replace(item, “new item”, function (err, fp) { file.commit(fp, function(err) { // How to close file when its done? }); }); } }); }); var file = reqire(“./file”); file.open() .then(function (fp) { return file.read(fp); }) .all(function (item) { return file.replace(item, ‘new item’); }) .then(function(fp) { return file.commit(fp); }) .then(function() { return file.close(); }) .catch(function(err) { console.log(‘Errors are handled:’ + err); return file.revert(); }); https://promisesaplus.com/ Old Javascript callback hell
  • 14. New programming concept born from resolving callback hell Must see: http://blog.namangoel.com/dealing-with-callback-hell Promise A+ Reactive Programming Generators
  • 15. Library Purpose Pro Con Suggestion Restify RESTful Server Framework - Light-weight - Very focused for RESTful API Implementation - Less middleware feature - Poor documentation If you fed up with Express JS and only you need is RESTful API Sequelize ORM - Best ORM Library - Well documented - Lack of some GIS feature - Auto sync may bad Be safe to use sync() Underscore Common Utilities - 100% Web compatible - Light and easy to use - Lack of function for arguments object If you not on ES6, use it. Bluebird Promise A+ - 100% Compatible with ES 6 Promise - Best Promise A+ Library - Has some memory leaks - Less documentation If you not on ES6, use it. Mocha TDD/BDD - Best BDD/TDD Framework - Best with should.js - May be old If you have no preference, use it. Passport JS Oauth / Social Login - Best Login Library - Many Strategies - Some strategies may need to be fixed on your own. If you don’t want to build your own login feature, use it. node.js and JS community is very large and rapidly growing, So you have to checkout good libraries at NPM and Github to reduce time to search.
  • 16. Many web frameworks exists for node.js but all of them has pro/cons = no superb one. You have to choose right tool for your right purposes. (Avoid Tech Masturbation) Name Express JS Hapi Restify Strongloop Pro • All-in-one (Web/RESTful) • Many 3rd party middlewares • Service by Manifest • Walmart Support • Light weight • Dtrace support • Only for RESTful Service • For Enterprise • Nice dashboard, Profiler • Swagger included Con • Very complex to use/fix • Soon will be decayed • Static content can be served via nginx or apache • Less middleware • Express code cannot be used • Poor documentation • Have to build everything you needed. • Only for Enterprise • Memory leaks • Very heavy • No OSS
  • 17. Due to the structure limitations, node.js may very bad choice for certain applications If you need intensive CPU jobs, consider use Python or Java. (http://imjuni.tistory.com/694) Events are not processed in enough time. Event queue is rapidly grow Memory is growing fast Heavy CPU process/wait in callbacks Segmentation Fault may happen
  • 18. V8 Engine GC has two way in memory management, each will executed respectively https://strongloop.com/strongblog/node-js-performance-garbage-collection/ Full GC (Mark and Sweep & Mark and Compact) Short GC (Scavengering)
  • 19. Checkout RSS/Heap Size/Heap total to checkout memory leaks. Watch your Heap growth pattern before and after GC using Continuous request for period Full GC (Mark and Sweep & Mark and Compact) Short GC (Scavengering) Normal Memory Leaking Segment Fault OS kills app Heap & RSS are kepp growing
  • 20. Running server with high pressure of request may not help to find out actual problem. Using google chrome dev tools and few other libraries, you can profile your applications Must see: https://www.joyent.com/blog/walmart-node-js-memory-leak Golden rules 1. Narrow down causes 2. Wait, Collect, Compare 3. Check your throught-put 4. Most of all: Build with KISS Wallmart Memory LeakCase (Running for 15 hours )
  • 21. Due to the Javascripts less type safe and very dynamic features, Unit Testing is very crucial to assure quality of Application (NO TDD, NO DEV) Type What to Test Goal How to Test Together with Module Test Module To assure quality of module UT/TDD with randominputs Feature Test API To assure quality of each features UT/BDD with random inputs Load Runner Scenario Test Business Logic To assure quality of scenario UT/BDD with random inputs Load Runner You have to run regression Test for all above 3 (If possible). Managing bulk of codes in Unit Testing is not that easy Kanizsa Lab's Software Testing Policy
  • 22. Single Mode Clustered Mode PID: 1 PID: 1 master PID: 2 slave 1 PID: 3 slave 2 PID: 1 master PID: 2 slave 1 PID: 3 slave 2 Clustered Mode with Forever Forever To enable scalability in node.js, Clustered Mode is supported (Process Fork) but you have to manage slaves by yourself. Using forever daemon to watch master process status is encouraged. Recommended size of slaves = number of CPUs (But you’d better check out enough memory exists)
  • 23. Logging is very important but have to keep a “golden mean” 1) Do not give burden to process 2) Enough to be detailed 3) Machine Understandable 4) Server wide standard format PID: 1 node bunyan CRON JOB Logrotate File AWS S3upload JSON node bunyan is the best library to logging with JSON bunyan is also main logging library of Joyent Cloud Not recommended: Upload to NoSQL directly via app internal library Seems too much in early stages: Using transport system like Flume, Kafka, Fluentd these technology required by enough large clusters Logrotate
  • 24. node.js is still rapidly growing and expanding its supporting platforms from server to embedded devices. the best advantage of node.js: Fast I/O with less memory and easy to start makes it a very fascinating framework to learn for developers. So keep watch it! IoT.js (Forked version of node.js) by Samsung node.js running on Raspberry-Pi as application framework