BookmarkSubscribeRSS Feed
Wienik_Kruithof
Fluorite | Level 6

Hi All,

 

We have created a new reusable context server with a shared account linked to it for our web application running within the job execution server. This should be good for the performance of our application. 

 

I have been looking at the session id's within the log during the usage of our created web form. My assumption is that the session ID should be the same for a period of time. 

 

Action 1:

SYS_COMPUTE_SESSION_ID=5c8e0be6-631a-42ba-928b-5154c77c171e-ses0008

Action 2:

SYS_COMPUTE_SESSION_ID=5c8e0be6-631a-42ba-928b-5154c77c171e-ses0009

Action 3:

 SYS_COMPUTE_SESSION_ID=5c8e0be6-631a-42ba-928b-5154c77c171e-ses0010

 

The session ID ends with '-000X' and seems to get a higher number after each action (processing form). 

What does this last part mean? Is this still the same session or should we interpreted this as a new Session?

There seems to be a little bit performance improvement, but not allot. 

12 REPLIES 12
AllanBowe
Barite | Level 11

My theory on this is that the reusable context "reuses" a (parent) SAS session for each of the "sas00xx" (child) sessions.  That parent session will have already run the autoexec, and have the options set, making the creation of each child session much faster.

 

The reason you are seeing new session ids is likely because you are creating new sessions with each request (expensive / still quite slow).  If you want to re-use a specific session, you need to connect to that particular session id (they last 15 minutes without activity by default).

 

Connecting to an existing session is much faster than creating one each time - which is why, in the SASjs Adapter, we pre-spawn sessions for subsequent use (providing sub-second response time if everything is set up correctly).

 

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Wienik_Kruithof
Fluorite | Level 6

Thank you for your answer. 

 

I was thinking about a way to re-use the firstly created (child) session ID. 

Pre-spawn a session sounds to me like you create multiple sessions at the start of your program and assign them when necessary. 

AllanBowe
Barite | Level 11

That's right, SASjs uses a 'session array' and spawns additional sessions as they are popped off.  It also kills the sessions after they are used, which is more efficient than leaving it running for 15 minutes.

 

If you want to to re-use a single session you just need to post to the `/compute/sessions /$sessionid/jobs ` endpoint, eg:  https://github.com/sasjs/adapter/blob/master/src/api/viya/executeScript.ts#L157

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Wienik_Kruithof
Fluorite | Level 6

We are using a html form post request where we use the SASJobExecution/jobdefinitions/definitions/...... url.

In your documentation you refer to that as the JES API approach. 

 

Within the Webapp I would indeed like to re-use a single session. Is there an approach I can take while still using the html webform and the JES API. 

 

I have looked into the approach of using the compute api but that would  mean re-coding the total webapp which is mainly build using SAS and HTML coding.  I was hoping I could create a session (or determine the session on open) and reuse the session ID when the form action is initiated and the JES API is used.  

AllanBowe
Barite | Level 11

