# MedLearn Performence, Server Resources, Societies Enhancements ## Performance Societies is not slow due to server resources. NewRelic shows me what is slow and with Societies it is all client-side slowness. We have alerts on both CPU and memory use. If the thresholds are passed, NewRelic alerts us. When societies is accessed, the server resources do not increase and do not reach the threshold for alerts. > CPU and memory use has not gone above 20-25% average in the last 14 days [Link to NewRelic resouce monitoring](https://one.newrelic.com/launcher/infra.infra?pane=eyJuZXJkbGV0SWQiOiJpbmZyYS5ob3N0cyIsImZlYXR1cmUiOiJzeXN0ZW0iLCJob3N0c0ZpbHRlcnMiOnsiYW5kIjpbeyJpcyI6eyJlbnRpdHlOYW1lIjoiaXAtMTcyLTIyLTMtMTg2LnVzLXdlc3QtMi5jb21wdXRlLmludGVybmFsIn19XX19&platform[timeRange][begin_time]=1598980860000&platform[timeRange][end_time]=1600276924407&platform[accountId]=1827178) We do sometimes get alerts tied to Societies when there is a poor end-user experience, meaning that browser processing is slow. ## Calendar Performance Most of our performance alerts are linked to the calendar. Elentra put out an update to the calendar to help improve this. We deployed it on 2020-09-03. Subsequently, we stopped getting CPU spikes and alerts. On Monday there was significant performance degradation, but only with end-user experience. `No CPU/memory alerts.` NewRelic alerted us of this problem at the same time users were also reporting problems. I tracked it down to the calendar ICS downloads. The downloads were including all of the assignments for the past year and into the next year. This is a new feature recently added to Elentra. We turned off this feature and have not had a performance alert since Monday. > We have not seen any CPU/Memory spikes or alerts since we deployed calendar improvements on 2020-09-03 ### Societies client-side performance enhancements 99% of Societies's processing is done in the browser with our Vue.js modules. Vue.js is a javascript framework. All of the code executes in the browser. The code makes API calls to retrieve and update data. Those API calls are fast and do not use significant server-side processing. The Societies module is very big and has many Vue.js files. When the browser needs to refresh the Vue.js files, it can take a significant amount of time for all of the files to download. Once the files are downloaded, the browser caches those files, and subsequent Societies page loads will be much faster. This is the most likely cause of Societies slowness. To mitigate this issue, and give the user more feedback instead of a blank page, I added a "please wait while societies loads" message. The browser will wait until all of the files are downloaded start executing the Vue modules. When the Vue module starts executing, the message goes away and the user sees the Societies interface. > All MedLearn Vue module, including those developed by the Elentra core team have this same problem. > This change has been tested and is in staging. Societies includes a number of tabs. The data for each tab is loaded on the first request to the page. I reduced the amount of processing that takes place when the page first loads by waiting to request and process the data for each tab, `only if the tab is clicked.` > This change has been tested and is in staging. Some data requests to the API were optimized by replacing mulitple API calls with a single API call. This means only waiting for one API request to complete processing in the browser. This also avoids hitting the API rate limit. > This change has been tested and is in staging. ## UI Enhancements There were problems with Bedside Competencies where the data entered was not being saved even though it looked like it was. I added Save buttons and error handling to give the user more feedback that the data was saved. If there were errors, an error message is displayed. > This change is being tested and is in test. ## Security Some API endpoints were not secured properly. I created authorization policies and implemented them following the pattern recommended by Elentra. > This change has been tested and is in staging.