7. Managing Resources
In this section, you will learn:
- How to monitor server resources
- What resource configuration options can be utilized
- How to manage and customize disk usage
- Where logs are located and how to utilize them
Admin dashboard
The Admin page is available for Connect administrators from the top navbar. This is an excellent way to monitor server performance, content usage, and scheduled content.
- Metrics: CPU, RAM, Named Users, Shiny Connections, Usage Scorecard, Processes Run
- Mail Settings: Change email settings
- Tags: Add/Delete/Update/Organize tags
- Audit Logs: captured events by Connect’s audit system
- Unpublished Content: Content that has encountered errors while deploying
- Scheduled Content: View all content scheduled
- Server Status Reports: Diagnostic reports
Processes monitoring
There is a table of processes listed at the bottom of the screen on the Metrics tab of the Admin page. This table is useful to find information on which processes have been run on the Connect server and resource information about each. It also provides quick access to each piece of content and logs by clicking the notepad icon.
Each process will create a copy of the application, therefore, using up an additional core and the amount of memory required of the app while running. The information in this dashboard can be used to plan out capacity, which is looked at more in-depth in the Scaling section of this course.
Configuration choices
Applications and APIs
Users with Publisher or Collaborator permissions can change runtime settings for each API and application, which controls how Posit Connect manages processes for deployed applications and APIs. An administrator may change the default global values by editing the Scheduler section of the configuration file.
To prevent a few applications from taking over large amounts of server resources, utilize the MaxProcessesLimit configuration value. This sets the maximum MaxProcesses
value a user can set for any application or API.
By default IdleTimeout is set to 5 seconds, which will shut down a process when there are no longer any connections. For resource-intensive apps with users rapidly connecting and disconnecting, users may want to increase this to keep processes running for the next user. If processes are still running after connections have closed and these applications/APIs are taking up unnecessary server resources, this setting may be the culprit.
Reports
Reports can be scheduled to run at a set time and execute on the Connect server. By default ScheduleConcurrency is set to 2 in the configuration settings, meaning only two pieces of content will be executed in parallel. If you expect users to schedule multiple pieces of content to run around the same time, increase this setting.
Each piece of content will be run on a separate R or Python process, requiring additional cores on the server. Please ensure there are enough resources available before changing this setting.
Disk usage resource management
Posit Connect stores many items on the server, including:
- Content bundles (uploaded compressed bundles from users)
- Unzipped bundles for running applications
- Package caches (one copy per unique package version)
- Metrics (RAM and CPU usage)
- R/Python process information
- Logs
Data directory
By default, the data directory is set to /var/lib/rstudio-connect
, which will store all of the variable data associated with content and information used by the server in managing deployed content. The location of this directory may be changed in the configuration with Server.DataDir.
For more information on what data is stored and how to configure specific directories refer to the Variable Data section of the Admin Guide.
Bundle management
All bundles will, by default, remain on the server indefinitely as BundleRetentionLimit is set to 0. Setting this to a different integer will cause older bundles to be deleted, saving space in the server.
Individual bundles are generally not large in size unless users are bundling data with their content. If large bundles are being put onto the server, ask users to separate their data from the application by utilizing a database or provision the data on the server.
Logs
Posit Connect by default since the 2022.06.0 release utilizes structured logging, which offers significant formatting and organizational improvements over previous basic logging implementation. If your server is running a prior version of Posit Connect, be aware the formatting/organization of logs will appear differently than the current version.
Structured logging emits three types of log events:
- Service Logs capture the operating behavior of Posit Connect.
The default location for service logs is: /var/log/rstudio/rstudio-connect/rstudio-connect.log
- Access Logs capture information about client requests received by Posit Connect.
The default location for access logs is: /var/log/rstudio/rstudio-connect/rstudio-connect.access.log
- Audit Logs capture information about the set of events defined by Posit Connect’s auditing system.
The default location for audit logs is the database, but this information can be accessed on the Admin page or via the Connect API.
There are also Debug Logs, which provide troubleshooting information about specific services such as authentication.
Exercise
🚀 Launch the exercise environment!
In the exercise environment you will get experience:
- Identifying content resources used
- Determining server resources required to support content
- Managing disk storage space
- Finding and utilizing service, access and audit logs
Go to: 8. Scaling