Anaplan Connect: Wake-Up Script

Preface: Utilizing CA Certificates is the best practice for Anaplan Data Integrations. The wake-up script is best leveraged with CA Certificate authentication in the individual scripts for security purposes. If you would like to learn more about CA Certificates, click on this guideNote: Basic Authentication used for demo purposes.

Additionally, the wake-up script is not intended to be run 24x7x365, only during business workdays. The script should only be run to open the model for the first time. It is recommended that the script be run at most once per working day. It is important that the model goes to "sleep" when not in use to do garbage collection.

Imagine this scenario: You have a new Anaplan ecosystem as part of your organization. When you come in the morning to log into your Anaplan App or Model, you are met with a loading screen. This loading screen often takes 10 plus minutes. 

Solution: Create a wake-up script! With the power of Anaplan Connect, you can automate your model to “wake up” before you arrive to log in for the day. This can save you time every morning you spend waiting for your large model to open.  

Here's how: Creating a wake-up script is a simple process!

  1. In your Anaplan model, create a process under the Actions menu.
  2. Rename the process to “Wake Up Model”.
  3. Do not add any actions to the process; this will be a blank “dummy” process. (For an alternative method see the Appendix). 

It should look something like this:

dsoomar002_0-1613078124939.png

 Your Anaplan model is now ready to leverage Anaplan Connect! 

Next, you should:

  1. Download Anaplan Connect onto your local machine or server environment.
  2. Create your Wake Up Model script. 
  3. Save your script in your Anaplan Connect folder.
  4. A scheduler will be needed to run this action on a consistent basis.
Example Script: 

set Certificate="your Certificate Path"
set PrivateKey="yourprivatekeypath:"
set WorkspaceId="YourWorkspaceID"
set ModelId="YourModelID"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set ProcessName="Wake Up Model"
set Chunksize=1 
set Operation= -debug -service %ServiceUrl% -auth %AuthUrl% -process %ProcessName% -execute
set Credentials=-certificate %Certificate% -pkey %PrivateKey%
rem *** End of settings - Do not edit below this line *** 
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0     
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%
pause

Your end result should look something like this when you run the script:

dsoomar002_1-1613078124945.png

Use cases:

  • Any large Anaplan model that takes a long time to open or load the first time during the day.
  • Help your data integrations load faster by opening the model and getting it ready to receive data.

Things to consider:

  • If your model is taking a long time due to performance or long nested formulas/calculations, consider addressing those first.
  • Think of it like starting your car in the cold; it usually is a good idea to warm up your car before you go out and drive it.
  • If your car takes too long to warm up, there may be another underlying issue that needs to be looked at by a mechanic.

Appendix

An alternative method to the wake-up script method is by utilizing the "-P" operator instead of creating a blank dummy process. The "-P" method will return a list of processes available in the model upon execution. In doing so, the model will wake up. In this method, you are not required to do any additional setup in the model, there is no requirement to create a blank process. There is also no requirement to include a process in your script. Simply running the script with the "-P" operator instead of "-process" will achieve a similar result as the wake-up script, with a slightly different output.

Example Script: 

set Certificate="your Certificate Path"
set PrivateKey="yourprivatekeypath:"
set WorkspaceId="YourWorkspaceID"
set ModelId="YourModelID"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set Chunksize=1 
set Operation= -debug -service %ServiceUrl% -auth %AuthUrl% -P -execute
set Credentials=-certificate %Certificate% -pkey %PrivateKey%
rem *** End of settings - Do not edit below this line *** 
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0     
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%
pause

 

