Why Nginx Outperforms Apache: A Deep Dive into Select vs Epoll I/O Models
An in‑depth comparison reveals how Nginx’s epoll‑based I/O model delivers higher concurrency, better efficiency, reduced memory copying, and non‑blocking operation, while Apache’s traditional select model is limited by FD_SETSIZE, linear scanning, and greater kernel‑user space copying overhead.
Nginx and Apache differ in I/O performance because they use different I/O models.
Apache – select model
Characteristics:
Maximum concurrent connections are limited by the number of file descriptors (FD) a process can open, defined by FD_SETSIZE (default 1024/2048), which caps the concurrency.
Efficiency drops linearly because select scans the entire FD set on each call; increasing FD_SETSIZE further reduces performance.
Kernel‑user space memory copying is required to notify the user space of FD events, leading to extra copying overhead.
Can cause blocking.
Nginx – epoll model
Characteristics:
Maximum concurrent connections are limited only by the system’s maximum open files (e.g., /proc/sys/fs/file-max), typically far larger than 2048 and dependent on available memory.
Efficiency is higher because epoll monitors only active connections, independent of total connection count.
Uses shared memory to avoid kernel‑user space copying, eliminating that overhead.
Operates in non‑blocking mode.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
