Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Hands-On 3: Create a pool of reusable compute servers

In this hands-on, we will configure a pool of 5 reusable compute servers and see how it affects the time to make a compute server available in the SAS application. (Tip #4)

Step-by-step instructions

Create the Compute credentials for a shared Account

  1. We will use the sas-viya CLI to create a “Shared Account” (used here to run the compute process under hrservice’s identity).
  2. Run the following commands, in the Root terminal window .

    sas-viya --profile Default profile set-endpoint "https://server.demo.sas.com/"
    sas-viya auth login -u Student -p Metadata0
    sas-viya plugins install --force -repo SAS compute
    sas-viya compute credentials list
    sas-viya compute credentials create -u hrservice -p lnxsas -d "sharedaccount"
    sas-viya compute credentials list
    
  3. You can copy the block of commands, right click in the Terminal, select Paste and hit enter to run the commands.
  4. You should see a message The shared service account credential for hrservice was created successfully..
  5. and at the end of the execution, you should see this line:

    1.  hrservice - compute-password - "sharedaccount"
    

Create a new SAS Compute shared Context

Let’s create a compute context with reusable SAS Compute Servers.

--- Expand this ONLY if you want to use the SAS Environment Manager UI to do it ---
  1. If you use the SAS App, click the hamburger icon (top left) and select Develop Code and Flows (otherwise, open Google Chrome and click the SAS Studio bookmark ).

  2. If you are not already loggedin, Login as student/Metadata0.

  3. Choose Yes when asked to opt in to all of your assumable groups.

  4. Notice the little spinning wheel at the top right.
  5. It spins for a few seconds which corresponds to the time required to pull the sas-programming image on the node and start the compute session that is needed by SAS Studio.

  6. Now, click the hamburger icon (top left) and select Manage Environment to open SAS Environment Manager.

  7. Open the Contexts page.

    Context page icon

  8. Select Compute Contexts in the dropdown menu at the top.

  9. Select SAS Studio compute context.

  10. Right click and select Copy.

    Environment Manager Copy Contexts button

  11. It opens a dialog where you will configure your new Compute Context, first rename as SAS Studio launcher context_SHARED (instead of “_Copy”).

  12. Click the little + icon to add an attribute named runServerAs and the value is hrservice.

  13. Click Save.

  14. Do it one more time, this time with an attribute named reuseServerProcesses and the value is true.

  15. Do it once again, with an attribute named serverMinAvailable and the value is 5.

  16. You should, now see your 3 attributes:

  17. Click Save.

Otherwhise follow the instructions below to do it from the command line (faster):

  1. Run the command below, in the Root terminal, to create a JSON file for the new SAS Studio compute context_SHARED context:

    tee ./create_SHARED_compContext.json > /dev/null << EOF
    {
        "attributes": {
        "reuseServerProcesses": "true",
        "runServerAs": "hrservice",
        "serverMinAvailable": "5"
        },
        "description": "New compute context for SAS Studio with reusable compute servers",
        "environment": {},
        "launchContext": {
        "contextId": "8db02d8d-c31c-4ba8-9c24-894f783fb827",
        "contextName": "SAS Studio launcher context"
        },
        "launchType": "service",
        "name": "SAS Studio compute context_SHARED",
        "version": 4
    }
    EOF
    
  2. Apply the change:

    sas-viya compute contexts create -r -d @create_SHARED_compContext.json
    

    With results similar to:

    {
        "description": "New compute context for SAS Studio with reusable compute servers",
        "id": "debdeb21-ca28-48c5-ac67-3d03eda55b92",
        "launchType": "service",
        "name": "SAS Studio compute context_SHARED"
    }
    
  3. Check the configuration change:

    • Using the sas-viya CLI:
    sas-viya --output fulljson compute contexts show -n "SAS Studio compute context_SHARED" | \
    jq 'with_entries(select(.key | in({"attributes":1,
                                         "description":1,
                                         "environment":1,
                                         "launchContext":1,
                                         "launchType":1,
                                         "name":1,
                                         "version":1})))'
    

    And note the attributes for reusable compute include:

    "attributes": {
      "reuseServerProcesses": "true",
      "runServerAs": "hrservice",
      "serverMinAvailable": "5"
    }
    
    • (Optional) Using SAS Environment Manager:

    Navigate to Contexts (left-menu) > Compute contexts (View pull-down) > SAS Studio compute context_SHARED (from list) > Attributes (parameter group) > look for reuseServerProcesses, runServerAs, and serverMinAvailable.

List and test the reusable compute servers

  1. Now run the command below, in the Root terminal, to list the pods for the compute sessions started as “hrservice”.

    kubectl -n edu get pod -l launcher.sas.com/requested-by-client=sas.compute,launcher.sas.com/username=hrservice
    
  2. You should see 5 lines that corresponds to the pool of available Compute servers.

  3. Back to your SAS App, navigate to SAS Studio by clicking on Develop Code and Flows in the left side menu.

  4. At the top right of the screen, you will see the spinning wheel for a few seconds for the SAS Studio compute context (because Kubernetes needs a bit of time to start the SAS Compute server pod on the default Compute Context).

  5. Once ready, click the SAS Studio compute context button to display the Compute Contexts menu.

  6. Then select the new compute context: SAS Studio Compute Context SHARED.

    Note: if you don’t see the new “_SHARED” context, you need to sign out and login again as Student/Metadata0.

  7. You will see this warning:

  8. Click Change.

  9. As soon as you click Change, the access to the new Compute Context should be immediate. You will not see the spinning wheel because the compute session has been pre-started for you!

    Note: Each time you’ll open SAS Studio, the context will now automatically be set to “SAS Studio compute context SHARED”.

Optional: run a SAS program

  1. Click Program in SAS and submit some code to see who is running it.

  2. Copy/paste the following SAS code in SAS studio programming.

    %put NOTE: I am &_CLIENTUSERNAME;
    %put NOTE: My UID is &SYSUSERID;
    %put NOTE: My home directory is &_USERHOME;
    %put NOTE: My Compute POD IS &SYSHOSTNAME;
    
  3. Run the SAS program (Hit the F3 key or click the button).

  4. You should see something like:

  5. You can now click the profile icon on the top right and select Sign out, the hands-on is completed.

  6. Close the SAS App (or Google Chrome), check the number of compute session pods in the Terminal window (even if they are not used, there should always be 5 available sessions).

What have we learned  ?

  • It is possible to create a pool of available/reusable compute servers.

  • They need to run under the identify of a shared account, which has to be defined upfront and associated to the compute context.

  • It can significantly reduce the time to start the compute pods for interactive applications such as SAS Studio or SAS Model Studio (it can also drastically reduce the execution of pipelines that need to start several compute sessions) and improve the overall user’s experience.

References



Back to top

Copyright © SAS Institute Inc. All Rights Reserved.