ArcGIS Online print servic performance

737
3
02-21-2022 02:27 AM
pmi
by
New Contributor II

We use the ArcGIS Online print service, which is available at the following URL: https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%...

Unfortunately, the Esri print service in the afternoon (CET) has very poor performance and is prone to errors.
In particular, these errors occur in the evening between 4:00 p.m. and 6:00 p.m. (CET) and Esri does not return an image. (see charts below)

We have built in a retry mechanism that tries up to 3 times to load the image. Sometimes the image service returns an image on the 1th, the 2nd or 3rd attempt with the identical query.
This retry mechanism is not optimal because the requests for our customers take a long time and we unnecessarily load ArcGIS Online.

Are you aware of this issue? Do you know what is causing this? Does Esri have a recommendation on how to work around such errors?

0 Kudos
3 Replies
LauridsSund
New Contributor

I do have the troubles - did you find a solution?

0 Kudos
pmi
by
New Contributor II

To solve the issue with the errors we use Polly (https://www.pluralsight.com/blog/software-development/intro-to-polly) as a retry framework.

Duration of requests could not be solved until now. Unfortunately, there was no willingness from esri to investigate the problem.

0 Kudos
pmi
by
New Contributor II

The duration of request can be improved by using Export Map instead of the PrintTools API (https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export)

=>https://developers.arcgis.com/rest/services-reference/enterprise/export-map.htm

Then you can load a base map and a layer map image and put them together.

.net API with c#:

        [HttpPost("/v1/[controller]/[action]")]
        [ProducesResponseType(typeof(ImageData), StatusCodes.Status200OK)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> ByUrlPoc([Required][FromBody] PrintByUrlInput printByUrl)
        {
            var basemapResponse = await _httpClient.GetAsync(printByUrl.BasemapUrl);
            byte[] basemap = await basemapResponse.Content.ReadAsByteArrayAsync();

            var layerResponse = await _httpClient.GetAsync(printByUrl.LayerUrl);
            byte[] layer = await layerResponse.Content.ReadAsByteArrayAsync();

            var resizeFactor = 1f;
            //var basemapImage = SKBitmap.Decode("img\\Bild_voll.png");
            var basemapImage = SKBitmap.Decode(basemap);
            var toBitmap = new SKBitmap((int)Math.Round(basemapImage.Width * resizeFactor), (int)Math.Round(basemapImage.Height * resizeFactor), basemapImage.ColorType, basemapImage.AlphaType);

            var canvas = new SKCanvas(toBitmap);
            // Draw a bitmap rescaled
            canvas.SetMatrix(SKMatrix.CreateScale(resizeFactor, resizeFactor));
            canvas.DrawBitmap(basemapImage, 0, 0);
            canvas.ResetMatrix();


            //var layerImage = SKBitmap.Decode("img\\Bild_transp2_800.png");
            var layerImage = SKBitmap.Decode(layer);
            canvas.DrawBitmap(layerImage, 0, 0);

            canvas.Flush();

            var image = SKImage.FromBitmap(toBitmap);
            var data = image.Encode(SKEncodedImageFormat.Jpeg, 90);

            var stream = new MemoryStream();
            data.SaveTo(stream);

            data.Dispose();
            image.Dispose();
            canvas.Dispose();
            toBitmap.Dispose();
            basemapImage.Dispose();

            return base.File(stream.ToArray(), "image/jpeg");
        }

        public class PrintByUrlInput
        {
            public string BasemapUrl { get; set; }
            public string LayerUrl { get; set; }
        }

 

 

0 Kudos