I’ve been running a web project for a while now and recently started running into a mix of performance and security issues that I’m trying to understand better.
The site handles a decent amount of traffic — usually around ~5k visits daily, but some days it spikes to ~10–12k. Most of the traffic is mobile-heavy and involves serving relatively large files.
What I’ve noticed is that during these spikes, things become unstable in ways that don’t feel like normal scaling issues.
Some of the patterns I’m seeing:
– sudden bursts of requests hitting the same endpoints repeatedly
– inconsistent performance between users (some load instantly, others get delays or challenges)
– occasional Cloudflare verification loops for certain users
– increased load even when traffic numbers don’t seem that high
This makes me think a portion of the traffic might not be legitimate (bots, scraping, or low-level abuse), but I’m not experienced enough to confidently classify it.
What I’m struggling with is balancing:
– keeping the site responsive for real users
– protecting against automated traffic / abuse
– avoiding overly aggressive filtering that breaks UX
Right now it feels like:
– increasing protection → hurts real users
– reducing protection → increases load and instability
A few questions I’d really appreciate insight on:
– how do you reliably distinguish between real spikes vs abusive traffic patterns?
– what’s a practical way to protect download-heavy endpoints without blocking legit users?
– is Cloudflare Free generally enough for this level, or do you need more advanced filtering?
– at what point does infrastructure (VPS vs dedicated) become the bottleneck instead of configuration?
I’m trying to approach this from a systems perspective rather than just tweaking random settings, so any real-world experience would be really helpful.
Cloudflare on its free tier will do most of what you need. Especially if you go to tunnels it will reduce the attack surface considering. You can’t do a ton of custom rules on free but the standard rules mitigate 98% just fine on free.
You’ll find that the performance will be.much more steady. You may need to adjust some of the caching if your large files frequently change but otherwise should work for you.
Logs… look at the cloudflare dashboard for your site > security > security rules > click on each rule’s graph to see a log of matches that can be filtered or exported.
If your users are all from a particular region then consider challenging traffic from outside your region. Look for spikes from ASNs that are not ISPs. Although User-Agent can be spoofed it’s still often important.
For the sake of investigation you can initially just setup rules that have no effect but still allow you to log traffic that matches certain patterns, then change the action to block or challenge once you have the rule dialed in.
A proper robots.txt will prevent a significant amount of well behaved bots. I think cloudflare has an option to serve a generic robots.txt for you as well as an AI bot filter that I think is enabled by default now.
Ensure HTTP caching headers are setup on your origin server so that static content is being cached appropriately on the user’s end by browsers. I think Cloudflare defaults to overriding cache headers because origin servers not being setup properly is so common. Set these up and then set clouldflare to respect your headers.
If you have large static resources that aren’t being effectively cached by cloudflare despite proper headers then you may want to move the content to a CDN.
Yes. Although you’re limited to five custom security rules each rule can be quite complex so in practice a single rule can effectively be an entire collection of rules in one.
When you need to serve more dynamic content than your infrastructure can handle. If your origin server is just busy serving static resources or bots then work on your configuration.
This is super helpful honestly, especially the part about starting with logging-only rules first instead of immediately blocking things.
I think part of my problem is I’ve been reacting blindly whenever the site slows down instead of actually understanding what kind of traffic is hitting it.
The ASN point is interesting too because I never even looked into that side of things before.
One thing I’m still confused about though:
how do you personally tell the difference between “normal popularity spikes” vs bots that are pretending to behave like real users?
Because sometimes traffic numbers look normal on the surface, but the server still starts acting weird in ways that feel off.
Ultimately you can’t tell because bots can be indistinguishable from normal users and normal users can sometimes behave like bots. What’s “normal” also varies both site to site and even on the same site “normal” tends to vary over time so you’re always aiming for a moving target.
Some bot traffic will always get through and this isn’t always even a bad thing. It’s essential for example that search engine bots are not blocked if you want your site indexed.
Everything isn’t about bots either. Ensuring that browser and proxy caching are both working properly for normal users can go a long way towards relieving the origin server from having to handle a considerable volume of requests.