Available for new projectsCairo · London · Serving the Gulf, Egypt and Europe

DDoS Attacks Explained: How They Work and Effective Ways to Protect Your Website

How to Protect Your Website From DDoS Attacks

A distributed denial-of-service (DDoS) attack tries to make a website unavailable by overwhelming it with traffic from many sources at once. For an online store or booking site, even an hour offline means lost sales and frustrated customers. Understanding how these attacks work makes it much easier to prepare.

Key takeaways

  • DDoS attacks flood a site or server until real visitors can't get through.
  • Most small and mid-size sites are best protected by a CDN with DDoS mitigation in front of the server.
  • Rate limiting, caching and a firewall reduce the impact of application-layer attacks.
  • Prepare a response plan with your host before an attack happens.

Types of DDoS attacks

TypeTargetExample
VolumetricNetwork bandwidthUDP floods, amplification attacks
ProtocolServer and network resourcesSYN floods
Application layer (Layer 7)The website or API itselfFloods of HTTP requests to search or login pages

Application-layer attacks are harder to spot because each request looks like a normal visit.

Warning signs

  • Sudden, unexplained traffic spikes from many IPs or countries.
  • The site becomes slow or returns errors while server resources max out.
  • Unusual requests to the same URL, such as search or login.
  • Your host notifies you about abnormal traffic.

Protection measures

  • Use a CDN with DDoS mitigation such as Cloudflare to absorb and filter traffic before it reaches your server.
  • Web application firewall: block malicious patterns and known bad bots.
  • Rate limiting: cap requests per IP to login, search and API endpoints.
  • Caching: serve as much as possible from cache so the server does less work.
  • Hide the origin IP: only allow traffic from your CDN to reach the server.
  • Scalable hosting: cloud or managed hosting that can absorb spikes.
  • Monitoring and alerts: know quickly when something unusual starts.

See what Cloudflare does for your website.

During an attack

  1. Confirm it's an attack and not a legitimate traffic spike from a campaign.
  2. Enable stricter protection modes in your CDN (for example, an "under attack" mode).
  3. Add temporary rules to block or challenge offending countries, IP ranges or patterns.
  4. Contact your hosting provider for network-level help.
  5. Keep customers informed if the outage is visible.
  6. Review logs afterwards and strengthen permanent rules.

Business continuity

Keep backups, a status page or social channel for updates, and a list of contacts at your host and CDN. For critical stores, consider uptime SLAs and multi-region hosting.

DDoS readiness checklist

  • CDN with DDoS protection in front of the website.
  • Origin server accepts traffic only from the CDN.
  • Rate limits on login, search and API endpoints.
  • Caching for as many pages as possible.
  • Monitoring and alerting configured.
  • Contact details for host and CDN support ready.
  • A status page or social channel for customer updates.

Example: protecting a store during a sales campaign

Before White Friday, an online store enabled CDN caching for product and category pages, added rate limits to search and checkout endpoints, scaled its cloud server and set alerts for traffic anomalies. When a bot flood hit search, rules challenged the traffic while real customers continued shopping.

Common mistakes to avoid

  • Exposing the origin server IP even after adding a CDN.
  • Having no contact plan with the host during an incident.
  • Leaving search and login endpoints without rate limits.
  • Blocking whole countries permanently and losing real customers.

Protecting APIs and mobile app backends

Mobile apps often call APIs directly, making them targets for floods. Use API gateways or CDN rules with rate limits per token or IP, require authentication, cache public endpoints and monitor unusual traffic patterns. Separate admin APIs from public ones.

Logging and post-incident review

After an attack, review logs to identify patterns (paths, user agents, countries), keep the rules that worked, document response times and update your runbook. Share lessons with your host and development team.

Questions to ask your host

  1. What network-level DDoS protection is included?
  2. How do you notify customers about attacks?
  3. Can you null-route or filter traffic quickly?
  4. What are the costs if traffic spikes?

Frequently asked questions

Can a small website be targeted by DDoS?

Yes. Attacks can be cheap to launch and are sometimes used against competitors or for extortion.

Is DDoS the same as hacking?

Not exactly. DDoS aims to make a site unavailable; it doesn't necessarily involve breaking in, though attackers sometimes use it as a distraction.

Does shared hosting protect against DDoS?

Hosts provide some network protection, but a CDN with dedicated mitigation offers much stronger defence for your specific site.

How long do DDoS attacks last?

From minutes to days. Good mitigation reduces the impact so real visitors can keep using the site.

Can I tell a DDoS from a viral spike?

Real visitors browse varied pages and convert; attack traffic is repetitive, often from unusual sources and doesn't behave like customers.

Do I need paid DDoS protection?

Many small and mid-size sites are well protected by a CDN's standard plan; high-risk or high-revenue sites may need advanced paid protection and SLAs.

Sources and further reading

S
Eng. Mohamed Sakr

Founder of Sakr Web (usaker) and msaker.com. Web and mobile app developer and SEO and digital marketing specialist with 15+ years of experience building projects for clients in Egypt, the Gulf and beyond.

Need help putting this into practice?

Sakr Web builds and grows websites, stores and apps: design, speed, security, SEO and ads.

Ready to grow online?

Website, store, app, SEO or marketing: a free plan and quote within 24 hours.

Call usFast reply

Talk to us directlyDaily

+20 100 006 2434Main line
+20 110 070 0484Sales & support