How to Mitigate a Layer 7 DDoS Attack

Layer 7, or application-layer, DDoS attacks target the applications, APIs, and services that power digital experiences. Rather than overwhelming a network with obvious traffic floods, attackers send seemingly legitimate HTTP or HTTPS requests designed to exhaust application, database, or API resources.

These attacks can be difficult to identify because they often resemble normal user behavior. A request to a login page, search function, product catalog, or API endpoint is not inherently malicious, but thousands of coordinated requests can degrade performance or bring an application offline.

For a broader overview, see What is an application layer DDoS attack? 

Why Layer 7 attacks are hard to stop

Layer 7 attacks are challenging because they operate at the same layer as legitimate application traffic.

Attackers may:

  • Use valid HTTP or HTTPS requests.

  • Distribute traffic across thousands of IP addresses.

  • Rotate user agents, headers, cookies, and URLs.

  • Target resource-intensive functions rather than bandwidth.

  • Mimic normal browsing, login, search, or API behavior.

  • Send requests slowly to avoid volume-based detection.

  • Use valid credentials or compromised devices.

  • Target different endpoints over time to evade static rules.

A relatively small number of requests can cause significant damage if each request triggers database queries, authentication workflows, API calls, search operations, or other expensive processes.

This means traditional network-level defenses and simple IP blocking may not be enough. Effective mitigation requires application context, real-time visibility, and controls that can distinguish legitimate activity from abusive behavior.

Common Layer 7 attack patterns

HTTP floods

Attackers send large volumes of GET, POST, or other HTTP requests to overwhelm web servers or application resources. More advanced floods vary request paths, headers, cookies, and client characteristics to appear more legitimate.

API floods

API endpoints are targeted with excessive requests, often against operations that trigger database queries, computations, or calls to downstream services.

Login and authentication floods

Attackers repeatedly submit login, password-reset, registration, or multifactor authentication requests. These workflows can consume significant resources because they may involve password hashing, identity-provider calls, fraud checks, and database operations.

Expensive-function attacks

Attackers target functions that require disproportionate processing, such as:

  • Search and filtering

  • Reporting and data exports

  • Product recommendations

  • Complex queries

  • File processing

  • Content generation

  • Dynamic page rendering

Cache-bypass attacks

Attackers vary query strings, headers, or URLs to prevent responses from being served from cache. This forces more requests back to the origin and increases backend load.

Low-and-slow attacks

These attacks send requests at a deliberately controlled pace. They may not create a dramatic traffic spike but can consume connections, sessions, threads, or other application resources over time.

Distributed bot attacks

Botnets distribute requests across many IP addresses and devices. This makes simple per-IP rate limits less effective and requires behavioral analysis or bot-management controls.

Choosing the right control: A decision framework

The right mitigation depends on what is being targeted, how confident you are that traffic is malicious, and how much friction legitimate users can tolerate.

Situation

Recommended control

Why

A sudden, broad traffic surge is affecting multiple properties

DDoS protection at the edge

Absorbs and mitigates attack traffic before it reaches the origin

One endpoint is receiving excessive requests

Targeted rate limiting

Controls abuse without unnecessarily affecting the entire application

Traffic appears automated but is not clearly malicious

Bot detection and behavioral analysis

Helps separate legitimate users, trusted automation, and abusive bots

Suspicious traffic is concentrated in a specific route or request pattern

WAF rule or custom edge policy

Blocks a defined attack signature or behavior

You need stronger proof that a client is a real browser or user

JavaScript or managed challenge

Adds verification to suspicious traffic

A sensitive API is being abused

API-specific rate limits, authentication controls, and schema validation

Protects expensive operations and limits malformed or excessive requests

The origin is overloaded but cached content remains available

Caching and origin protection

Serves eligible content from the edge and reduces backend requests

You are unsure whether the spike is an attack or a legitimate event

Observe, segment, and compare against baselines

Helps avoid blocking customers during launches, promotions, or breaking news

Controls should be applied progressively whenever possible. Start with the narrowest action that addresses the observed behavior, then increase enforcement if the attack continues.

Layered defense architecture

No single control can address every Layer 7 attack. A resilient architecture combines prevention, detection, mitigation, and recovery.

1. Detect at the edge

Monitor traffic before it reaches the application and origin. Track request volume, endpoint concentration, client behavior, geography, status codes, cache performance, and origin traffic.

2. Absorb and mitigate attacks away from the origin

Use distributed edge infrastructure and DDoS protection to handle malicious traffic before it consumes application servers, databases, and other backend resources.

3. Apply application-aware controls

