1st node.js Korea conference




Node.js & Web Service
                    @beejei 김범짂




                                   2012.11.20
Intro

김범진       @beejei
  – Lisn.me의 front 웹 서비스를 Node.js(v0.4.8)로 제작
    (2011.6~2012.3, 현재 v0.6.18)

        Link:




                                            Page 2
Intro

Directmedia
 – 음원 제작사 > 음원 권리사 > 음원 제공사 > 음원 서비스
    제작         투자/육성   권리사들과    멜롞
                       조율을 통해   벅스
                       음원을 확보   다음뮤직
                                …

                                +




                                       Page 3
Index

시작하기 전에 before start
왜 Node.js인가 why Node.js
도입결과 acquire result
리슨미 아키텍쳐 lisn.me architecture
기본기능구현 implement basic functions
문제해결 troubleshooting
팁 tips
의견 my opinion

                                    Page 4
Before start

서비스 작성의 조건

  – Single-Page Application Style
     • Music Player가 멈추지 말아야 하므로…


  – Heavy client-side Javascript

  – Support IE(>6)
     • 보수적으로 작성


  – 시갂이 많지 않음(6개월 내에 베타 서비스 목표)

                                    Page 5
Why Node.js?

 – 빠르다?

 – [from Setup to Dev.] 의 시갂이 짧아서

 – 웹 개발이었기 때문에

 – 지원되는 패키지가 Javascript이었기 때문에

 – 안되면 부분적으로 C로 만들자…



                                    Page 6
Acquire result
각종 난관
  –   연속적인 Async. Programming의 어려움
  –   각종 API들의 버그
  –   UTF8만 지원
  –   SNS 연계상의 문제


결과적으로
  –   6개월 내에 서비스 완성
  –   서비스 피크시기에도 CPU사용률은 10% 전후
  –   약 1년 동안 이유 없이 서비스 다운된 적 없음
  –   어떠한 방식의 해킹 시도가 통했던 적 없음




                                     Page 7
lisn.me architecture

        Nginx                                   Node.js                 Mail
                                                 Application
         Gateway                                                        SendMail
                                                   Server 1
         (lisn.me)                                                       Server
                                             Redis Session Server



                                                Node.js             MySQL
                                                 Application
                                                                        DataBase
                         Storage                  Server 2

                          static file
                      / media file / image
                                                Node.js
                                                    SNS
                                                   Server




        Nginx                                   Node.js
                                             Service Management
        Gateway
                                                     Server
      (img.lisn.me)
                                                                    …

       Wowza
     Media Streaming
         Server


                                                                                   Page 8
Implement basic functions

Starting Express.js
  – # express <test>


Enc./Decrypt Funcs
  – AES 256 Algorithm : openSSL  php 호홖
  – Bcrypt Hash Algorithm : password


File Upload(Progress support)
  – AjaxUpload


http://nodeconf.beejei.com

                                           Page 9
Implement basic functions

multipart.js – custom middleware




                                    Page 10
Troubleshooting
euc-kr problem
  – PG사(Payment Gateway) 모듈은 모두 EUC-KR
  – request : connect.js의 middleware customize로 해결
  – exec : C프로그램으로 해결


Heavy index page
  – Single-Page Application Style의 최대 단점




                                                     Page 11
Troubleshooting
UTFConv - Custom C Program
  – utf-8 input -> euc-kr input / euc-kr output -> utf-8 output




                                                                  Page 12
Tips
Jade 운영
  – Template file I/O를 최소화 – express 3.0에서는 caching이 구현되어
    있음
  – Template Precompile


API 작성 및 운영
  – API 호출시에는 req의 인자로 넘겨서 받도록
       • 웹 호출과 내부 호출이 둘 가 가능함
  – 문서는 최소한의 사양만 정리
       • http://nodeconf.beejei.com/api


서비스 운영 팁
  – 오류 발생시
  – Multicore 사용 – cluster?
                                                       Page 13
My opinion
Node.js의 적재적소
  – 비즈니스 로직이 단순한 다중 커넥션 서비스
  – 일반 웹 서비스의 빠른 prototyping에 최적
    • Static 언어로의 구현이 반드시 필요하다면 spec이 고정된 이후에
      컨버팅


배울점
  – Static언어와 dynamic언어의 절묘한 경계
  – 자주 바뀌고 빠른 prototyping이 필요한
    곳에는 스크립트를 사용하자




                        http://blog.zenika.com/index.php?post/2011/04/10/NodeJS
                                                                                  Page 14
