Let's consider a scenario like below:
A small web blog build based on LAMP stack and deployed on a shared hosting. Suddenly it becomes popular in one day and it gets million hits per day. Since the developer have not consider high traffic, it caused server downtime and crashes.
What would be a quick fix for such a scenario?
BTW I know on cloud Servers I may be able to add more RAM or CPU to avoid that like in Amazon EC2.
Don't get into this situation in the first place.
Shared hosting providers are notorious for having difficulty handling large traffic spikes to a single customer, and since you don't run the machine, there's not much you can do to optimize things.
Probably the best you can do on shared hosting is application-level caching. For instance, if you use WordPress, install W3 Total Cache in disk caching mode.
If you realistically expect large amounts of traffic on an ongoing basis, you would do best to move to servers you control as soon as possible. The point at which I would start planning to get off shared hosting is about 5,000 unique visitors/day. By the time you get to 10,000 you should be long gone. (This is just a rule of thumb; your provider may be better or worse.)
You've answered your own question. Web servers typically hit RAM limits before CPU. Once you start exhausting RAM, the O/S will start swapping, causing a downward spiral of disk thrashing, with one outcome. If your host is running on Linux, there's a chance the kernel will start killing processes in order to preserve itself. Apache could be one of the first to go.
So, monitor RAM utilisation, and speak nicely to your cloud provider BEFORE you hit problems.
Ordered by, "How quickly can I make this change?"
For CDN take a look at Akamai, Amazon CloudFront, or cloudFlare. Also make sure youre not going to pay exorbitant traffic fees.