ArcGIS Enterprise

Move services to shared instances using Python

This year, we introduced shared instances to ArcGIS Enterprise. This is a significant evolution in how your server sites handle service traffic. Rather than each service in a site running their own service instances, the shared instance pool is designed for use by multiple services.

Compatible map services published from ArcGIS Pro to ArcGIS Server 10.7 and later can be configured to use this pool. When they need to process a request, they’ll use a shared instance; once the job is finished, they’ll release the instance back into the shared pool.

 

The shared pool option for a service
Selecting the shared pool option will grey out the parameters pertaining to the dedicated instance pool.

For many server sites, shared instances can drastically reduce the memory footprint of map services. It’s a particularly big win for services that receive infrequent traffic (perhaps one service request every minute on average or less). Because these services aren’t running their own service instances on each machine in the server site, all that memory is conserved for use elsewhere.

Administrators have also told us they like the reduced time and effort involved in managing service instances – instead of adjusting the dedicated instance pool size for all their services, they can place those services in the shared instance pool.

To learn more about shared instances, and to see which services are compatible with the shared instance pool, take a look at our blog from March. The documentation topic Configure service instance settings has all you need to know to get started.

A new tool for administrators

A request we heard at User Conference was for the ability to move existing compatible map services to the shared instance pool in bulk. While you can change the default instance type used for newly published compatible map services, that only governs new services, not the existing services running in your site.

For administrators of sites with lots of services, it can be a hurdle to examine each for compatibility, then change each compatible service’s instance type in Server Manager.

Hence, a script to automate the flip.

We’ve put together a Python script that does two things. First, it counts the number of services in your site by their “provider” – a value ArcGIS Server uses to know how to run. This breaks down the services in your site into three categories:

You can optionally tell the script to change the provider for the services in the second category – the ones published from ArcGIS Pro that are currently using dedicated instances – and change them to use shared instances.

This will move all compatible map services in your site from using their own dedicated instance pools to instead use the shared instance pool. (Services published from ArcGIS Pro that aren’t compatible with shared instances won’t be moved.)

Just like that – you’ve bulk updated your services to make the most of the shared instance pool!

Let’s get started

You can access the script on GitHub. The script requires a Python 3 environment with the ArcGIS API for Python installed.

If you’re wondering how to get such an environment, it just so happens that the Python environment that comes with ArcGIS Pro nicely fits that description.

To run the script, download the it or copy it into a new file and save. Then, in a terminal with access to the right Python environment, change directories to where the script file is located and run the following command:

 

If you include the optional ——update parameter, the script will attempt to move all Pro-based services from dedicated to shared instances. If you don’t include it, the script will print out the list of services in each category without changing anything.

Note: This script assumes your server site allows built-in authentication with a simple username and password. If your site has a different form of authentication configured, you’ll need to modify the script.

We’d love any feedback you have on the script – or on your experiences with the shared instance pool in general. Please reach out to us on Twitter @ArcGISXprise or post on GeoNet.

And keep watching this space – we’ll have more updates for shared instances at the next release of ArcGIS Enterprise.

Happy scripting!

About the authors

Philip is the senior product manager for ArcGIS Enterprise. He enjoys living in Southern California and traveling around the world for both business and pleasure.

Scott is a product engineer on the ArcGIS Enterprise team. Follow him on Twitter: @macd_sm.

Connect:

Next Article

Getting to Know the Data Loading Tools

Read this article