SlideShare a Scribd company logo
NGINX Architecture
20171625 손건 – SA Homework2
What is NGINX?
Event-Driven
C10K 문제를 해결하기 위해
2004년 Igor Sysoev가
High performance
High Concurrency
Low Memory Usage
세가지에 집중해 만든
웹 서버 데몬
목표 특징 효과
3가지 특징들 덕분에
동시 접속자 수가 많은 경우
요청을 빠른 반응 속도와
효과적으로 처리할 수 있음.
Event-Driven
Asynchronous
Non-Blocking
NGINX Use Case 1
외부에서 들어오는
Request들에 대해서
Gateway의 역할을 해준다.
외부와의 통신은 https로
서버 내부에서는 http로 통신
하는 등 SSL적용도 가능하다.
NGINX Use Case 2
API Gateway의 역할로
각각 path에 맞는 서버로
Redirection 시켜준다.
MSA 구조에서 쓰이는
형태이다.
NGINX Use Case 3
Reverse Proxy로 작동을 해
각 서버에 Load Balancing을
해주는 역할을 한다.
High Level Architecture View
High Level Architecture View
Master-Worker
Model
Module System
Master ­ Worker Model
Master
Process
Worker
Process1
Worker
Process2
Worker
Process2
Master Process
권한이 필요한 작업들을 담당한다.
서버와 관련된 설정들을 읽고
port를 binding한다.
또한 CPU갯수 만큼 Worker Process를
생성하고 Resource들을 관리해준다.
Worker Process
실제 Connection과 관련된 일들을 모두
처리한다. 내부적으로는 단일 쓰레드로 동작
하지만 많은 수의 Connection을 비동기로
처리하는 event-driven run-loop가
동작한다
Compare to Apache
Apache 방식은 Connection 한 개당 프로세스 혹은 쓰레드를
한 개씩 만들어줘야한다. 이런 방식을 1000개의 Connection을 10초간
처리해줘야 할 경우 쓰레드 한 개당 1Mb를 사용하게 할 경우 약 1Gb를
사용하게 된다.
Modern Web 환경에서는 브라우저가 여러개의 Connection을 열고
리소스에 접근해야 하기 때문에 더 많은 Connection에 대해 버틸 수 있는
능력이 필요하다.
Compare to Apache
Apache
Connection 한 개당 프로세스 혹은 쓰레드를 한 개씩
만들어줘야한다.
이런 방식을 통해 1000개의 Connection을 10초간
처리해줘야 할 경우 쓰레드 한 개당 1Mb를 사용하게 할 경우
약 1Gb를 사용하게 된다.
NGINX
CPU갯수에 맞춘 프로세스가 각각 싱글스레드로 여러개의
Connection을 비동기 방식으로처리 하기 때문에
Apache의 방식에 비해 Context Switching의 비용도
적고 메모리도 적게 소모하게 된다
Modern Web 환경에서는 브라우저가 여
러개의 Connection을 열고
많은 리소스에 접근하기 때문에
더 많은 Connection에 대해
버틸 수 있는 능력이 필요하다.
C10K Problem
Dual Core Cpu, 2Gb Ram, 1Gbps Lan
표준 장비에서 어떻게 10K connection을
처리할 것 인가
Master ­ Worker Model
NGINX Modules
- NGINX Core
- NGINX Modules
- Handler
- Protocol
- Event Module
- Filter
Module System을 이용하기 때문에 다양한 기능들을 Core의 변경없이 추가 할 수 있다.
Ex. Protocol 구현 Link
Module System
NGINX Module Working
Core은 TCP Connection과 같은 매우 밑단의
작업을 해준다.
Handler와 Core 사이에는 functional module이
Protocol (HTTP)와 같은 Protocol을 구현 해 주고
Handler는 여러개의 Filter들을 통해
Header, Body를 처리하고 Response를 보내준다.
이때 Filter는 Pipe-Line 구조로 Unix Pipe와
같은 방식으로 도착한다.
Filter Ex. Encryption, Compression
NGINX
기존의 서버 구조와 다른 형태의 Event-driven 형식을 통해 빠른 처리속도를 가지고
Concurrency를 극대화 해서 여러개의 Connection을 처리 할 수 있는것이 매우 인상적
이였다.
또한 Module을 통해 단지 웹서버 뿐만 아니라 동영상 스트리밍 메일 등 다양한 프로토콜
들을 처리할 수 있게 만들 수 있는 확장성 또한 좋다.
NGINX는 Apache에 비해 다양한 이점을 가져서 앞으로도 점점 점유율이 더 높아질 것을
기대해 볼 수 있을 것 같다.
• http://www.aosabook.org/en/nginx.html
• https://velog.io/@jeff0720/2018-11-18-2111-
%EC%9E%91%EC%84%B1%EB%90%A8-iojomvsf0n
• http://www.kegel.com/c10k.html#top
• https://dzone.com/articles/inside-nginx-how-we-designed
• https://d2.naver.com/helloworld/192785
• https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-
spdy-code/
Reference

