Giter Club home page Giter Club logo

node.js-practice's Introduction

Node.js-practice

  1. 서버
    • 클라이언트 → (requeset) → 서버 → (response) → 클라이언트
    • 서버 ←-→ 서버
  2. 자바스크립트 런타임
    • 런타임 : 특정 언어로 만든 프로그램들을 실행할 수 있는 환경
    • 웹 브라우저 위에서만 실행할 수 있었던 자바스크립트 코드를 브라우저 외에서 실행
  3. 이벤트 기반
    • 이벤트가 발생할 때 미리 지정해둔 작업을 수행하는 방식
    • 이벤트 리스너에 콜백 함수를 등록
    • 호출한 순서대로 함수를 호출 스택에 넣고 스택의 위에서부터 함수를 꺼내서 실행
    1. 이벤트 루프
      • 이벤트 발생 시 호출할 콜백 함수 관리, 실행 순서 결정
    2. 백그라운드
      • 타이머나 이벤트 리스너들이 대기
    3. 태스크 큐
      • 이벤트 발생 후 백그라운드에서 태스크 큐로 타이머나 이벤트 리스너의 콜백 함수를 보냄
      • 태스크 큐에서 정해진 규칙에 따라 콜백 함수들을 호출 스택으로 부름
  4. 논 블로킹 I/O
    • I/O 작업을 논 블로킹으로 처리 가능
    • 논 블로킹을 통해 실행 순서를 바꿔줌으로써 간단한 작업들이 대기하는 상황을 막을 수 있다.
    • 논 블로킹 ≠ 동시
  5. 싱글 스레드
    • 자바스크립트 코드가 동시에 실행될 수 없는 이유
    • 노드 실행 → 프로세스 생성 → 여러 스레드 생성 → 그 중 제어할 수 있는 스레드는 하나

서버로서의 노드

  • 싱글 스레드, 논 블로킹 모델
  • 서버에는 I/O 요청이 많음 → I/O 처리를 잘하는 노드가 효율적
  • CPU 부하가 큰 작업 → 싱글 스레드가 감당하기 어려움

→ 개수는 많지만 크기는 작은 데이터를 실시간으로 주고받는 작업에 적합

node.js-practice's People

Contributors

rlacksgus97 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.