[Qgis-developer] [Server] performance questions

Neumann, Andreas a.neumann at carto.net
Fri Apr 22 07:45:38 PDT 2016


Hi Jörg, 

Unfortunately I am not the suitable person to ask. In only occasionally
develop Python and don't know C/C++. However, I am a long-time QGIS
server user. I have big projects as well (with 80/90 layers). They
usually render in 1-2 seconds, not 20 seconds like you cite. So maybe
there are other issues/bottlenecks? Do you have an exceptional number of
features in your layers? Do you use scale thresholds to filter features.
Typically it doesn't make any sense to render too many features at small
scales, because you can't depict them anyway if there are too many. 

I assume you use Postgis as a data source - since you talk about DB
queries. Do you have the proper spatial index and other indexes? Do you
have a recent version of QGIS server? I think version 2.10 and later
introduced filtering inside the DB (instead of filtering in QGIS), which
should come with a performance improvement. 

20 seconds is definitely too long a wait for a map rendering, but I
guess you can bring this down to 1-2 seconds if properly optimized (both
in DB and in QGIS). 

It may well be that there is room for improvements in rendering speed of
QGIS server, but multi-threading is probaby the most complicated way of
improving performance in QGIS server. When I asked Marco Hugentobler,
the main QGIS Server developer, he told me it would be almost impossible
to make QGIS server multi-threaded. 3LIZ is also into QGIS server
development since some time. So these are the guys to ask. 

And then - the other issue is that you want to reserve your other CPU
cores for parallel requests as well. You usually don't want to dedicate
all your CPU power to a single http request. 

But if there is a way to improve speed in QGIS server I am all for it
... 

Greetings, 

Andreas 

On 2016-04-22 15:20, Jörg Habenicht wrote:

> Hi Andreas, dear list,
> 
> sorry for the warm up of this old topic.
> 
> There is in deed a need to enable multi threading in Qgis-Server.
> 
> In our company we use around 60 different layer to lay some topics on
> the map. This may be an extreme example to read, but quite common in our
> environment, i.e. we can not lower this number significantly.
> 
> A warmed up QGis-Server process which already read and cached the
> Configuration file qgis-xy.conf still needs around 20 seconds to
> calculate the complete resulting map picture.
> 
> During this calculation there is only one thread working, serializing
> the DB-requests, calculation the layer picture and mapping the picture
> on the resulting picture.
> The process is running on a multi core server. If we can utilize the
> idle cores to do useful work, this can be an easy example to speed up
> the process (significant).
> 
> I'd like to share my developing experience to do this change, but I
> would need further information and some support to do some useful patches.
> 
> I have scanned the git-Qgis sources (commit
> 81744ecf90a8f6c1e2e94fdacb07e3dca6987dcc) for a suitable multithreading
> entry. Found QgsMapRenderer::render() because of the line "while (
> li.hasPrevious() )". It seems in this loop the layers are painted in
> serial onto the resulting picture.
> If I can build an auto parallel computing with QtConcurrent in this
> place there seems to be the most gain. I mean to parallelize the loop
> with concurrent DB requests, concurrent painting in separate pictures
> and in serial map the single pictures onto the result picture.
> 
> Right now I don't know if I can do DB requests in parallel, or where the
> code for database requests is buried.
> And how about the calls inside the loop, are there side effects
> preventing multi threading?
> 
> Do you got hints, flames or suggestions?
> 
> cu
> Jörg
> 
> Am 23.02.2016 um 16:39 schrieb Neumann, Andreas: 
> 
>> Hi Régis,
>> 
>> QGIS server is single-threaded. You can't simply turn on multi-threaded
>> rendering in QGIS server. The other issue is that each Apache FCGI
>> process has it's own set of cache. So if you have 5-10 parallel Apache
>> threads or processes each thread/process has it's own cache. If your
>> client hits a thread that has the cache unititialized you will have wait
>> longer until this cache is fillled.
>> 
>> I once asked Marco whether one could
>> 
>> a) have a shared cache for all Apache threads or processes
> 
> There is no shared cache, because Apache spawns QGis-Processes with its
> own memory layout. these Processes know nothing about its neighbor, and
> you have a hard time to exchange data between all processes.
> How about a scheduler, which assigns requests to warmed up Qgis-processes?
> 
>> b) support multi-threaded rendering
>> 
>> But he said it would be very complicated to implement a) and b), if not
>> impossible. Maybe other devs have other views. Note that was about 2
>> years ago, when I last discussed this with Marco.
>> 
>> ---------------------
>> 
>> Nevertheless I believe there would be room for performance improvements
>> in QGIS server - if interested parties share their efforts (be it dev
>> time or financial resources).
> [snip] 
> 
>> Andreas
> [snip] 
> 
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> 
> -- 
> 
> mWerk GmbH
> Dipl.-Ing. Jörg Habenicht
> Landwehrstr. 76
> 30519 Hannover
> (T) +49 511 9999 8033
> (F) +49 511 9999 8041
> (E) jh at mwerk.net
> Amtsgericht Hannover HRB 206522
> Geschäftsführer
> Reiner Brachvogel
> Dennis Kornehl
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160422/a448d78b/attachment-0001.html>


More information about the Qgis-developer mailing list