When NGINX reverse proxy starts it creates one thread per CPU core and these worker threads do the heavy lifting. The number of worker threads is configurable but NGINX recommends one thread per CPU core to avoid context switching and cache thrashing. In older versions of NGINX, all threads accept connections by competing on the shared listener socket (by default only one process can listen on IP/port pair).
In recent versions of NGINX, this was changed to use socket sharding (through the SO_REUSEPORT socket option) which allows multiple threads to listen on the same port and the OS will load balance connections on each accept queue.
No comments:
Post a Comment