> ## 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.

# What is a DDoS Attack

> Describes distributed denial of service attacks, vectors and impacts, and practical defenses such as CDNs, rate limiting, WAFs, SYN cookies, and scrubbing services.

A Distributed Denial-of-Service (DDoS) attack is an attempt to make an online service unavailable by overwhelming it with traffic from many sources. The goal is to exhaust the target’s resources — CPU, memory, network bandwidth, or connection slots — so legitimate users cannot access the service.

## Simple DoS example

Imagine you run an online store hosted on a single server that can handle 2,000 requests per second. An attacker using one machine might run a tiny program that repeatedly sends requests in an infinite loop:

```javascript theme={null}
while (true) {
  send(request);
}
```

If the attacker sends 5,000 requests per second while your server can only handle 2,000, the server becomes overloaded. Customers trying to reach the store will experience timeouts or errors — that is a Denial-of-Service (DoS) attack.

A simple mitigation for a single attacking IP might be a rate-limit or block rule such as:

```text theme={null}
If an IP sends > 20 req/s → block
```

Blocking or rate-limiting single malicious IPs is effective against straightforward DoS attacks. However, attackers often distribute traffic across many IPs to evade simple IP-based defenses.

## Why distributed attacks (DDoS) are harder

When attackers control thousands of compromised devices (botnets made of routers, cameras, PCs, etc.), they can send traffic from many geographic locations and IP addresses simultaneously. Because some of those IPs may belong to legitimate users or shared infrastructure, indiscriminate blocking is risky and often ineffective at scale.

One common DDoS technique targets the TCP handshake. The TCP three-way handshake starts with a client sending a SYN packet to the server. If an attacker sends many forged or incomplete SYN packets (a SYN flood), the server reserves resources while waiting for the handshake to finish. If those reserved slots reach the server’s limit (for example, 2,000 concurrent half-open connections), new legitimate connections are refused.

Because of the scale and diversity of sources, organizations commonly rely on specialized DDoS protection services (for example, [Cloudflare](https://www.cloudflare.com), [AWS Shield](https://aws.amazon.com/shield/), or [Akamai](https://www.akamai.com)) to absorb, filter, and distinguish malicious traffic before it reaches the origin server.

![An infographic titled "DDoS Protection" showing an online store being hit with 2,000 req/s, a red traffic bar and a rule to block IPs sending >20 req/s. Below it is a world map with red attack dots and icons representing users and a hacker.](https://mintcdn.com/kodekloud-c4ac6d9a/IK4ISE2GFis3psR1/images/DevOps-Interview-Questions-and-Answers-Scenario-Based-Prep/Networking/What-is-a-DDoS-Attack/ddos-protection-store-2000rps-block-20rps.jpg?fit=max\&auto=format\&n=IK4ISE2GFis3psR1\&q=85\&s=a7ebdff5b51933b6182c887ed1903c0c)

## Common DDoS attack vectors

| Attack Category | What it targets | Typical examples | Typical mitigations |
| - | - | - | - |
| Volumetric | Network bandwidth (floods the pipe) | UDP flood, ICMP flood, amplification attacks (NTP, DNS) | Anycast/CDN, upstream scrubbing, rate-limiting, blackholing for extreme cases |
| Protocol / State-exhaustion | Server or network device resources (connection tables, CPU) | SYN flood, TCP connection exhaustion | SYN cookies, connection limits, firewall rules, load balancers, scrubbing |
| Application-layer | Application resources (HTTP endpoints, APIs) | HTTP GET/POST floods, slowloris | WAF, application rate-limiting, CAPTCHA, behavioral analysis, autoscaling |

## Practical mitigations and best practices

* Use a CDN or DDoS protection provider to absorb and filter attack traffic before it hits your origin.
* Implement rate limiting and per-IP connection caps at the edge (but avoid overly aggressive limits that block legitimate users).
* Use SYN cookies or kernel-level TCP hardening to mitigate SYN floods.
* Deploy a Web Application Firewall (WAF) to block malicious requests at the application layer.
* Use anycast routing and geographically distributed scrubbing centers to spread and dissipate volumetric attacks.
* Monitor traffic patterns and set up automated alerts for sudden spikes or unusual geographic/source distributions.
* Have an incident response plan and a point of contact with your ISP and DDoS provider for emergency mitigation (e.g., BGP blackholing or traffic diversion to a scrubbing center).

## Quick reference — DDoS protection options

| Option | When to use |
| - | - |
| CDN / Anycast | For broad volumetric protection and reducing latency |
| DDoS scrubbing service | When you need high-capacity mitigation of large floods |
| WAF + rate limiting | To protect application endpoints from targeted layer-7 attacks |
| SYN cookies / kernel tuning | To reduce impact of TCP handshake-based attacks |
| IP reputation & ACLs | To block known bad actors, used cautiously to avoid collateral damage |

Blocking traffic by IP without careful analysis can block legitimate users (false positives). Always combine blocking with traffic analysis and prefer upstream filtering or scrubbing services for large-scale attacks.

## Further reading and resources

* [Cloudflare DDoS protection](https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/)
* [AWS Shield](https://aws.amazon.com/shield/)
* [Akamai DDoS Mitigation](https://www.akamai.com/)

Use the combination of edge protection, behavioral detection, and scalable infrastructure to reduce the risk and impact of DDoS attacks on your services.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/devops-interview-prep/module/c1eb3967-23d3-4a34-b23d-14a892f95e1d/lesson/961fb827-4aa1-4275-b2cd-9cc843feab86)


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