A CDN helps prevent DDoS attacks by distributing traffic across a network of servers. This reduces the load on a single server and makes it harder for attackers to overwhelm the system with a flood of traffic.