user3615856
user3615856

Reputation:

RoR:-use public images in CDN for better performance in production

I have implemented a rails application and have deployed it on azure webserver.

The issue I am getting is that some of the images present in the public folder take a long time to load hence the website performance is very low.Some of the images are as small as 20kb and still takes around 13 secs to load.

My question is that if i were to put the images present in the public directory in the CDN(Content delivery network) and then load via cache, will it give better performance or will it not affect the overall performance.

Is it also possible to put all the images in the CDN for the rails app in production.

Thanks.

Upvotes: 0

Views: 321

Answers (1)

Aaron
Aaron

Reputation: 707

Well, remember that a CDN is just another webserver. All you are doing when you use a CDN is hyperlinking to the resource on that other webserver.

<img src="http://www.quackit.com/pix/milford_sound/milford_sound_t.jpg" />

Now, will it speed up the load times of your app? Maybe. There are lots of factors effecting this, namely:

  1. Why is your app loading slow? Is it your connection? Are you on dialup? A CDN can't help that.
  2. Why is your azure server slow? Is there lots of traffic? If so, a CDN will help.
  3. Most large production applications likely use a CDN for all of their static assets, such as images, css, and javascript. (They probably own the CDN, but still, its a CDN.) So, yes, every image in your site could be stored in a CDN. (Very easy if these are all static images.) However, CDN's that do this are not usually free.
  4. Why are you choosing to use azure for a rails app? It's possible, but it would be much easier to use something like Heroku or Engineyard. You could even use a VPS service like Digital Ocean, and set up your own small army of CDN's using VPS providers around the country. (If your a cheapskate, like me.)
  5. There usally aren't that many images in a production rails app that are located in /public. Usually those images are in assets/images/... the only thing I would keep in public would be a small front end site and perhaps some 404/error pages.

Upvotes: 1

Related Questions