編輯

共用方式為


How to create and manage session pools for fast web service connections in R

Important

This content is being retired and may not be updated in the future. The support for Machine Learning Server will end on July 1, 2022. For more information, see What's happening to Machine Learning Server?

Applies to: Machine Learning Server 9.3 (R) | Machine Learning Server 9.4 (R)

Fast connections to a web service are possible when you create sessions and load dependencies in advance. Sessions are available in a pool dedicated to a specific web service, where each session includes an instance of the R interpreter and a copy of dependencies required by the web service. For example, if you create ten sessions in advance for a web service that uses Matplotlib, dplyr, cluster, RevoScaleR, MicrosoftML, and mrsdeploy, each session would have its own instance of the R interpreter plus a copy of each library loaded in memory.

A web service having a dedicated session pool never requests connections from the generic session pool shared resource, not even when maximum sessions are reached. The generic session pool services only those web services that do not have dedicated resources.

For R script, the mrsdeploy function library provides three functions for creating and managing sessions:

Create or modify a dedicated session pool

Given an existing connection to a Machine Learning Server with operationalization enabled, you can use mrsdeploy functions and an R console application such as Rgui.exe to run the following commands:

 # load mrsdeploy and print the function list
 library(mrsdeploy)
 ls("package:mrsdeploy")

 # Return a list of web services to get the service and version 
 # Both service name and version number are required
 listServices()

 # Create the session pool using a case-sensitive web service name
 # A status code of 200 is returned upon success
 configureServicePool(name = "myWebservice1234", version = "v1.0.0", initialPoolSize = 5, maxPoolSize = 10 )

 # Return status 
 # Pending indicates session creation is in progress. Success indicates sessions are ready.
 getPoolStatus(name = "myWebService1234", version = "v1.0.0")

Currently, there are no commands or functions that return actual session pool usage. The log file is your best resource for analyzing connection and service activity. For more information, see Trace user actions.

Delete a session pool

At the R console, on the compute node, run the following command to delete the session pool for a given service.

 # Return a list of web services to get the service and version information
 listServices()

 # Deletes the dedicated session pool and releases resources
 deleteServicePool(name = "myWebService1234", version = "v1.0.0")

This feature is still under development. In rare cases, the deleteServicePool command may fail to actually delete the pool on the computeNode. If you encounter this situation, issue a new deleteServicePool request. Use the getPoolStatus command to monitor the status of dedicated pools on the computeNode.

# Deletes the dedicated session pool and releases resources
deleteServicePool(name = "myWebService1234", version = "v1.0.0")

# Check the real-time status of dedicated pool
getPoolStatus(name = "myWebService1234", version = "v1.0.0")

# make sure the return status is NotFound on all computeNodes
# if not, issue another deleteServicePool command again

See also