JamesG
JamesG

Reputation: 1601

AWS S3 + CDN Speed, significantly slower

Ok,

So I've been playing around with amazon web services as I am trying to speed up my website and save resources on my server by using AWS S3 & CloudFront.

I ran a page speed test initially, the page speed loaded in 1.89ms. I then put all assets onto an s3 bucket, made that bucket available to cloudfront and then used the cloudfront url on the page.

When I ran the page speed test again using this tool using all their server options I got these results:

Server with lowest speed of : 3.66ms

Server with highest speed of: 5.41ms

As you can see there is a great increase here in speed. Have I missed something, is it configured wrong? I thought the CDN was supposed to make the page speed load faster.

Upvotes: 1

Views: 2137

Answers (3)

E.J. Brennan
E.J. Brennan

Reputation: 46879

I've seen the same thing. I initially moved some low-traffic static sites to S3/cloudfront to improve performance, but found even a small linux ec2-instance running nginx would give better response times in my use cases.

For a high traffic, geographically dispersed set of clients S3/Cloudfront would probably outperform.

BTW: I suspect you don't mean 1.89ms, but instead 1.89 seconds, correct?

Upvotes: 1

alexjs
alexjs

Reputation: 573

Have I missed something, is it configured wrong? I thought the CDN was supposed to make the page speed load faster.

Maybe, in answer to both of those statements.

CDNs provide two things:

  • Ability to scale horizontally as request volume increases by keeping copies of objects
  • Ability to improve delivery experience for users who are 'far away' (either in network or geographic terms) from the origin, either by having content closer to the user, or having a better path to the origin

By introducing a CDN, there are (again two) things you need to keep in mind:

  • Firstly, the CDN generally holds a copy of your content. If the CDN is "cold" then there is less likely to be any acceleration, especially when the test user is close to the origin
  • Secondly, you're changing the infrastructure to add an additional 'hop' into the route. If the cache is cold, the origin isn't busy, and you're already close to it, you'll almost always see an increase in latency, not a decrease.

Whether a CDN is right for you or not depends on the type of traffic you're seeing.

If I'm a distributor based in the US with customers all over the world, even for dynamic, completely uncachable content, then using a CDN can help me improve performance for those users.

If I'm a distributor based in North Virginia with customers only in North Virginia, and I only see one request an hour, then I'm likely to have no visible performance improvement - because the cache is likely not to be kept populated, the network path isn't preferable, and I don't have to deal with scale.

Upvotes: 2

elixenide
elixenide

Reputation: 44851

Generally, yes, a CDN is faster. But 1.89ms is scorchingly fast; you probably won't beat that, certainly not under any kind of load.

Don't over-optimize here. Whatever you're doing, you have bigger fish to fry than 1.77ms in load time based on only three samples and no load testing.

Upvotes: 1

Related Questions