Generating reports to xlsx - resource uses

Niko Lync6 years ago

Hi, I have a quick question

I'm displaying on the web a "route" report for several vehicles. Waiting about a minute the report data is shown ( about several thousand lines) , the route is visible on the map. When generating a report, the server is not overloaded. Everything is working properly.

If I try to export the same (or even smaller) report or send it via email, the CPU load reaches 99% and after a short time it receives an error in the log.

WARN: / api / reports / route - org.glassfish.jersey.server.ContainerException: java.lang.OutOfMemoryError: Java heap space - ServletException (...)

(for completely shorter reports, export also works)

I know that I can add RAM or adjust memory using the Xmx parameter. I also know that the export route to excel also does not make much sense. However, I am curious why it is, such a difference in the way of exporting the same data. Is this a bug in 4.3 or normal.

traccar 4.3 / ubuntu 18.04 / mysql 14.14 5.7.25

Anton Tananaev6 years ago

I guess more memory is allocated for email itself, which causes it to reach the limit.

Niko Lync6 years ago

I did one more test. I made the "route" report for 1 vehicle from the period of 1 month. (37000 rows / 3 MB)

  1. It took 15 seconds to display the report on the website. While generating the report, the average processor load was about 5%.

  2. The attempt to generate a email report took over 70 seconds. During the report generation, the CPU load was around 99%. (Java) The report did not execute due to the memory limit. (default memory settings)

For example, the same data "Trips" report is performed about 2 seconds by both www and by email.

If the execution of the report via the website almost completely does not use the resources of the server, then the attempt to export or email report kills the CPU. For less-efficient machines, clicking the export or email report button may cause performance problems experienced by other server users. (As I checked on the Windows server, it also occurs)

Of course, increasing the MaxHeapSize memory limit causes the report is generated and sent, however the performance is worse than when the report is generated by the website

It seems to me that the priority of generating a report by email should be rather low (in most cases it is not important if the message will come in 5 seconds or in 5 minutes)

Is it possible to change it in easy way ? or is it better to arm yourself with xeon platinium and forget about the case :)

Anton Tananaev6 years ago

There is no easy way to change it.

Peter Flower6 years ago

Hi, I have the same question, I don't know why is too slow the report part.
Is there any workaround to speed a little bit this execution?

Tony Shelver6 years ago

To (maybe) elucidate on Anton's comment. I suspect it very much depends on the library being used. I have a custom report that feeds off our existing tracking application (that hopefully we will migrate to Traccar) written in Python. Like many of the Excel libraries out there, it generates the entire spreadsheet in memory before writing it to file.

In our case, it's a measure of how much free memory is on the machine at the time as to the size of the file that can be exported. There are also varying limits on the total number of rows depending on the file type (older Excel versions had much lower row limits).

Jack3 years ago

I've also stepped on this. The report export is very inefficient as it drives multicore server to max system load for exporting just 15 days for 1 device.

Basically the export button is a self DDOS, as it also stopped the processing of incoming requests in my case.

I'll experiment with https://www.traccar.org/api-reference/#tag/Positions, but if it uses the same logic I'll be forced to go straight to mysql and do external processing of the data