Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-03-02 Thread BenSav
Guys,

Thanks a lot for the explanation! Appears this was the problem indeed.

Now, every time the CreateMap function is executed, I capture the returned
object to a variable. Then I call Dispose() on it, and the proble is solved.

I'll make sure to check the rest of my code on similar issues.

Cheers!



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5310368.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-03-01 Thread Jackie Ng
This is sadly a leaky abstraction that is unavoidable at the moment. 

You have to be cognizant of the fact that although you're writing .net code,
it is .net code that ultimately wraps and interops to native C/C++ code, so
its memory management and lifecycle issues can crop up in your .net code if
you write your code in a "too .net" fashion.

So, I'd extend Benoit's advice to say that you should be capturing to a
variable *any method in the MapGuide API that returns an object reference*,
not just methods that return MgByteReaders.

- Jackie



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5310221.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-03-01 Thread Benoit Begin
I do believe you are leaking 1 MgByteReader per call.

Here is the definition of the function call:

public virtual *MgByteReader* CreateRuntimeMap(MgResourceIdentifier
mapDefinition, string sessionId, int requestedFeatures, int
iconsPerScaleRange);

It returns a MgByteReader. I strongly recommend putting it in a variable and
calling Dispose() directly on it. Odds are you are holding on to a bunch of
MgByteReader and the delay is the time the garbage collector takes to
manually dispose those objects.

My second recommendation would be to maybe not use CreateRuntimeMap. You are
not using the returned map definition whatsoever. You may as well just
create an MgMap and MgSelection directly and avoid some unecessary
processing? CreateRuntimeMap is useful when you want to have more
information about the map, including having Base64 icons for layers for a
legend type control. It doesn't look like this is the case for you.

Cheers,
Ben



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5310195.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-28 Thread BenSav

This is the function we are using to create the runtime map, it is called
from a for-loop:

private void CreateMap(string name, MgMappingService srv)
{
if (!string.IsNullOrEmpty(name))
{
try
{
_log.Info("Trying to create map: " + name);
MgResourceIdentifier resourceID = new
MgResourceIdentifier("Library://" + name + "." +
MgResourceType.MapDefinition);

_log.Info("MapDefinition resource: " +
resourceID.ToString());

srv.CreateRuntimeMap(resourceID, sessionId, 0, 100);

_log.Info("Map created");
}
catch (MgResourceNotFoundException e)
{
_log.Error("Failed to create map: " + name);
_log.Error(e.GetExceptionMessage());
}
catch (Exception e)
{
_log.Error("Failed to create map: " + name);
_log.Error(e.ToString());
}
}
}

This is what is being logged:

09 02 2017 11:22:41 INFO  Starting session
09 02 2017 11:22:41 INFO  Trying to create map:
DWG/Gasdetectie/Maps/OL_Gasdetectie
09 02 2017 11:22:41 INFO  MapDefinition resource:
Library://DWG/Gasdetectie/Maps/OL_Gasdetectie.MapDefinition
09 02 2017 11:22:41 INFO  Map created
09 02 2017 11:22:41 INFO  Trying to create map:
DWG/Kanaal_gent_terneuzen/Maps/OL_Waterwegen_details
09 02 2017 11:22:41 INFO  MapDefinition resource:
Library://DWG/Kanaal_gent_terneuzen/Maps/OL_Waterwegen_details.MapDefinition
09 02 2017 11:22:41 INFO  Map created
09 02 2017 11:22:41 INFO  Trying to create map:
DWG/Kanaal_gent_terneuzen/Maps/OL_Waterwegen
09 02 2017 11:22:41 INFO  MapDefinition resource:
Library://DWG/Kanaal_gent_terneuzen/Maps/OL_Waterwegen.MapDefinition
09 02 2017 11:22:41 INFO  Map created
09 02 2017 11:22:41 INFO  Trying to create map:
DWG/Info.Bloknrs/Maps/OL_Afdelingsnamen
09 02 2017 11:22:41 INFO  MapDefinition resource:
Library://DWG/Info.Bloknrs/Maps/OL_Afdelingsnamen.MapDefinition
09 02 2017 11:22:41 INFO  Map created
09 02 2017 11:22:41 INFO  Trying to create map:
DWG/Info.Bloknrs/Maps/OL_Info_BlokNrs
09 02 2017 11:22:41 INFO  MapDefinition resource:
Library://DWG/Info.Bloknrs/Maps/OL_Info_BlokNrs.MapDefinition
09 02 2017 11:22:41 INFO  Map created
.
.
.
09 02 2017 11:22:42 INFO  Trying to create map:
DWG/Nutsleidingen_gasvorm/Kooksgas/Maps/OL_196_info
09 02 2017 11:22:42 INFO  MapDefinition resource:
Library://DWG/Nutsleidingen_gasvorm/Kooksgas/Maps/OL_196_info.MapDefinition
09 02 2017 11:22:42 INFO  Map created
09 02 2017 11:22:42 INFO  Trying to create map:
DWG/Nutsleidingen_gasvorm/Kooksgas/Maps/OL_196_kooksgas
*09 02 2017 11:22:42 INFO  MapDefinition resource:
Library://DWG/Nutsleidingen_gasvorm/Kooksgas/Maps/OL_196_kooksgas.MapDefinition
09 02 2017 11:23:12 INFO  Trying to create map:
DWG/Nutsleidingen_gasvorm/Hoogovengas/Maps/OL_195_RegNr_hoogovengas*
09 02 2017 11:23:12 INFO  MapDefinition resource:
Library://DWG/Nutsleidingen_gasvorm/Hoogovengas/Maps/OL_195_RegNr_hoogovengas.MapDefinition
09 02 2017 11:23:12 INFO  Map created
09 02 2017 11:23:12 INFO  Trying to create map:
DWG/Nutsleidingen_gasvorm/Hoogovengas/Maps/OL_195_info
09 02 2017 11:23:12 INFO  MapDefinition resource:
Library://DWG/Nutsleidingen_gasvorm/Hoogovengas/Maps/OL_195_info.MapDefinition
09 02 2017 11:23:12 INFO  Map created


