What Is New in NGINX 1.9
| Category | Key Changes |
|---|---|
| New Feature | Stream module TCP load balancing with SSL termination |
| New Feature | HTTP/2 protocol support |
| Core Enhancement | Socket Sharding with the reuseport parameter |
| Bug Fixes | Resolved issues in the stream module, proxy, and SSL handling |
What are the major new features in this release?
The headline feature is the introduction of the stream module for generic TCP proxy and load balancing. This allows NGINX to handle traffic beyond just HTTP, like database or mail protocol connections. You can now terminate SSL for these TCP streams directly within NGINX.
Another major addition is experimental support for the HTTP/2 protocol. This lets you serve content over the newer, more efficient protocol to compatible clients, a significant step up from SPDY.
How does socket sharding improve performance?
The new reuseport parameter for the listen directive enables socket sharding. This reduces lock contention by creating separate sockets for each worker process, which the kernel then uses for load balancing incoming connections.
In practice, this can lead to a noticeable reduction in latency and better CPU utilization under high connection loads, especially on multi-core systems. It's a simpler and more efficient alternative to using multiple listen directives on different IPs.
What changed with the stream and mail modules?
The stream module for TCP proxying and the mail module were dynamically loadable in previous versions. In 1.9, they are now built by default, though you can still compile them as dynamic modules if needed.
This change simplifies the standard build process. For most users, the core functionality for TCP and mail proxy is just there without extra steps, which is more convenient for common use cases.
Were there any important bug fixes?
Yes, several issues were resolved. A bug was fixed where the stream module might not properly handle connections if the proxy_protocol was used. Another fix addressed a problem where a backend closure could cause an alert "send() failed (111: Connection refused)" to be logged incorrectly.
SSL-related fixes were also included, such as ensuring the ssl_session_cache setting was properly shared between different listening sockets, which is crucial for performance.
FAQ
Is the TCP load balancing in the stream module production-ready?
Yes, it is designed for production use. It provides core load balancing features like round-robin, least connections, and hash-based routing for generic TCP traffic, making it suitable for balancing database or custom protocol connections.
How do I enable HTTP/2 in NGINX 1.9?
You enable it by adding the http2 parameter to your listen directive in an SSL server block: listen 443 ssl http2;. Remember, HTTP/2 requires SSL/TLS encryption for most modern browsers.
What is the reuseport parameter and should I use it?
The reuseport parameter enables socket sharding for better performance on multi-worker systems. You should use it if you are experiencing high connection rates and want to reduce lock contention between worker processes. Add it to your listen directive: listen 80 reuseport;.
Can I still compile the stream module as dynamic?
Yes. While the stream and mail modules are built by default in this version, the build configuration options (--with-stream, --with-mail) still allow you to compile them as dynamic modules using the =dynamic suffix if your deployment requires it.
Was SPDY support removed in this version?
No, SPDY support is still present in NGINX 1.9. However, the introduction of experimental HTTP/2 support is the first step toward eventually replacing SPDY, as the industry was moving in that direction.