Is there a way to handle performance of the map when large number of layers are loaded.
currently we have scenarios where over 200 layers are being loaded depending on the need, and it slows everything down.
Layers sets are combination of MapImageLayer and FeatureLayer.
Edit 1 - MapImageLayers are registered by individuals themselves. They have MapServers running they want to add. Some of these MapServers are large to say the least.
I'd be interested in this question too. Furthermore I'd like to know if there is an option to load a layer only when it gets displayed the first time (if the layers are not visible on starting the application, they don't need to be loaded. however this is currently the case which leads to a long loading time for the application).
Right off the bat I'm just going to say that 200 layers is waaayyyy too many layers to be loading. Even if you used ArcGIS Pro and had the data stored locally, the time it took to display that many would seem slow. There's also a difference in having 200 simple layers, like just a couple of points/lines, versus 200 layers with a few hundred (more?) records each, but both scenarious will run slow in performance, especially when exacerbated by being online. Some things to think about in trying to speed things up:
1. Make sure all of the data is in Web Mercator projection. That's what Online uses and even if you are using an internal Portal, if you use any online basemaps they will still be using Web Mecator.
2. Reduce the fields to only what is necessary. Having a large number of fields will not help anything.
3. Make sure the spatial indexes are there and up to date. You can update them for Online featureclasses by going into the Layer's settings.
4. Use scale dependency settings to make sure each layer is only showing at the scale(s) it is relevant to view at.
In the past, I had developed an application that needed some large layers, and we only showed 1 or 2 layers upon open, and slowly added them to the map (not too slow) while the user started moving around. This was long before the current ArcGIS Online usage, but if you load an ArcGIS Online map with the data already loaded it might already have some of the performance fine tuned.
Still, my recommendation is to figure out how to combine data layers, put your data on different maps, or re-evaluate why you need 200 layers. Maybe you could create one map with a few layers, then another map with some other layers, and then move between the maps when selected. Just a thought.
Edited the post to explain the situation further. Layers are added ad-hoc by users, and they are oftern series of MapServers with number of sublayers.
Some of your ideas we have already implemented (1,2), 4 is handled via extent of the mapview, however if you can advise how to ensure this is enforced I can review. Item 3 can't confirm as these are external brought in by users.
I would echo @JeffreyWilkerson comments. Spot on. With the scale dependency set in the map view, the layers won't load data, but they will send requests for details if referenced as item ids, things like title, name, basically stuff needed for layer list or other resources. I have worked with customers that have had to work with large numbers of layers in their applications and there are some methods that have helped.
In both these cases, you probably have a base set of layers like parcels or boundaries always on, but you can now better control when and what layers are loaded to help alleviate the load.
Edited the post to explain the situation further. Layers are added ad-hoc by users, and they are oftern series of MapServers with number of sublayers.
Unfortunately since a lot of data is outside of our control, our filtering capability is limited to only content we manage.