<div dir="ltr"><div>Hi Jukka,</div><div><br></div><div>Thanks for the advice. I was able to confirm through local testing that using "DATA" is consistently faster than using the OGR connection (was getting over 500 ms for OGR vs just over 300 ms for DATA). My results are also suggesting that performing the shapefile optimizations may make my request several hundredths of a second faster, I'm a little less sure on that one. But regardless, it appears that the bulk of the problem with the slow S3 connection is likely S3's overhead, so I don't think there's anything more I can do with MapServer to speed it up.</div><div><br></div><div>Thanks again,</div><div>Matt<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 8, 2023 at 11:58 AM Rahkonen Jukka <<a href="mailto:jukka.rahkonen@maanmittauslaitos.fi">jukka.rahkonen@maanmittauslaitos.fi</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-3472087305491934760">
<div style="overflow-wrap: break-word;" lang="FI">
<div class="m_910239788150493526WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">You should test the same shapefiles locally for understanding where the time gets spent. Normal time with simple styles is perhaps up to 300 ms. The optimization hints were written long
before there were S3 or Amazon (the company).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Unfortunately I don’t know how to optimize access to S3.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> MapServer-users <<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>>
<b>Puolesta </b>Matthew Graber via MapServer-users<br>
<b>Lähetetty:</b> perjantai 8. joulukuuta 2023 21.47<br>
<b>Vastaanottaja:</b> <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br>
<b>Aihe:</b> [MapServer-users] Speeding up msDrawMap() for shapefiles<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'm trying to speed up the time required for msDrawMap() to execute for rendering shapefiles. Currently, according to the mapserver logs, it's taking 2.5-3.5 seconds, sometimes up to 5 seconds for it to execute:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">[Wed Dec 6 18:43:47 2023].699791 CGI Request 53 on process 2641<br>
[Wed Dec 6 18:43:47 2023].717216 msDrawMap(): rendering using outputformat named png (AGG/PNG).<br>
[Wed Dec 6 18:43:52 2023].299580 msDrawMap(): Layer 1010 (Shapefile_Layer), 4.582s<br>
[Wed Dec 6 18:43:52 2023].299792 msDrawMap(): Drawing Label Cache, 0.000s<br>
[Wed Dec 6 18:43:52 2023].299803 msDrawMap() total time: 4.584s<br>
[Wed Dec 6 18:43:52 2023].310853 msSaveImage(stdout) total time: 0.011s<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">[Wed Dec 6 18:43:52 2023].310883 mapserv request processing time (msLoadMap not incl.): 4.611s<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The mapfile is currently set up using "CONNECTIONTYPE OGR" and "CONNECTION" to access the shapefiles from an S3 bucket as follows:<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">CONNECTIONTYPE OGR<br>
CONNECTION '/vsis3/s3_bucket_path/my_shapefile%.shp'<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I noticed at <a href="https://mapserver.org/input/vector/shapefiles.html" target="_blank">
https://mapserver.org/input/vector/shapefiles.html</a> that it says "Shapefile access is built directly into MapServer. It is also available through OGR, but direct access without OGR is recommended and discussed here."<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">So I tried removing "CONNECTIONTYPE OGR" and changing "CONNECTION" to "DATA" as follows:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> DATA '/vsis3/s3_bucket_path/my_shapefile%.shp'<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I haven't been able to observe any definitive speed improvements by doing this yet, although I can't say for sure that there aren't any.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Based on <a href="https://mapserver.org/optimization/vector.html" target="_blank">
https://mapserver.org/optimization/vector.html</a>, I also tried using the shptree command to create a spatial index and the coshp command to sort the shapefile and index. Even after doing that, I still see load msDrawMap() times of up to 5 seconds.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Does anyone know of any other optimizations that could be made here? Or if not, would using shptree and coshp on the shapefile and then accessing it in the mapfile using "DATA" to take it from S3 be the optimal way to set things up?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Matt<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div></blockquote></div>