So you can see clearly there is a pause or delay of exactly 30 seconds. 






--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5310061.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-28 Thread Jackie Ng
If you ran CREATERUNTIMEMAP many times on the same map definition and same
set of parameters, the only difference in the responses you get back are the
session ids. Thus the caching opportunity is to save the rest of the XML
response as a cached "template" and for subsequent requests of the same map
and parameters, just fetch the stored template, plug in the new session id,
make the new MgMap/MgSelection in that session's repository and return that
plugged in XML response.

Still, I don't think this is the actual problem at hand. It might be a bit
slow on some big map definitions, but not "30 seconds" slow.

- Jackie



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5310028.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-28 Thread BenSav
Jackie
We are using AIMS 2015 at the moment.
I'll post a code snippet of what we are trying to do tomorrow when at the 
office.

Thx!

[cid:image004.png@01CE52E4.A7D3CDA0]

Ben Savelkoul
0494 64 63 73 |  
ben.savelk...@geosolutions.be

GEO Solutions nv, Prins Boudewijnlaan 41, 2650 Edegem
www.geosolutions.be
GIS op maat van uw organisatie |Advies | Analyse | Ontwikkeling | Data



From: Jackie Ng [via OSGeo.org] [mailto:ml-node+s1560n5309767...@n6.nabble.com]
Sent: dinsdag 28 februari 2017 2:33
To: Savelkoul Ben 
Subject: RE: 30 seconds delay after creating +/-100 CreateRuntimeMap calls

What is the rough pseudo-code of the thing you are doing ~100 times? I want to 
try and get a gauge of what server resources could possible be consumed.

Also, what version of AIMS/MapGuide is this and what WebTier configuration are 
you using?

- Jackie

If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309767.html
To unsubscribe from 30 seconds delay after creating +/-100 CreateRuntimeMap 
calls, click 
here.
NAML


image001.png (6K) 





--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309998.html
Sent from the MapGuide Users mailing list archive at Nabble.com.___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-28 Thread BenSav
Benoit,
Thanks for your comment. In fact we are creating the runtime maps server side 
sending an array of map definitions in the request as you suggest. Now to 
reduce the load a little bit, I am only doing this for the maps that are to be 
visible at startup of the application. When the user switches additional layers 
on I add them to the session over http but in this case it's only for a few 
layers at a time at most, so we are not experiencing any problems there.

I am wondering, in this blogpost:
http://themapguyde.blogspot.be/2013/08/mapguide-26-feature-showcase.html
It is mentioned that: "There are still unexplored caching opportunities on the 
server side that could make these response times even faster!" could this be 
related to the unexplored caching opportunities?

Cheers

[cid:image004.png@01CE52E4.A7D3CDA0]

Ben Savelkoul
0494 64 63 73 |  
ben.savelk...@geosolutions.be

GEO Solutions nv, Prins Boudewijnlaan 41, 2650 Edegem
www.geosolutions.be
GIS op maat van uw organisatie |Advies | Analyse | Ontwikkeling | Data



From: Benoit Begin [via OSGeo.org] 
[mailto:ml-node+s1560n5309989...@n6.nabble.com]
Sent: dinsdag 28 februari 2017 21:07
To: Savelkoul Ben 
Subject: RE: 30 seconds delay after creating +/-100 CreateRuntimeMap calls

