I am trying to reduce the cpu/memory load on my web server, and I am wondering if I should host my images on a CDN instead of my webserver. Does serving these images take up much CPU/memory?
-
How long is a piece of string? (The issue is that you ask if it takes up "much" CPU/memory. It takes some, but whether that's a lot depends on how many images, how big they are, how often they're being served, how powerful your server's CPU is, how much RAM it has, and so on.)– David SchwartzMar 4, 2013 at 7:20
-
Amazon EC2 Medium instance, /w 4GB ram, dual core xeon at 2.4ghz,, images aren't big, general website template type stuff.– williamsandonzMar 4, 2013 at 7:23
-
1If you are going with amazon anyway, consider using S3 (and probably CF on top) as a bulk static webserver.– rackandbonemanMar 4, 2013 at 9:48
2 Answers
CDNs mostly save you bandwidth and latency (by placing the content closer to the user). If they end up saving you significant amounts of CPU time or memory, that's usually going to mean that you aren't scaling to the number of users, or there's a sub optimal webserver config in place.
When dealing with load problems, you really have to identify the exact source of the problem and decide how to grow things from there. I understand that asking this question was part of that process for you, but a better question to pose would be something like this:
"I have X web-server+operating system, it is configured with Y clustering and is designed to perform function Z. Lately I've been running into problems with CPU and memory usage. How would I begin to identify what is generating the load?"
The more specific the scope you can make the question (and detail about your setup+its configuration), the better results you'll get. Just make sure you've reviewed the similar questions on this site first.
CDN's generally have more of an impact on your bandwidth (which is handy if it's limited), and is meant to improve the browsing experience of your users.
That being said, if you have a lot of static text-based content that you would be serving compressed, then serving those from a CDN could alleviate that burden. HTTP compression doesn't generally take a huge amount of overhead, but a CDN can handle this and caching for you.