Compress plain GPX uploads with gzip#7124
Conversation
|
If the majority of downloads are of the uncompressed file, am I right to think that this will translate in costs to the infrastructure? Compute of the server-side decompression and traffic. If so, can this be significant enough to be a problem? Should the "download gpx" link be slightly more "hidden" to avoid this situation? Just an additional click or something like that. |
|
@pablobm you're right that this could add real bandwidth and CPU cost. I looked into it a bit more. I think we can avoid it without hiding the link, using the Browsers always send Accept-Encoding: gzip, so this happens on its own and the user still gets a normal .gpx I tested it with curl --compressed, which behaves like a browser: If a client doesn't support gzip, the server unzips the file and sends it plain, same as today, so nothing breaks. Other formats work the same way too: we still serve whatever the user uploaded. And since the backend decides this from the request header, one download link is enough now, so I kept just one. |
pablobm
left a comment
There was a problem hiding this comment.
Serving it directly sounds like a good idea! From a quick online lookup, it seems that even MS Edge should support it 👍
|
I changed the logic a bit. There is now a The user still gets a plain GPX either way. If their client accepts gzip, the server sends the gzip and the client unzips it. If not, the server unzips it first. And the CPU usage already happens today when clients request data.gpx, because the server unzips every file requested with .gpx. |
This PR compresses plain GPX files before they go to S3. This should cut a large part of the size of plain GPX files.
Files that are already compressed (gzip, bzip2, zip, tar) are left as is.
For new uploads, the file comes back as .gpx.gz, no longer as plain GPX. The problem is for Windows users, where .gz is not supported unless they install 7-Zip. To handle this, I have added two links to download . One gives the plain GPX and the other gives the compressed file. I did not add new decompression code. I reused the xml_file function that already decompresses the trace, and linked the plain GPX option to it.
Results:
Ref: #4188
cc. @1ec5