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
- We will use the
sas-viya CLI
to create a “Shared Account” (used here to run the compute process under hrservice’s identity). -
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
- You can copy the block of commands, right click in the Terminal, select Paste and hit enter to run the commands.
- You should see a message The shared service account credential for hrservice was created successfully..
-
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 ---
-
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 ).
-
If you are not already loggedin, Login as student/Metadata0.
-
Choose Yes when asked to opt in to all of your assumable groups.
- Notice the little spinning wheel at the top right.
-
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.
-
Now, click the hamburger icon (top left) and select Manage Environment to open SAS Environment Manager.
-
Open the Contexts page.
-
Select Compute Contexts in the dropdown menu at the top.
-
Select SAS Studio compute context.
-
Right click and select Copy.
-
It opens a dialog where you will configure your new Compute Context, first rename as SAS Studio launcher context_SHARED (instead of “_Copy”).
-
Click the little + icon to add an attribute named runServerAs and the value is hrservice.
-
Click Save.
-
Do it one more time, this time with an attribute named reuseServerProcesses and the value is true.
-
Do it once again, with an attribute named serverMinAvailable and the value is 5.
-
You should, now see your 3 attributes:
- Click Save.
Otherwhise follow the instructions below to do it from the command line (faster):
-
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
-
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" }
-
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
, andserverMinAvailable
.
List and test the reusable compute servers
-
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
-
You should see 5 lines that corresponds to the pool of available Compute servers.
-
Back to your SAS App, navigate to SAS Studio by clicking on Develop Code and Flows in the left side menu.
-
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).
-
Once ready, click the SAS Studio compute context button to display the Compute Contexts menu.
-
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.
-
You will see this warning:
-
Click Change.
-
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
-
Click Program in SAS and submit some code to see who is running it.
-
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;
-
Run the SAS program (Hit the F3 key or click the button).
-
You should see something like:
-
You can now click the profile icon on the top right and select Sign out, the hands-on is completed.
-
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
- Documentation:
- Blogs:
- hands on / HO1 Enable Progressive App
- hands on / HO2 Allow more analytics jobs to run
- hands on / HO3 Create a pool of reusable compute servers<-- you are here
- hands on / HO4 Increase Compute pod CPU limit
- hands on / HO5 Tune temporary storage locations CAS DISK CACHE
- hands on / HO6 Tune temporary storage locations SASWORK