More Related Content

PPTX
High Availability Content Caching with NGINX
PDF
NGINX: Basics and Best Practices EMEA
PPTX
Introduction to NGINX web server
PPTX
Maria db 이중화구성_고민하기
PPTX
NGINX: High Performance Load Balancing
PDF
Wp100963 jython scripting with wsadmin tutorial
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
PPTX
Learn nginx in 90mins
High Availability Content Caching with NGINX
NGINX: Basics and Best Practices EMEA
Introduction to NGINX web server
Maria db 이중화구성_고민하기
NGINX: High Performance Load Balancing
Wp100963 jython scripting with wsadmin tutorial
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Learn nginx in 90mins

What's hot (20)

PPTX
Load Balancing and Scaling with NGINX
PPTX
NGINX: Basics and Best Practices
PDF
Proxysql sharding
PDF
[2018] MySQL 이중화 진화기
PDF
MariaDB 마이그레이션 - 네오클로바
PPTX
NGINX Installation and Tuning
PDF
아마존 클라우드와 함께한 1개월, 쿠키런 사례중심 (KGC 2013)
PPTX
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
PDF
Best Practice in Accelerating Data Applications with Spark+Alluxio
PDF
Apache Flink Worst Practices
PDF
How to build massive service for advance
PDF
Nginx dhruba mandal
PDF
실전 서버 부하테스트 노하우
PPTX
LSM Trees
PDF
Data Distribution and Ordering for Efficient Data Source V2
PDF
웹서버 부하테스트 실전 노하우
PDF
쿠키런 1년, 서버개발 분투기
PDF
webservice scaling for newbie
PDF
How to Manage Scale-Out Environments with MariaDB MaxScale
Load Balancing and Scaling with NGINX
NGINX: Basics and Best Practices
Proxysql sharding
[2018] MySQL 이중화 진화기
MariaDB 마이그레이션 - 네오클로바
NGINX Installation and Tuning
아마존 클라우드와 함께한 1개월, 쿠키런 사례중심 (KGC 2013)
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
Best Practice in Accelerating Data Applications with Spark+Alluxio
Apache Flink Worst Practices
How to build massive service for advance
Nginx dhruba mandal
실전 서버 부하테스트 노하우
LSM Trees
Data Distribution and Ordering for Efficient Data Source V2
웹서버 부하테스트 실전 노하우
쿠키런 1년, 서버개발 분투기
webservice scaling for newbie
How to Manage Scale-Out Environments with MariaDB MaxScale
Ad

Similar to Nginx Architecture (20)

