Moving JAVASCRIPT and CSS to a CDN for improved global delivery

brettbrett FoxyCart Team
in Important News edited March 2010
Hello all.
As FoxyCart users continue to grow and use FoxyCart on larger sites it's obviously increasing the load on our servers. Also, due to PCI compliance requirements, we are limited in certain ways, especially in regard to cloud hosting.

So, up to this point, the foxycart_includes.js files have dynamically served up the correct version of the file based on the store version (from the host in the request). This has worked, but:
-- Every request hits our servers, in the US, so it can be slower in Australia (notably) and elsewhere.
-- Every request pushes our servers a little more towards capacity, increasing our costs (and eventually our prices).
-- When our app servers go down, this creates problems if the files are included in the <head> of your sites. While we have very solid uptime, nobody's perfect.

In order to get around these issues we're looking at using a Content Delivery Network (CDN), which basically is a way to host files all around the world. This should _radically_ improve load times for those files as well as reduce our system load, allowing us to keep our costs as low as possible for you all.

The potential downside is that CDNs are "dumb", so if you're on v060, the CDN won't know. You'll have to enter a different file path depending on your store version. While that really shouldn't be an issue, it is a change.

We plan on maintaining the current functionality for existing store versions and for the near future, but we may eventually force all foxycart_includes.js and related CSS files to use the CDN. This should be a benefit to everybody, but we wanted to bring this up with the community to get feedback. If anybody has questions or concerns please let us know so we can address them and ensure things are communicated clearly.

Thanks all!
Comments
  • I think that's a really good move. When I upgrade my store versions, I have to test it out anyway, and a small link change is not a large deal. If it makes foxycart faster, I think it's a big win (esp. for folks in other countries).
  • pixelchutespixelchutes Member
    edited April 2010
    I completely agree. To scale according to your growth, a CDN sounds like a reasonable solution--one that larger scale sites likely already leverage (or should be).

    IMO, I would much rather see responsiveness and add a little work to my development cycle for new/upgraded stores (as Chuck pointed out), than to trust that I am being served the correctly version JS/CSS. Depending on your template structure, it can be as simple as updating a single source reference to take into account the new version, which isn't much to ask at all.

    I have yet to see a client accidentally "upgrade their store" on their own, but this may also serve as a fail-safe, as well. Should a client attempt to upgrade their store, having the older JS/CSS references in place could potentially result in unwanted/erroneous behavior prompting a call to their developer to "look into it".

    Bottom line: Do whatever you need to support your growth. Your customers will be more satisfied with FC as a service, and your developers are already satisfied enough because they're getting to leverage FoxyCart ;)

    UPDATE: Brett, will the new CDN support HTTPS?
  • I'm all for it as well and think it's a great move.
  • brettbrett FoxyCart Team
    If anybody wants to test this out please whisper me. We have files set up for v060 that are ready to use.
  • brettbrett FoxyCart Team
    Update on this front:
    After a LONG time testing different CDNs, and a false start with one, it looks like we've got one that works really well. We'll keep everybody posted once we have some URLs to use. Response times I'm seeing in Los Angeles for the foxycart.js file are between 12-20ms, which is pretty awesome (compared to ~82ms on our primary app server from my location). Tests from Russia and Australia seem to be improving by about 100ms. Obviously, your mileage will vary depending on location, but it looks to be an improvement, and will allow us to grow with one less thing to worry about.
  • Sounds exciting brett. As opportunities arise I'll be in touch regarding testing. Good on ya for being pro-active!
  • brettbrett FoxyCart Team
    Update, since we might as well: The code's been committed to our dev branch but needs some reviewing before we push it out. Since it's purely an additive type of thing we do currently plan on adding it to v060, but depending on when we're able to get to things that might change. But we'll update on this thread once it does go live.
  • brettbrett FoxyCart Team
    Ok, we just turned this on on our production environment. If you'd like to give this a go, this is how it works:
    http://wiki.foxycart.com/docs/upgrading/0.6.0#cdn_content_delivery_network

    Please try it out and let us know if you have any issues with anything. The CDN in 060 is really more of a test just to make sure it's working well for us and for you, so if you see anything strange just let us know.
  • oskayoskay Member
    Previously, all of these includes were https. Now, they're all http. What are the implications of this change, if any?
  • Doesn't look like HTTPS support is an option? (cert warnings over SSL...)
  • brettbrett FoxyCart Team
    Yeah, way back when... oh, great, not "way back when", but right now...

    So anyway, the "sample code" in the admin has https URLs for all the include files. In probably 99% of use cases, that's doing nothing but adding more overhead to the requests and slowing things down. I'd thought that we changed that but I was wrong. At least, we didn't change it in the admin.

    So: What are the implications?
    If you need to load those files from a page being served as https, you'll have to use the old URLs. That's basically it.

    We do plan on extending the CDN to serve more assets, including cached images on the cart and checkout, so we will likely eventually have the CDN support SSL, but that's a little bit off at this point.
  • oskayoskay Member
    So... Assuming that I'm deploying FoxyCart on a regular CMS w/o SSL, there shouldn't be any ill effect of switching to the CDN at this point. Got it.

    It seems to me that it would be a good idea to add two images to the CDN at this point (since they're called from the /themes/standard/theme.foxybox.css file, and the extra requests are likely taxing your servers at least as much as the css):

    https://www.foxycart.com/themes/standard/images/cart-close-x.png
    https://www.foxycart.com/themes/standard/images/cart-continue-shopping.png
  • brettbrett FoxyCart Team
    Yeah, we'll definitely be adding those. Why it's like that is kind of related to way way back when, but the www site is on an entirely different server than the admin and app services, and that server (the www one) is fine. But yes, those will be moving in our next release.

    I love that so many of our users are so on the ball with these things. It makes our lives a lot easier.
  • Ah ok. just tested the new links running from Australia. And the load time more than halfed!! So good.

    And I'm running it using EE with Foxee mod.

    Thanks Foxy.
  • brettbrett FoxyCart Team
    Glad to hear it!
  • oskayoskay Member
    Maybe you need a "flag this post" feature?
  • brettbrett FoxyCart Team
    @oskay, yeah, looks like Vanilla is getting hit by bot spam. We're halfway through a move to Vanilla2 (which is actually quite nice), but until then I think we'll just deal with it manually unless it gets too crazy.
  • frontierfrontier Member
    edited May 2010
    Nice! I didn't know about this, will give it a shot asap as it is a little uncomfortably slow here in Australia.

    I would also add that it doesn't concern me to link to a specific version's resources on the site.. but if you guys could update the files on the CDN on a per store basis, then that would be even better and the path then doesn't need to change on the website again.. requiring just a change to use the CDN (existing sites) but after that it is fixed.

    Edit: Oh I should RTFM first.. looks like that's what you have done. :-D
  • brettbrett FoxyCart Team
    Edit: Oh I should RTFM first.. looks like that's what you have done. :-D
    Haha, yeah, I'm actually pretty happy with how we were able to make the CDN behave. ... REALLY happy, actually. Our next release should see more of the files (images and such) moved to the CDN as well. Let us know how it works out for you in Australia. We're hearing that it at least halves the response times.
Sign In or Register to comment.