Nginx

Nginx is a high-performance, open-source web server and reverse proxy that excels at handling concurrent connections efficiently, making it a popular choice for...

Nginx (pronounced "engine-x")는 고성능의 오픈소스 웹 서버로, reverse proxy, load balancer, mail proxy, HTTP cache로도 사용될 수 있습니다. Nginx의 아키텍처는 event-driven 및 asynchronous 방식으로, master process와 여러 worker process를 사용합니다. master process는 worker process를 관리하며, configuration reload 및 graceful shutdown을 처리합니다. worker process는 일반적으로 CPU 코어당 하나씩 존재하며, non-blocking, I/O multiplexing 방식(예: Linuxepoll)을 사용하여 클라이언트 연결을 효율적으로 처리합니다. 이러한 설계 덕분에 Nginx는 최소한의 메모리 사용량과 CPU 사용량으로 수만 개의 동시 연결을 처리할 수 있어, 뛰어난 확장성과 성능을 제공합니다. Nginx는 static content를 직접적이고 효율적으로 제공하는 데 뛰어나지만, reverse proxy 기능 또한 강력합니다. 여러 backend server에 들어오는 트래픽을 분산시키고, 해당 서버들의 health check를 수행하며, 응답을 cache하여 부하를 줄일 수 있습니다. Nginx의 configuration language는 declarative하고 hierarchical하여, routing, security (SSL/TLS termination), caching rule, request manipulation에 대한 세밀한 제어가 가능합니다. 다른 경쟁 제품에 비해 module system이 덜 유연하고 복잡한 configuration의 경우 학습 곡선이 다소 가파르다는 단점이 있지만, 핵심 기능 자체는 직관적입니다.

        graph LR
  Center["Nginx"]:::main
  Rel_redis["redis"]:::related -.-> Center
  click Rel_redis "/terms/redis"
  Rel_reverse_proxy["reverse-proxy"]:::related -.-> Center
  click Rel_reverse_proxy "/terms/reverse-proxy"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 지식 테스트

1 / 1

🧒 5살도 이해할 수 있게 설명

Nginx는 웹사이트를 위한 아주 빠른 교통 경찰관과 같습니다. 방문자를 올바른 장소로 빠르게 보내고, 압도당하지 않으면서 한 번에 엄청나게 많은 방문자를 처리할 수 있습니다.

🤓 Expert Deep Dive

The Nginx event-driven, asynchronous architecture is key to its performance. It utilizes a small number of worker processes that continuously monitor listening sockets. Upon receiving a connection, a worker process handles it through a state machine, performing non-blocking I/O operations. This avoids the thread-per-connection overhead common in traditional servers. Its reverse proxy functionality involves accepting client requests, forwarding them to upstream servers, receiving responses, and sending them back to the client, often with features like SSL termination, HTTP compression, and request/response modification via modules (ngx_http_proxy_module, ngx_http_ssl_module). Load balancing algorithms (round-robin, least-connected, IP hash) are built-in. Caching (ngx_http_proxy_module with proxy_cache) further enhances performance by storing frequently accessed content. Architectural trade-offs involve its primarily C-based core, making deep customization complex, and its event [loop](/ko/terms/event-loop) model, which can be less efficient for CPU-bound tasks compared to threaded models. Vulnerabilities often stem from misconfigurations or exploits in specific modules.

📚 출처