> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Performance Introduction

> Practical NGINX performance and protection techniques including rate limiting, connection throttling, caching, gzip compression, logging, and troubleshooting for web server optimization and mitigation.

Welcome to the final module of this lesson. Congratulations on making it this far.

This module covers practical performance and protection techniques for web servers, focusing on actionable NGINX configuration and troubleshooting. Below are the objectives and a concise summary of what you'll learn and implement.

| Objective | Purpose | Example NGINX focus |
| - | - | - |
| Rate limiting | Limit request rates to mitigate abuse such as brute-force attempts and scraping | `limit_req_zone` / `limit_req` |
| Protect from DoS & brute-force | Throttle connections and apply connection controls to reduce resource exhaustion | `limit_conn` / `limit_conn_zone` |
| Improve performance with caching | Reduce backend load by configuring cache behavior and TTLs | `proxy_cache` / `proxy_cache_valid` |
| Speed up content delivery (Gzip) | Reduce response sizes to speed up transfer times and lower bandwidth | `gzip` directives via `ngx_http_gzip_module` |

![Slide titled "Objectives" with a blue gradient panel and a vertical list of four numbered goals. The goals are: rate-limiting network traffic, protecting web servers from DoS and brute-force attacks, improving application performance with caching, and speeding content delivery by compressing data (Gzip).](https://mintcdn.com/kodekloud-c4ac6d9a/ij3FNIPjp1w0Myd0/images/Nginx-for-Beginners/Performance/Performance-Introduction/objectives-rate-limit-dos-caching-gzip.jpg?fit=max\&auto=format\&n=ij3FNIPjp1w0Myd0\&q=85\&s=b24dca172e675a35f70d28d85d518e95)

Key topics we'll cover in this lesson

* Rate limiting: how to set request limits to mitigate abuse (scrapers, brute-force attempts) and to reduce some application-layer DDoS effects.
* Connection controls and throttling: protecting web servers from DoS and brute-force by limiting simultaneous connections and applying per-IP controls.
* Caching: configuring cache behavior to reduce backend load and improve response times.
* Compression (Gzip): enabling and tuning gzip compression to deliver content faster and reduce bandwidth usage.

Rate limiting and throttling help mitigate many abuse patterns, but they are not a complete defense against large volumetric DDoS attacks. For high-volume attacks you’ll need upstream network protections (cloud/ISP-level mitigation, WAFs, or DDoS scrubbing services).

Gzip compression example

We will use gzip as the compression example because the gzip `content-encoding` is widely supported by browsers and is available in NGINX via the `ngx_http_gzip_module` (most standard NGINX packages include this module). You generally do not need to install an additional utility to enable gzip in NGINX—just enable and configure the gzip directives in your NGINX configuration.

Gzip remains the most widely compatible choice across browsers. If you control client environments, consider newer formats (for example, Brotli) for better text compression ratios, but always test client compatibility and CPU trade-offs before switching in production.

Other topics covered in this lesson

* Keep-alive (persistent) connections: what they are, why they reduce latency by reusing TCP connections for multiple HTTP requests, and how to tune `keepalive_timeout`. (Persistent connections are the default for HTTP/1.1; HTTP/2 further reduces latency by multiplexing many requests over a single connection.)
* Log analysis: reading and interpreting NGINX access and error logs to identify performance issues, spikes in latency, error patterns, and possible security threats.
* Troubleshooting: common configuration pitfalls and steps to resolve them (permission issues, module availability, configuration test/reload commands).
* Monitoring with Datadog: walkthrough for installing and configuring Datadog to collect NGINX metrics, logs, and traces. The Datadog section shows installation and configuration; sending data requires your own Datadog account.

Recommended next steps

1. Review the gzip configuration directives in your `http`, `server`, or `location` blocks and enable gzip for text-based responses (`text/plain`, `text/css`, `application/javascript`, etc.).
2. Add a conservative rate limit (e.g., requests per second) and test with a client tool (curl or a load tester) before rolling to production.
3. Configure a simple proxy cache for static assets to validate cache hits and measure backend load reduction.
4. Enable and analyze NGINX access logs to find long-tail requests, repeated 4xx/5xx errors, and potential abusive patterns.

Links and references

* [NGINX gzip module documentation](https://nginx.org/en/docs/http/ngx_http_gzip_module.html)
* [Datadog](https://www.datadoghq.com/)
* [Brotli GitHub](https://github.com/google/brotli)

This lesson focuses on practical configuration and troubleshooting steps you can apply to real servers. Let's get started.

> **[Watch Video](https://learn.kodekloud.com/user/courses/nginx-for-beginners/module/4a5db5c4-df5f-4291-84f0-013d1c4ce235/lesson/d552c1f3-a18f-44ee-9570-8cb15a7b5ef6)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.