PPTX
20170609 tech day_4th-nginx(lb)-이재훈
PPTX
PHP를 위한 NginX(엔진엑스) 시작과 설정
PDF
build a linux webhosting server
PDF
FCGI, C++로 Restful 서버 개발
PDF
(OCI 탐험일지) nginx 설치(오라클 리눅스 7)
PDF
Nginx basic configurations
PPTX
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
PDF
HTTP 완벽가이드 - ch5. web server
PPTX
코딩에는 좋은 노트북이 필요 없다
PPTX
PDF
AWS EC2 flask_uwsgi_nginx install guide korean
PDF
Internship backend
PPTX
200.마이크로서비스에 적합한 오픈소스 WAS는 무엇?
PDF
웹기반원격감시제어 2010 CPD
PPTX
Lw4.2
PDF
DGMIT 제3회 R&D 컨퍼런스 r&d1 team : HTTP 프로토콜 개요
PDF
모바일 메신저 아키텍쳐 소개
PDF
파이썬 웹 프로그래밍 2탄
PDF
Human designproject 최종발표
PDF
ALB+EC2 to API gateway + Lambda
20170609 tech day_4th-nginx(lb)-이재훈
PHP를 위한 NginX(엔진엑스) 시작과 설정
build a linux webhosting server
FCGI, C++로 Restful 서버 개발
(OCI 탐험일지) nginx 설치(오라클 리눅스 7)
Nginx basic configurations
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
HTTP 완벽가이드 - ch5. web server
코딩에는 좋은 노트북이 필요 없다
AWS EC2 flask_uwsgi_nginx install guide korean
Internship backend
200.마이크로서비스에 적합한 오픈소스 WAS는 무엇?
웹기반원격감시제어 2010 CPD
Lw4.2
DGMIT 제3회 R&D 컨퍼런스 r&d1 team : HTTP 프로토콜 개요
모바일 메신저 아키텍쳐 소개
파이썬 웹 프로그래밍 2탄
Human designproject 최종발표
ALB+EC2 to API gateway + Lambda
Ad

More from 건 손 (8)

PDF
dbt 101
PDF
소프트웨어에 물들다 - 소프트웨어를 만드는 프로그래밍 언어
PDF
Golaksa 개발기 손건
PDF
Understanding for loop
PDF
콕콕 발표자료
PDF
Item27 familiarize yourself with alternatives to overloading on universal ref...
PPTX
Item22 when using the pimpl idiom, define special memberfuctions in the imple...
PPTX
Modern Effective C++ Item2 Understanding Auto type deducing
dbt 101
소프트웨어에 물들다 - 소프트웨어를 만드는 프로그래밍 언어
Golaksa 개발기 손건
Understanding for loop
콕콕 발표자료
Item27 familiarize yourself with alternatives to overloading on universal ref...
Item22 when using the pimpl idiom, define special memberfuctions in the imple...
Modern Effective C++ Item2 Understanding Auto type deducing