Comments

  • Oh nice to see this coming as best practise! 🙂 I can remember a time where Anaplan was not happy when customers implemented such scripts to keep a model open, even if it was just from 6am-8pm.

    It would be cool if there was a central setting in the administration where up-/down time could be managed. Will check if there is an idea posted.

  • Thanks @PhilippErkinger - yes I remember that time too (former Anaplan Support). 

     

    I think there is a value add to using this concept so long as you use it reasonably within the parameters specified above and not excessively. You might be onto something with that idea, though, I suspect from a technical development standpoint that could be quite the undertaking and there may be more to the model open/load process than the eye can see.

     

    Glad you liked this one!

  • @DaanishSoomar If you don't have a scheduler, it would be a fun spin to let Siri run it. 😉

     

    Yes, there may be technical challenges. I can remember a technical conversation about the structure of the core and why such "simple" solutions are really difficult. Nevertheless, I gave it a shot and posted it as an Idea in Idea Exchange 

     

     

  • Oh wow! Regarding Siri- amazing, that is actually an article someone has published on Community!

     

    I like the way you think @PhilippErkinger - that is pretty cool! 

     

    Let some Anaplanners dream 🙂 

  • @DaanishSoomar First time I've heard of a wake up script but it's absolutely spot-on! I've waited 10 minutes for the data hub to open. 

    About how much does the average certificate cost per year do you think?

  • @JaredDolich - It depends on the vendor, if you go through this link, there is a link in here which takes you to the Anaplan Supported vendors.

     

    https://community.anaplan.com/t5/Common-Support-Questions/Interactive-CA-Certificate-Guide/ta-p/58492

     

    Generally they are pretty nominal and only need to be renewed once a year, 2 years, or 5 years depending on which vendor and certificate you purchase (each certificate and vendor is a bit different depends on their policies). 

     

    Don't quote me on this or hold me to it, but generally I have seen anywhere from $50-200 in that ballpark, (though this isn't an official quote, and this is from my memory back when I was in Support so prices may have changed since then).

  • @DaanishSoomar  An alternative to Anaplan Connect and a scheduler could be the new CloudWorks functionality within Anaplan. 

  • Hmm interesting @Brandon.U - I have not been following the CloudWorks functionality too closely, however, it appears the CloudWorks functionality is intended for a slightly different and more niche audience as compared to the Wake Up script.

     

    It appears you would need Amazon AWS or Microsoft Azure Blob as prerequisites. Additionally the documentation states:

     

    • One of the actions included in your process must be an AWS S3 (cloud-based) import or export. (Which would perhaps would be too complicated for the simple purpose of running a script to simply wake up the model, as it would likely require me to make another action I don't want to include).
    • Your process cannot include a model-to-model import action. (As mentioned in the above script, the dummy process isn't technically a model to model import, but I would have to test this out to see if the dummy process violates this principle).

    Here's the link/pages I was referencing. 

    https://help.anaplan.com/en/56d5b31b-2526-41fc-9651-5307fe39201d-Create-a-new-process-

     

     

  • @DaanishSoomar  it seems quite crazy, but sometimes it is difficult on the customer side to find an on-premise server from which it can be launched a scheduled script.

    If an on-premise server is available, your solution indeed is the simplest way to implement it. 

     

    @Brandon.U  has a really good point: with CloudWorks this can be solved using only Anaplan Cloud tools + a user on Amazon S3. 

    On Amazon S3 can be created a  dummy file that can be imported in a dummy module ( 1cell) and you have the same effect of waking up the model. 

     

    Hope it helps

    Alex

     

  • @alexpavel CouldWorks is definitely a cool new Anaplan upgrade. Just not if the customer is on team Google or Microsoft. 😉 Yet, all of the Cloud solutions have build-in schedulers. The script could be run via this as well, Anaplan Connect doesn't require an on-premise server. Although... if the customer is that advanced, they will probably have a proper integration tool. 🙂

  • Good Article, do we know how much time it takes for the model to go inactive / sleep mode? 

  • Hi @Kudiarasu - the model is in memory for 60 minutes I believe. 

    Here is an article which discusses further https://community.anaplan.com/t5/Best-Practices/Model-Load-Save-and-Rollback/ta-p/33557

  • Hi all, 

     

    We have quite a large model that is not used intensively every day, but would be usefull to being able to open the model fast to view data/KPIs. Would it be possible to run this script every hour only during business (9-17)? Or would this also impact the carbage collection?

  • Hi,

     

    Nice article.  A couple of details:

    1. -P works great on ANY model since you do not need to create a dummy process

    2. garbage collection happens while the model is loaded.  The model does not need to be asleep.

  • @schulze I have the -P process automated across multiple models and we see no noticeable difference in performance or load times. I can confirm the models all show up under "Manage Tasks". I was really hoping this would address the lag/load time in the morning.

    Is this option still viable?

  • What -P is intended to do is wake up the model. So the first user of the day would not have to wait while the model loads into memory. So the solution would only impact the model open time for the first user. It won't make the model itself perform any better. Does that help?

  • @schulze Thanks - that helps.

  • One thing that we found is that if the model is not spun up in memory, a Python API call for automated data imports or exports will fail. Hence, the model must be kept in memory for automated data import/export processes. You can use an API call or Cloudworks to run a process to keep the model in memory. Using Cloudworks does not require a connection to S3/Blob/Big Query, you can schedule any process to run in Cloudworks. The catch is that the Process must have 1 action associated with it. We created a module with 2 line items with no lists and simply copy Line item 1 to line item 2 as our action attached to our "Wake up" process. We then just scheduled the Wake up process to run every hour 15 minutes prior to our API call for data imports and exports. Hope this helps.

  • Hello guys !

    If I create a dummy processe like you mention, and I create in cloudworks an action (linked to this process) to wake-up the model everyday at everyhours. Does it work too ?

    Thanks,

    William

  • That sounds like you're on the right track.