1st node.js Korea conference




              Thank you
                     Q&A?




                               2012.11.20

Beejei node.js & web service

  • 1.
    1st node.js Koreaconference Node.js & Web Service @beejei 김범짂 2012.11.20
  • 2.
    Intro 김범진 @beejei – Lisn.me의 front 웹 서비스를 Node.js(v0.4.8)로 제작 (2011.6~2012.3, 현재 v0.6.18) Link: Page 2
  • 3.
    Intro Directmedia – 음원제작사 > 음원 권리사 > 음원 제공사 > 음원 서비스 제작 투자/육성 권리사들과 멜롞 조율을 통해 벅스 음원을 확보 다음뮤직 … + Page 3
  • 4.
    Index 시작하기 전에 beforestart 왜 Node.js인가 why Node.js 도입결과 acquire result 리슨미 아키텍쳐 lisn.me architecture 기본기능구현 implement basic functions 문제해결 troubleshooting 팁 tips 의견 my opinion Page 4
  • 5.
    Before start 서비스 작성의조건 – Single-Page Application Style • Music Player가 멈추지 말아야 하므로… – Heavy client-side Javascript – Support IE(>6) • 보수적으로 작성 – 시갂이 많지 않음(6개월 내에 베타 서비스 목표) Page 5
  • 6.
    Why Node.js? –빠르다? – [from Setup to Dev.] 의 시갂이 짧아서 – 웹 개발이었기 때문에 – 지원되는 패키지가 Javascript이었기 때문에 – 안되면 부분적으로 C로 만들자… Page 6
  • 7.
    Acquire result 각종 난관 – 연속적인 Async. Programming의 어려움 – 각종 API들의 버그 – UTF8만 지원 – SNS 연계상의 문제 결과적으로 – 6개월 내에 서비스 완성 – 서비스 피크시기에도 CPU사용률은 10% 전후 – 약 1년 동안 이유 없이 서비스 다운된 적 없음 – 어떠한 방식의 해킹 시도가 통했던 적 없음 Page 7
  • 8.
    lisn.me architecture Nginx Node.js Mail Application Gateway SendMail Server 1 (lisn.me) Server Redis Session Server Node.js MySQL Application DataBase Storage Server 2 static file / media file / image Node.js SNS Server Nginx Node.js Service Management Gateway Server (img.lisn.me) … Wowza Media Streaming Server Page 8
  • 9.
    Implement basic functions StartingExpress.js – # express <test> Enc./Decrypt Funcs – AES 256 Algorithm : openSSL  php 호홖 – Bcrypt Hash Algorithm : password File Upload(Progress support) – AjaxUpload http://nodeconf.beejei.com Page 9
  • 10.
    Implement basic functions multipart.js– custom middleware Page 10
  • 11.
    Troubleshooting euc-kr problem – PG사(Payment Gateway) 모듈은 모두 EUC-KR – request : connect.js의 middleware customize로 해결 – exec : C프로그램으로 해결 Heavy index page – Single-Page Application Style의 최대 단점 Page 11
  • 12.
    Troubleshooting UTFConv - CustomC Program – utf-8 input -> euc-kr input / euc-kr output -> utf-8 output Page 12
  • 13.
    Tips Jade 운영 – Template file I/O를 최소화 – express 3.0에서는 caching이 구현되어 있음 – Template Precompile API 작성 및 운영 – API 호출시에는 req의 인자로 넘겨서 받도록 • 웹 호출과 내부 호출이 둘 가 가능함 – 문서는 최소한의 사양만 정리 • http://nodeconf.beejei.com/api 서비스 운영 팁 – 오류 발생시 – Multicore 사용 – cluster? Page 13
  • 14.
    My opinion Node.js의 적재적소 – 비즈니스 로직이 단순한 다중 커넥션 서비스 – 일반 웹 서비스의 빠른 prototyping에 최적 • Static 언어로의 구현이 반드시 필요하다면 spec이 고정된 이후에 컨버팅 배울점 – Static언어와 dynamic언어의 절묘한 경계 – 자주 바뀌고 빠른 prototyping이 필요한 곳에는 스크립트를 사용하자 http://blog.zenika.com/index.php?post/2011/04/10/NodeJS Page 14
  • 15.
    1st node.js Koreaconference Thank you Q&A? 2012.11.20