Nginx Architecture

  • 2. What is NGINX? Event-Driven C10K 문제를 해결하기 위해 2004년 Igor Sysoev가 High performance High Concurrency Low Memory Usage 세가지에 집중해 만든 웹 서버 데몬 목표 특징 효과 3가지 특징들 덕분에 동시 접속자 수가 많은 경우 요청을 빠른 반응 속도와 효과적으로 처리할 수 있음. Event-Driven Asynchronous Non-Blocking
  • 3. NGINX Use Case 1 외부에서 들어오는 Request들에 대해서 Gateway의 역할을 해준다. 외부와의 통신은 https로 서버 내부에서는 http로 통신 하는 등 SSL적용도 가능하다.
  • 4. NGINX Use Case 2 API Gateway의 역할로 각각 path에 맞는 서버로 Redirection 시켜준다. MSA 구조에서 쓰이는 형태이다.
  • 5. NGINX Use Case 3 Reverse Proxy로 작동을 해 각 서버에 Load Balancing을 해주는 역할을 한다.
  • 7. High Level Architecture View Master-Worker Model Module System
  • 8. Master ­ Worker Model Master Process Worker Process1 Worker Process2 Worker Process2 Master Process 권한이 필요한 작업들을 담당한다. 서버와 관련된 설정들을 읽고 port를 binding한다. 또한 CPU갯수 만큼 Worker Process를 생성하고 Resource들을 관리해준다. Worker Process 실제 Connection과 관련된 일들을 모두 처리한다. 내부적으로는 단일 쓰레드로 동작 하지만 많은 수의 Connection을 비동기로 처리하는 event-driven run-loop가 동작한다
  • 9. Compare to Apache Apache 방식은 Connection 한 개당 프로세스 혹은 쓰레드를 한 개씩 만들어줘야한다. 이런 방식을 1000개의 Connection을 10초간 처리해줘야 할 경우 쓰레드 한 개당 1Mb를 사용하게 할 경우 약 1Gb를 사용하게 된다. Modern Web 환경에서는 브라우저가 여러개의 Connection을 열고 리소스에 접근해야 하기 때문에 더 많은 Connection에 대해 버틸 수 있는 능력이 필요하다.
  • 10. Compare to Apache Apache Connection 한 개당 프로세스 혹은 쓰레드를 한 개씩 만들어줘야한다. 이런 방식을 통해 1000개의 Connection을 10초간 처리해줘야 할 경우 쓰레드 한 개당 1Mb를 사용하게 할 경우 약 1Gb를 사용하게 된다. NGINX CPU갯수에 맞춘 프로세스가 각각 싱글스레드로 여러개의 Connection을 비동기 방식으로처리 하기 때문에 Apache의 방식에 비해 Context Switching의 비용도 적고 메모리도 적게 소모하게 된다 Modern Web 환경에서는 브라우저가 여 러개의 Connection을 열고 많은 리소스에 접근하기 때문에 더 많은 Connection에 대해 버틸 수 있는 능력이 필요하다. C10K Problem Dual Core Cpu, 2Gb Ram, 1Gbps Lan 표준 장비에서 어떻게 10K connection을 처리할 것 인가
  • 12. NGINX Modules - NGINX Core - NGINX Modules - Handler - Protocol - Event Module - Filter Module System을 이용하기 때문에 다양한 기능들을 Core의 변경없이 추가 할 수 있다. Ex. Protocol 구현 Link Module System
  • 13. NGINX Module Working Core은 TCP Connection과 같은 매우 밑단의 작업을 해준다. Handler와 Core 사이에는 functional module이 Protocol (HTTP)와 같은 Protocol을 구현 해 주고 Handler는 여러개의 Filter들을 통해 Header, Body를 처리하고 Response를 보내준다. 이때 Filter는 Pipe-Line 구조로 Unix Pipe와 같은 방식으로 도착한다. Filter Ex. Encryption, Compression
  • 14. NGINX 기존의 서버 구조와 다른 형태의 Event-driven 형식을 통해 빠른 처리속도를 가지고 Concurrency를 극대화 해서 여러개의 Connection을 처리 할 수 있는것이 매우 인상적 이였다. 또한 Module을 통해 단지 웹서버 뿐만 아니라 동영상 스트리밍 메일 등 다양한 프로토콜 들을 처리할 수 있게 만들 수 있는 확장성 또한 좋다. NGINX는 Apache에 비해 다양한 이점을 가져서 앞으로도 점점 점유율이 더 높아질 것을 기대해 볼 수 있을 것 같다.
  • 15. • http://www.aosabook.org/en/nginx.html • https://velog.io/@jeff0720/2018-11-18-2111- %EC%9E%91%EC%84%B1%EB%90%A8-iojomvsf0n • http://www.kegel.com/c10k.html#top • https://dzone.com/articles/inside-nginx-how-we-designed • https://d2.naver.com/helloworld/192785 • https://blog.cloudflare.com/open-sourcing-our-nginx-http-2- spdy-code/ Reference