Skip to content

xogml123/HttpWebServerClone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webserv

42seoul에서 진행하는 프로젝트로, C++을 활용하여 I/O Multiplexing 기반 Http Web Server를 구현합니다.

동작

  1. nginx.conf파일과 같은 형식으로 된 설정파일을 파싱합니다.
  2. 파싱된 데이터를 기반으로 Socket을 생성하고 tcp 소켓, non-blocking으로 설정한 후 설정 포트에 bind하고 listen합니다.
  3. Client Socket에서 connect할 때 accept함수가 return 하면서 클라이언트에게 대응 되는 Socket이 생성됩니다.
  4. 2, 3의 과정에서 생성되는 소켓들을 실제로는 I/O Multiplexing System call인 kqueue를 활용하여 이벤트를 확인합니다. kqueue를 사용한 이유는 여러 Socket의 File Descriptor Event에 대해서 변경을 감지하기 위해서 이며 Select 방식보다 효율적이기 때문입니다. Select는 매번 Event 구조를 재생성 하지만 kqueue는 자체적인 큐를 보유하고 재사용합니다. https://stackoverflow.com/questions/17355593/why-is-epoll-faster-than-select
  5. Socket에서 Read event가 발생했다면 요청이 온 경우이고 Write event가 발생한다면 Response를 보내야하는 상황입니다.
  6. Http 명세에 맞게 요청을 파싱하고 처리하여 적절한 응답코드와 함께 응답합니다.

실행

실행 명령어

make re && ./webserv config_files/default.conf

브라우저 다음 url 입력

localhost:8081/

성능 테스트

siege -b 127.0.0.1:8081

성능 테스트 트러블 슈팅

소켓 close를 하지 않을 시 생기는 문제

Team

sorikikikim / Hyeon2Nam / xogml123

Subject

정리한 개념

  1. Blocking, Non-Blocking, Synchronous, Asynchronous의 개념
  2. 여러 웹서버 I/O의 구성 방식
  3. select vs kqueue
  4. Nginx System
  5. Blocking-Multi-thread vs Non-Blocking-Single-Thread

참고자료

Server setup

How to build a simple HTTP server

Simple server with C++

C++ Web Programming

HTTP 1.1 (standard to follow) :

HTTP/1.1 (RFC 2616)

HTTP/1.1 : Message Syntax and Routing (RFC 7230)

HTTP/1.1 : Semantics and Content (RFC 7231)

HTTP/1.1 : Conditional Requests (RFC 7232)

HTTP/1.1 : Range Requests (RFC 7233)

HTTP/1.1 : Caching (RFC 7234)

HTTP/1.1 : Authentication (RFC 7235)

Other HTTP (legacy / future) :

HTTP/1.0 (RFC 1945)

HTTP/2 (RFC 7240)

HTTP/2 : Header Compression (RFC 7241)

FTP (RFC 959)

HTTP Header Syntax

HTTP Request Methods

HTTP Status Codes

HTTP Header Break Style

Select and non-blocking

Select

Non-blocking I/O

CGI

CGI : Getting Started

CGI 1.1 Documentation

About

Nginx를 모방하여 만든 Http Webserver입니다.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published