Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris 9 posts 90 karma points
    Jun 10, 2022 @ 11:13
    Chris
    0

    Umbraco 9 + Azure Redis Distributed Cache for autoscaling

    Hey,

    I'm looking at moving hosting to Azure and I'm just testing out the performance (which has been excellent so far).

    The docs Session State & Distributed Cache state that Umbraco needs a distributed cache as it uses TempData.

    I've set up Redis as a proof of concept but the escalation of the costs as the tiers go up is a little concerning. I can't find any information about how much TempData is used and what for making it difficult to pick a size.

    Does anyone have any guide on what service tier would be required in a production environment?

    Are there better options for the distributed cache?

    Cheers C

  • Chris Norwood 131 posts 642 karma points
    Nov 10, 2022 @ 16:03
    Chris Norwood
    0

    We're just looking at this too (we've just gone live with a load-balanced Azure Web Apps site that we've migrated to v10 from v8) and it looks like you can use SQL Server Distributed cache fairly easily (we're not using auto-scale - we load balance using Application Gateway - so I'm not sure if the below applies, but I'm going to ask support since we're a Gold Partner :)):

    https://our.umbraco.com/documentation/fundamentals/setup/server-setup/Load-Balancing/#session-state-and-distributed-cache

    https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-6.0#distributed-sql-server-cache

  • Chris Norwood 131 posts 642 karma points
    Nov 12, 2022 @ 08:27
    Chris Norwood
    1

    Does anybody know when Umbraco actually writes to the distributed cache?

    As per Chris' question above, what would be the level of Redis cache required for a production environment?

    The site we are looking at is extremely large (~15k content items, ~100k media items), but since there's no information about what is written to the cache it's not at all clear what sort of level is required, and they become prohibitively expensive at higher tiers.

    I've set up a SQL Server Distributed cache for our test server using the documentation here: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-6.0, but I'm seeing nothing written to it (1 back office, 1 front end) - does anybody know of a way to test this reliably? Do I somehow need to tell Umbraco that a distributed cache exists? I can see from the source code that both .AddWebsite() and .AddBackoffice call .AddDistributedCache(), but this seems to be just the instruction cache that Umbraco uses to ensure publishing from the back office to the front-end works.

    Thanks in advance! :)

  • Nijaz Hameed 38 posts 173 karma points
    Jan 19, 2024 @ 15:32
    Nijaz Hameed
    0

    Hi Chris,

    Are you able to find a solution for this?

  • Chris Norwood 131 posts 642 karma points
    Jan 19, 2024 @ 17:52
    Chris Norwood
    0

    We ended up using a basic SQL Server Distributed cache - it was fairly cost effective and seemed to work well for our purposes. I never really found out when Umbraco writes to the cache though, I guess we'd have to dig through the source code to figure it out!

  • Nijaz Hameed 38 posts 173 karma points
    Jan 19, 2024 @ 17:58
    Nijaz Hameed
    0

    Great, did you tried the exact same configuration as referred on the microsoft documentation https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-6.0#distributed-sql-server-cache

    I tried the same but couldn’t see anything logging on my table, do I need to consider anything else?

  • Chris Norwood 131 posts 642 karma points
    Jan 19, 2024 @ 18:07
    Chris Norwood
    0

    We did - our config looked like this, with the cache settings coming from the appSettings.json file so we could set them per environment:

                    services.AddDistributedSqlServerCache(options =>
                {
                    SqlCacheSettings sqlCacheConfig = new();
                    _config.GetSection("SqlCacheSettings").Bind(sqlCacheConfig);
    
                    if (!string.IsNullOrEmpty(sqlCacheConfig?.SchemaName) && !string.IsNullOrEmpty(sqlCacheConfig?.TableName))
                    {
                        options.SchemaName = sqlCacheConfig.SchemaName;
                        options.TableName = sqlCacheConfig.TableName;
                        options.ConnectionString = _config.GetConnectionString("sqlCacheDb");
                    }
                });
    

    SqlCacheSettings class:

        public class SqlCacheSettings
    {
        public string SchemaName { get; set; }
        public string TableName { get; set; }
    }
    
  • Nijaz Hameed 38 posts 173 karma points
    Jan 19, 2024 @ 18:15
    Nijaz Hameed
    0

    I am doing something similar, but not sure whats happening, maybe I must be missing something, all dependencies and middlewares are added before Umbraco middlewares and services.

  • Chris Norwood 131 posts 642 karma points
    Jan 19, 2024 @ 18:42
    Chris Norwood
    0

    I think when I checked, when running locally there was never any data written to the distributed cache db; I assume it was written to while running across multiple servers, but I no longer have access to that database so I can't check :)

Please Sign in or register to post replies

Write your reply to:

Draft