Use WAF policies, bot detection, rate limiting, challenges, and custom rules based on the behavior of the request—not only the source IP address.

4. Protect expensive endpoints

Identify routes that trigger costly operations. Apply stricter controls to login, search, checkout, account, API, reporting, and data-export functions.

5. Cache eligible content

Cache static and cacheable dynamic content at the edge to reduce repetitive requests to the origin. Review cache keys and configurations to reduce cache-bypass opportunities.

6. Shield and harden the origin

Restrict origin access so that applications are not directly reachable from the public internet. Allow traffic only from approved edge infrastructure, require authentication where appropriate, and ensure that origin IP addresses are not exposed through DNS, certificates, error messages, or application headers.

7. Build graceful degradation

Decide which features can be limited or temporarily disabled during an attack. Preserve critical functions such as authentication, checkout, core APIs, and account access while reducing nonessential workloads.

Harden the application and origin

Layer 7 mitigation is most effective when the application is designed to limit abuse.

Before an attack, teams should:

  • Set request and connection timeouts.

  • Enforce maximum request sizes.

  • Limit pagination depth and query complexity.

  • Set quotas for expensive API operations.

  • Require authentication for sensitive functions.

  • Use short-lived tokens and replay protections.

  • Separate public, authenticated, and administrative endpoints.

  • Add application-level circuit breakers.

  • Protect databases with connection limits and query timeouts.

  • Prevent direct public access to origin servers.

  • Maintain tested failover and rollback procedures.

  • Ensure logs and monitoring systems can handle attack-related volume.

  • Document which features can be disabled during an incident.

Best practices checklist: Before the attack

Visibility

  • Establish normal traffic baselines.

  • Monitor traffic by endpoint, method, geography, client type, and ASN.

  • Track origin traffic separately from edge traffic.

  • Monitor cache-hit ratios and cache-bypass behavior.

  • Create dashboards for latency, errors, saturation, and request volume.

  • Ensure security and operations teams can access real-time logs.

Application protection

  • Identify the most expensive application and API functions.

  • Apply stricter limits to login, search, checkout, and account endpoints.

  • Enforce API quotas and query-complexity limits.

  • Set connection, request, and database timeouts.

  • Protect sensitive routes with authentication and authorization.

  • Test graceful-degradation options.

Edge and origin security

  • Deploy DDoS protection in front of applications and APIs.

  • Use a WAF to protect against malicious application requests.

  • Use bot-management capabilities where automated traffic is a concern.

  • Cache eligible content at the edge.

  • Restrict direct access to the origin.

  • Rotate exposed origin addresses or credentials when necessary.

  • Review DNS, certificates, headers, and error pages for origin leakage.

Incident readiness

  • Define who can activate emergency controls.

  • Document rate-limit and challenge policies.

  • Maintain allowlists for trusted partners and integrations.

  • Create a tested first-30-minutes runbook.

  • Establish escalation paths for security, infrastructure, application, and communications teams.

  • Run tabletop exercises using realistic Layer 7 attack scenarios.

  • Review and tune controls after traffic spikes and incidents.

How Fastly can help

When Fastly DDoS Protection is enabled, it automatically monitors traffic, detects anomalous patterns, and mitigates attacks at the edge, often within seconds and without manual tuning. It can protect applications and APIs from both network- and application-layer DDoS attacks.

Fastly provides complementary controls for detecting and mitigating Layer 7 attacks across applications, APIs, and web properties.

  • Fastly DDoS Protection helps detect and mitigate attacks at the edge, keeping malicious traffic away from application infrastructure and origins.

  • Fastly Next-Gen WAF helps identify and block malicious application and API requests, including attacks that exploit application-layer behavior.

  • Fastly Bot Management helps distinguish legitimate users, trusted automation, and abusive bots - an important capability when attacks are distributed across many clients.

  • Fastly rate limiting helps control excessive request rates on sensitive or resource-intensive endpoints.

  • Fastly CDN caching reduces repetitive requests to the origin by serving eligible content from the edge.

  • Fastly Origin Shield can provide an additional caching layer and reduce duplicate requests reaching backend infrastructure.

  • Fastly real-time visibility and logging help teams understand which endpoints are being targeted, how traffic is changing, and whether mitigation is restoring application health.

Together, these capabilities support a layered approach: detect suspicious behavior, mitigate attacks at the edge, protect expensive application functions, reduce origin exposure, and preserve availability for legitimate users. Fastly’s application-layer DDoS protection capabilities are described in Application-Layer DDoS Protection.

Sind Sie bereit, loszulegen?

Treten Sie noch heute mit uns in Kontakt