Mixing HTML / JS code with SAS is an antipattern - I would not recommend it, for many reasons:

 

  • Your app now requires developers with TWO skillsets (SAS + Web) to maintain.  These guys are like unicorns, very rarely are they competent in both disciplines.
  • You cannot test your web / sas code in isolation
  • You cannot lint either your SAS code nor web code using regular IDEs
  • You are reliant on a SAS instance to work on the web component
  • You cannot build a complex application this way (because even a very simple app will rapidly get complex)
  • Good luck using React, Angular, or any modern frontend framework that requires compilation.  (By the way, it's not impossible, you can do this with SASjs Streamed apps)

When we built the JES API approach (documented here: https://adapter.sasjs.io/#using-the-jes-api ) it was not possible to re-use session ids, perhaps that has changed now, if so I hope that this thread will be updated.

To my understanding though your performance gains will be limited to the use of a re-usable compute context - meaning best case 2 seconds on Viya 3.5 and 6-8 seconds on Viya 4.


Contrast with Compute API which is ~1 second - https://adapter.sasjs.io/#using-the-compute-api

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Wienik_Kruithof
Fluorite | Level 6

The gains we got from a re-usable compute context on Viya are indeed what you are saying. Although it's a big difference our webapp is still way to slow after moving from a 9.4 STP to the JobExecution on Viya. 

 

What would be a way to interact with a form/table? Do you have any suggestions? What approach would you take for a webform?

 

We now have a webform where users have to filter the data so the table has max 800 rows (due to browser performance) and then they will be able to changes values and write those results.

I'm afraid we will move back to Excel if the performance remains as is. 

 

AlanC
Barite | Level 11

Here is a suggested architecture. Put the SAS data read behind a web service so it is isolated. I have used ASP.NET to do this and it works great. SAS is ODBC/OleDB compliant so use one of those behind the web service.

 

I front using Blazor since it can use a local component to display the data. WebAssembly is beyond screaming fast. Blazor can play video games over the web, it is that quick. Blazor then becomes the UI. If you want to use something like React, you could do that too.

 

Allan is right about the challenges with finding people to do both but find a UI person and then can interact with SAS. SAS is easy to deal with for a competent C# (or whatever) developer. 

https://github.com/savian-net
AllanBowe
Barite | Level 11

Have you considered just using Data Controller for SAS?  https://datacontroller.io

 

We recently changed the pricing, so it is now free for unlimited users: https://datacontroller.io/pricing

 

Would be happy to shadow a deployment.  Thanks to our OEM licence of the HandsOnTable grid system, it can handle on-page editing of several thousand rows (per data page), even hundreds of columns.  For excel uploads, it can be tens of thousands, or more if you have a powerful PC.  For CSV uploads there is no limit, as the processing is done backend in SAS.

 

We have multiple customer references, including banks / government / insurance if needed.  The source is also available, you can build it yourself - https://git.datacontroller.io

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Wienik_Kruithof
Fluorite | Level 6

Hi Allan, 

 

The datacontroller looks interesting. 

I would like to see the effect of using the compute api within our environment. That is why we started testing with the example of the sasjs adapter.

 

We saw the effect of your bar chart example on youtube and wanted to replicate that with the code you provide. We are able to have it working with the use of the SASJobExecution, but not with the Compute API. 

 

When looking at the API call within the browser I can see the 400 return code.

 

When running the same API call within SAS Studio I see the same issue occurring multiple times. To me that seems like SAS has a problem with the quotations marks. Do you see how we can get this example working on Viya 2023.06?

 

205 " XATTR=ZDSATTR(XIDNM, 'ALL'); "
NOTE: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended.
206 " XATTRN=ZDSXATT(XATTR); "
207 " "
208 " do j=1 to xattrn; "
205 " XATTR=ZDSATTR(XIDNM, 'ALL'); "
                                                                 ---
                                                                 22
ERROR 22-322: Syntax error, expecting one of the following: ;, AUTH_ANY, AUTH_BASIC, AUTH_NEGOTIATE, AUTH_NONE, AUTH_NTLM,
CLEAR_CACHE, CLEAR_CONN_CACHE, CLEAR_COOKIES, CT, EXPECT_100_CONTINUE, FOLLOWLOC, HEADERIN, HEADEROUT, HEADEROUT_OVERWRITE, HTTP_TOKENAUTH, IN, MAXREDIRECTS, METHOD, NOFOLLOW, NOFOLLOWLOC, NOPROXY, NO_CONN_CACHE, NO_COOKIES, OAUTH_BEARER, OUT, PASSWORD, PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, PROXY_AUTH_BASIC,
PROXY_AUTH_NEGOTIATE, PROXY_AUTH_NONE, PROXY_AUTH_NTLM, QUERY, TIMEOUT, URL, USERNAME, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
209 " XATTRC=ZDSYATT(XATTR, j); "
210 " blank_pos = index(xattrc,\" \");"
211 "\t\t key = substr(xattrc, blank_pos,99);"

 

I'm not able to change the " XATTR=ZDSATTR(XIDNM, 'ALL');  code because it's not within the Job. 

AllanBowe
Barite | Level 11

Interesting.  This code is not within SASjs either.

 

Perhaps we can schedule a call to take a look?  I'd be happy to help, if I can.  https://4gl.io/cal

 

Am also free for the rest of today if you want to send me a PM.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Wienik_Kruithof
Fluorite | Level 6

That would be great. 

Not sure if my PM got through. If not I will schedule a meeting.

AllanBowe
Barite | Level 11

Great to chat, we're on the case in relation to the root cause, the issue can be tracked here:  https://github.com/sasjs/adapter/issues/829

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 5645 views
  • 5 likes
  • 3 in conversation