Don't know how you can prevent this happening. I'm not a computer pro but, as I understand it, a DDoS attack is where the target is flooded constantly with access requests, presumably from bots, so it can't keep up and eventually overloads?
So it's not like you're trying to prevent one or two hackers getting in to to damage, it's more like the entire population of a capital city is trying to access the subway at rush hour through one entrance
Someone put me right if I'm off track please