One thing to keep in mind is if you are batching all those calls to the 
mapagent, you might be hitting the cap for simultaneously opened http requests 
to the same server. It's a little bit different from browser to browser, but 
typically only 4 to 8 http requests can be opened simultaneously to the same 
server. So since creating a runtime map can be a little bit time consuming, 
specially when creating so many at once, you might simply be stacking too many 
queries.

You could work around the issue by creating all your runtime maps server-side 
using php/.net and then just returning an array of all the map names you have 
created. This could check if the issue is creating so many maps or if it's 
because of too many http queries at once.

If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309989.html
To unsubscribe from 30 seconds delay after creating +/-100 CreateRuntimeMap 
calls, click 
here.
NAML


image001.png (6K) 





--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309997.html
Sent from the MapGuide Users mailing list archive at Nabble.com.___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-27 Thread Jackie Ng
What is the rough pseudo-code of the thing you are doing ~100 times? I want
to try and get a gauge of what server resources could possible be consumed.

Also, what version of AIMS/MapGuide is this and what WebTier configuration
are you using?

- Jackie



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309767.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-27 Thread BenSav
Hi Jackie,

I do pass the session ID to the CREATERUNTIMEMAP call. I also tried to bump the 
SessionRepositoriesLimit value, but I've never encountered more than about 20 
sessions at a time so that doesn't seem to be the problem. That is about 20 
sessions since we haven't gone to production yet. If I encounter this problem 
in our test environment, I expect it only to be worse in production.

Now, I already changed some things in my viewers code to not load all the  
runtime maps at once into the session at startup. So, this keeps the problem 
from occurring for now. But I am not sure that will do for production.

Cheers, Ben



[cid:image004.png@01CE52E4.A7D3CDA0]

Ben Savelkoul
0494 64 63 73 |  
ben.savelk...@geosolutions.be

GEO Solutions nv, Prins Boudewijnlaan 41, 2650 Edegem
www.geosolutions.be
GIS op maat van uw organisatie |Advies | Analyse | Ontwikkeling | Data



From: Jackie Ng [via OSGeo.org] [mailto:ml-node+s1560n5309742...@n6.nabble.com]
Sent: maandag 27 februari 2017 23:16
To: Savelkoul Ben 
Subject: Re: 30 seconds delay after creating +/-100 CreateRuntimeMap calls

CREATERUNTIMEMAP itself will also create a session for you if you do not pass a 
session id to it.

Do you pass the session ID to the CREATERUNTIMEMAP call? If not, that's 2 
sessions created for every time you are starting up your viewer. If you are 
doing 100 calls before seeing a 30s delay, assuming you didn't pass session id 
to CREATERUNTIMEMAP, then that's (100 * 2 = 200 sessions created) and you might 
have just hit the default value of SessionRepositoriesLimit in serverconfig.ini

If you haven't bumped up this value, you probably should.

- Jackie

If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309742.html
To unsubscribe from 30 seconds delay after creating +/-100 CreateRuntimeMap 
calls, click 
here.
NAML


image001.png (6K) 





--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309750.html
Sent from the MapGuide Users mailing list archive at Nabble.com.___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-27 Thread Jackie Ng
CREATERUNTIMEMAP itself will also create a session for you if you do not pass
a session id to it.

Do you pass the session ID to the CREATERUNTIMEMAP call? If not, that's 2
sessions created for every time you are starting up your viewer. If you are
doing 100 calls before seeing a 30s delay, assuming you didn't pass session
id to CREATERUNTIMEMAP, then that's (100 * 2 = 200 sessions created) and you
might have just hit the default value of SessionRepositoriesLimit in
serverconfig.ini

If you haven't bumped up this value, you probably should. 

- Jackie



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691p5309742.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Re: [mapguide-users] 30 seconds delay after creating +/-100 CreateRuntimeMap calls

2017-02-27 Thread Savelkoul Ben
Hi

I am building a Openlayers client for AIMS where at loadtime I call the
server api to create a session and to create maps to work with within this
session. I use OPERATION=GETDYNAMICMAPOVERLAYIMAGE to call the layers from
openlayers. In some cases the number of CreateRuntimeMap calls to the server
can get higher than 100 in a few seconds. When this happens it seems that
the server needs to clear a cache of some sort, because there I see in the
logs that for (almost exactly) 30 seconds, nothing is happening. The http
calls that were send to the server to add the runtimemap to the session have
status 'pending' until the 30 sec lapse has passed.

Based on this behaviour I would expect that there should be some value in
the serverconfig.ini to increase the Cachelimit of some sort, but having
tweaked every value that even remotely looks like it might bring a solution,
I don't see what else I can do.

I already contacted the support team of AIMS, but so far they could not help
me. In fact they refered me to this forum.

Any help would be highly appreciated!



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/30-seconds-delay-after-creating-100-CreateRuntimeMap-calls-tp5309691.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users