Announcement

Collapse
No announcement yet.

Redis and CDNs? Best Practice

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Redis and CDNs? Best Practice

    How does using a CDN impact the use of Redis. Can they be effectively used together? Or does one negate the use of the other.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    #2
    They perform different tasks and can be used together. Redis is only used for Miva Merchant to store selected content it would have otherwise generated as part of a page request, and many times this content cannot be cached by a CDN; so those dynamic pages can receive a large performance increase in generation time. The CDN will generally cache static content, CSS and Javascript resources served by Miva Merchant, etc. so the request doesn't need to come to the web server to begin with.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Originally posted by ILoveHostasaurus View Post
      They perform different tasks and can be used together. Redis is only used for Miva Merchant to store selected content it would have otherwise generated as part of a page request, and many times this content cannot be cached by a CDN; so those dynamic pages can receive a large performance increase in generation time. The CDN will generally cache static content, CSS and Javascript resources served by Miva Merchant, etc. so the request doesn't need to come to the web server to begin with.
      Awesome, thanks.
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment


        #4
        I can see the value of Redis in-memory storage for Miva and module developers. Are there any use cases for merchants?

        Does Miva see storing static html pages on a CDN and making ASYNC calls to Redis for dynamic entities?
        http://www.alphabetsigns.com/

        Comment


          #5
          The redis-based cache's sole purpose is to benefit merchants by way of dramatically faster page load times of any content that it can keep in cache, which is an ever-increasing amount as new code is added to make use of it in various ways.

          Third party modules actually make the decision on when and how to enable redis much more complicated, as any given store operator who has added third party modules must ensure the modules are compatible with page content caching before enabling it on pages where those modules play a role in the output. For example, if a module does an anti-fraud IP address check and alters the page content to take away the add to basket button, such a store's product pages would no longer be safe to cache as a visit from a risky IP could cause the no-basket-button version of the page to be cached and served to the next shopper.

          There are no current plans at Miva to generate actual static page copies of what would have been generated content. Many of Merchant's features could have issues with that, or prevent their use, such as template branches, or the generation of javascript subresource integrity hashes that must go in the page source but which would then have no protection from malicious alteration if they're just placed into static files which could be manipulated outside of Merchant.
          David Hubbard
          CIO
          Miva
          [email protected]
          http://www.miva.com

          Comment


            #6
            The reason I ask is because I have seen all the redis functions on mivascript.com and wondered how they would be very useful on page templates. So please help me understand Redis better.

            Redis is in-memory storage with caching that resides on the servers CPU. This makes faster page load times because it reduces the roundtrip time to a DB storage for each page request. Redis can cache session based data, parts of a page template, or a page template that can read other Redis based schema. When the Redis cache TTL expires then it makes another R/W to the DB if required.

            So in the anti-fraud example above the developer would only consider caching in redis the parts of the page that are static and would then import from redis the session-based basket button content.





            http://www.alphabetsigns.com/

            Comment


              #7
              The new MivaScript functions are for use in compiled MivaScript files, not page templates. The primary reason for their addition was for our core software to use them, but a third party module could potentially use them too if it detected redis as present and derived some benefit from its use independent of Merchant's caching of page output. For example, if a third party module currently performs some repetitive and undesirably long running database task that typically results in the same data being retrieved, it could use those functions to store that data in redis instead. The caveat is of course that redis is non-persistent, so it needs proper error handling to determine if the data it wants is there, and if not, place it there, each time it needs to use it.

              It is more than just reducing DB queries; it is caching portions of finalized page output, so beyond just reducing data retrieval, it's also eliminating CPU-bound work that Merchant would have put into manipulating the raw data into the final output. It can take even a highly optimized store's product pages from what is often .3-.4 second down to <.1 second. It does not cache page content once a shopper session has been established, i.e. logging in, or adding something to basket, as there's too great a risk that something on the page may be shopper-specific at that point. The expiration time can be set, generally five minutes is good (300 sec), but even dramatically longer caching is fine on stores that don't alter content frequently, or where there's a willingness to allow changes made in the admin to propagate out slowly.

              David Hubbard
              CIO
              Miva
              [email protected]
              http://www.miva.com

              Comment


                #8
                In the anti-fraud example above you said Redis decisions are complicated by third-party modules.

                I have a page template that includes product reviews read from the DB at runtime based upon product:id.

                Is there a way to specifically notify MIVA which page templates not to redis-cache?

                Thank you.
                http://www.alphabetsigns.com/

                Comment


                  #9
                  The functionality allows you to run it in either inclusion mode or exclusion mode, where you can create a list of page template codes to never cache, or a list of what would only ever be eligible for caching. For example, you could set it to inclusion mode and only SFNT,CTGY if you wanted two of the three most heavy hitters cached but not PROD due to the reviews issue. Alternatively, perhaps you could bring the reviews in via iframe for a different page template code, to allow that part to load dynamically under a second request from the browser, and then it may be eligible to be cached independently of the page that called it in, so while the overall combo can't be cached, the two independent parts can.
                  David Hubbard
                  CIO
                  Miva
                  [email protected]
                  http://www.miva.com

                  Comment


                    #10
                    Thank you.
                    http://www.alphabetsigns.com/

                    Comment


                      #11
                      Can Redis be used to cache just part of a page, such as a list of Featured Products? I see that David mentioned iframes; is that the way to do it?

                      Thanks --
                      Kent Multer
                      Magic Metal Productions
                      http://TheMagicM.com
                      * Web developer/designer
                      * E-commerce and Miva
                      * Author, The Official Miva Web Scripting Book -- available on-line:
                      http://www.amazon.com/exec/obidos/IS...icmetalproducA

                      Comment


                        #12
                        I noticed that the UI > Global Settings do not have the option to manage cache for templates such as global header or global footer. But either of those templates can be saved as a page template where they can be saved to Redis cache. So I am hoping to learn more about saving page partials to Redis.
                        http://www.alphabetsigns.com/

                        Comment


                          #13
                          Kent Multer and alphabet if its not possible with Redis I know the Transients module by Tess can do this when coupled with the content sections in the theme components. We use it to cache a lot of stuff on our CTGY page. Subcategory lists, canonical/pagination links, related categories, schema item list, product count and even our global navigation set.

                          Soon we will be adding redis as well though, so we will only use transients where partial caching is necessary.
                          Nick Harkins
                          www.loveisarose.com
                          *Web Developer
                          *Miva
                          *Google Analytics, Search Console, Tag Manager, Merchant Center, Ads

                          Comment


                            #14
                            Thank you. I looked at the Transients documentation and got a few ideas.

                            However, I still do not understand how Redis works. Does Redis cache the page template in memory or does it cache the results of the page template in memory?

                            The Miva Docs cautions against caching any page template that may display contingent content. But how is that any different than a PROD page template.

                            For example, does Redis cache the PROD template (components) or each product-uri like an edge server would?
                            http://www.alphabetsigns.com/

                            Comment

                            Working...
                            X