# denji/nginx-tuning

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/denji-nginx-tuning).**

2,692 stars · 403 forks · mit

## Links

- GitHub: https://github.com/denji/nginx-tuning
- Homepage: https://git.io/vSvsq
- awesome-repositories: https://awesome-repositories.com/repository/denji-nginx-tuning.md

## Topics

`best-practices` `details` `nginx` `security` `tuning`

## Description

This project is a collection of technical guides and configuration patterns for tuning Nginx server performance, managing traffic flow, and implementing protocol-aware routing. It provides a curated set of parameters and best practices to optimize request handling, memory usage, and CPU efficiency.

The project includes a method for sharing a single port between different protocols by inspecting initial packets to route traffic to the correct backend. It also provides configuration patterns for implementing request rate limiting and range request restrictions to mitigate denial of service attacks.

The technical scope covers system-level performance enhancements such as socket sharding and file descriptor scaling. It also addresses resource optimization through Gzip payload compression, multi-threaded file delivery via thread pools, and the throttling of connections per IP address.

## Tags

### DevOps & Infrastructure

- [Nginx Performance Tuning](https://awesome-repositories.com/f/devops-infrastructure/nginx-performance-tuning.md) — Provides a comprehensive set of optimized Nginx configuration parameters for high-performance traffic handling.
- [Web Server Performance Tunings](https://awesome-repositories.com/f/devops-infrastructure/web-server-performance-tunings.md) — Provides a curated set of configuration parameters to optimize Nginx request handling, memory usage, and CPU efficiency. ([source](https://cdn.jsdelivr.net/gh/denji/nginx-tuning@master/README.md))
- [Web Server Tuning](https://awesome-repositories.com/f/devops-infrastructure/web-server-tuning.md) — Optimizes web server resource usage and stability through efficient file delivery and compression.
- [Range Request Restrictions](https://awesome-repositories.com/f/devops-infrastructure/caching-layers/range-aware-caching/http-range-request-handling/range-request-restrictions.md) — Restricts the number of byte-range requests permitted per response to maintain stability during traffic spikes. ([source](https://git.io/vSvsq))

### Networking & Communication

- [Advanced Traffic Routing](https://awesome-repositories.com/f/networking-communication/advanced-traffic-routing.md) — Provides advanced routing logic based on protocol inspection to allow multiple services to share a single port.
- [Socket Sharding](https://awesome-repositories.com/f/networking-communication/socket-networking/socket-sharding.md) — Implements socket sharding and reuseport settings to reduce latency and distribute network load across CPU cores. ([source](https://git.io/vSvsq))
- [Socket Sharding](https://awesome-repositories.com/f/networking-communication/socket-sharding.md) — Optimizes network traffic distribution across CPU cores using socket sharding and reuseport settings.
- [Preread Routing](https://awesome-repositories.com/f/networking-communication/traffic-protocol-inspection/preread-routing.md) — Shares a single port between different protocols by inspecting initial packets to route traffic to the correct backend. ([source](https://cdn.jsdelivr.net/gh/denji/nginx-tuning@master/README.md))
- [SSL Protocol Routers](https://awesome-repositories.com/f/networking-communication/traffic-routers/ssl-protocol-routers.md) — Enables a single port to be shared between different protocols by inspecting initial handshake packets.
- [Protocol-Based Routing Rules](https://awesome-repositories.com/f/networking-communication/traffic-routing/protocol-based-routing-rules.md) — Implements routing rules that direct traffic to different backends based on the inspected connection protocol.
- [Request Limits](https://awesome-repositories.com/f/networking-communication/byte-range-requesting/http-range-request-handlers/request-limits.md) — Restricts the number of byte-range requests per response to mitigate resource exhaustion.
- [Network Data Compression](https://awesome-repositories.com/f/networking-communication/network-data-compression.md) — Implements Gzip compression for network payloads to optimize bandwidth and reduce transmission size.
- [Multi-threaded File Delivery](https://awesome-repositories.com/f/networking-communication/packet-engines/packet-processing-frameworks/multi-threaded-packet-processing/multi-threaded-file-delivery.md) — Implements multi-threaded file sending via thread pools to prevent worker process seizure. ([source](https://git.io/vSvsq))

### Operating Systems & Systems Programming

- [File Descriptor Limits](https://awesome-repositories.com/f/operating-systems-systems-programming/file-descriptor-limits.md) — Provides guides for increasing OS file handle limits to prevent crashes under high concurrency.

### Security & Cryptography

- [Network Attack Mitigations](https://awesome-repositories.com/f/security-cryptography/governance-policy-frameworks/compliance-governance/security-and-compliance/security-and-threat-mitigations/network-attack-mitigations.md) — Provides specific configurations and request limiting to neutralize network-level attacks and traffic spikes. ([source](https://git.io/vSvsq))
- [DDoS Protections](https://awesome-repositories.com/f/security-cryptography/network-infrastructure-security/web-network-security/network-security/ddos-protections.md) — Implements protections against resource abuse and traffic floods through request rate limiting and connection caps.
- [Request Rate Limiting](https://awesome-repositories.com/f/security-cryptography/request-rate-limiting.md) — Implements mechanisms to throttle the volume of incoming network requests per IP address to prevent system abuse. ([source](https://cdn.jsdelivr.net/gh/denji/nginx-tuning@master/README.md))

### Software Engineering & Architecture

- [Performance Tuning Guides](https://awesome-repositories.com/f/software-engineering-architecture/performance-tuning-guides.md) — Serves as an educational guide for optimizing Nginx request handling, memory, and CPU efficiency.
- [IP-Based Rate Limiting](https://awesome-repositories.com/f/software-engineering-architecture/traffic-management/request-rate-limiting/ip-based-rate-limiting.md) — Implements server-side throttling of concurrent connections and requests based on the client IP address.
- [Server-Side](https://awesome-repositories.com/f/software-engineering-architecture/traffic-management/server-side.md) — Provides configuration patterns for request rate limiting and range request restrictions to mitigate DDoS attacks.

### System Administration & Monitoring

- [High-Concurrency Server Tuning](https://awesome-repositories.com/f/system-administration-monitoring/high-concurrency-server-tuning.md) — Adjusts file handle and socket settings to maintain stability and low latency under high traffic volumes.

### Web Development

- [Performance Optimizers](https://awesome-repositories.com/f/web-development/web-infrastructure-deployment/web-infrastructure-servers/web-server-hosting/nginx-hosting-configurations/performance-optimizers.md) — Offers technical adjustments to increase file handle limits and optimize socket handling for Nginx.
- [Response Compression](https://awesome-repositories.com/f/web-development/response-compression.md) — Reduces transmitted data size using Gzip compression to decrease bandwidth usage and speed up page loads. ([source](https://cdn.jsdelivr.net/gh/denji/nginx-tuning@master/README.md))

### Artificial Intelligence & ML

- [File Delivery Offloading](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-deployment-and-serving/local-and-on-device-inference/local-model-inference-servers/remote-inference-offloaders/task-offloaders/thread-pooled/file-delivery-offloading.md) — Offloads synchronous file operations to thread pools to maintain the responsiveness of the main event loop.
