U4-7682 - Add option to DatabaseServerMessengerOptions to force a Cold Boot if there are too many instructions

Created by Shannon Deminick 08 Jan 2016, 13:21:50 Updated by Stephan 28 Jan 2016, 13:33:34

Tags: Needs Docs

We should allow an option on startup for the DatabaseServerMessengerOptions to force the server to Cold Boot if there are more than a specified threshold number of instructions.

For example, if a server has to process 10,000 instructions it might be faster/better for it to cold boot instead of processing each one. This needs to be made optional on startup.

In order to achieve this, we'd also need to be able to easily replace the db server messenger during startup which means being able to access it's own options so we can duplicate them - this would mean being able to resolve the messenger before resolution is frozen, or create a different way to resolve something before resolution is frozen.

Comments

Shannon Deminick 28 Jan 2016, 11:17:58

I've put this in place now and made it much easier to control the callbacks for Cold Booting. Here's an example that you could use during ApplicationStarting. This logic mimics the exact same thing that is the default behavior in Umbraco. I've also set the default MaxProcessingInstructionCount to 1000 which can be adjusted by specifying a custom value on startup in the DatabaseServerMessengerOptions.

ServerMessengerResolver.Current.SetServerMessenger(new BatchedDatabaseServerMessenger(
                ApplicationContext.Current,
                true,
                //Default options for web including the required callbacks to build caches
                new DatabaseServerMessengerOptions
                {
                    MaxProcessingInstructionCount = 1000,
                    //These callbacks will be executed if the server has not been synced
                    // (i.e. it is a new server or the lastsynced.txt file has been removed)
                    InitializingCallbacks = new Action[]
                    {
                        //rebuild the xml cache file if the server is not synced
                        () => global::umbraco.content.Instance.RefreshContentFromDatabase(),
                        //rebuild indexes if the server is not synced
                        // NOTE: This will rebuild ALL indexes including the members, if developers want to target specific 
                        // indexes then they can adjust this logic themselves.                        
                        () =>
                        {
                            //If the developer has explicitly opted out of rebuilding indexes on startup then we 
                            // should adhere to that and not do it, this means that if they are load balancing things will be
                            // out of sync if they are auto-scaling but there's not much we can do about that.
                            if (ExamineSettings.Instance.RebuildOnAppStart == false) return;

                            foreach (var indexer in WebBootManager.GetIndexesForColdBoot())
                            {
                                indexer.RebuildIndex();
                            }
                        }
                    }
                }));


Shannon Deminick 28 Jan 2016, 11:18:50

PR for review: https://github.com/umbraco/Umbraco-CMS/pull/1071


Stephan 28 Jan 2016, 13:33:29

Merged. And I even deleted the branch.


Priority: Normal

Type: Task

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.3.6

Sprint: Sprint 7

Story Points:

Cycle: