-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pulling media files from server with 1gb of RAM fails through direct API call or export generation #297
Comments
This seems pretty clearly related to memory although it's confusing that Digital Ocean doesn't see RAM usage above 80% for the QA server. We should describe this case in the documentation and help users recover (by adding RAM?). It would be helpful to know more about what conditions are likely to lead to this outcome. I initially thought it was driven by the largest media file but my experimentation suggests that's not the case. Does it have to do with the total size of media? The submission count? It almost feels like media does not start streaming until the CSV is generated. Is that possible? As I add more submissions, I see nothing happening for a while and then a quick download. |
yes, that's correct: the root table is the first stream inserted into the zip so it's the first thing over the wire. |
And so everything else for the export including all media has to fit in memory? |
no. there is backpressure, managed by node stream internals.
… On Oct 10, 2020, at 12:48, Hélène Martin ***@***.***> wrote:
it's the first thing over the wire
And so everything else for the export including all media has to fit in memory?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Does this mean that the root table must be /started/ for the zip to start being delivered but in principle, media files should be inserted as they are processed? Right now it seems like there's a threshhold of total media file size beyond which the server crashes and nothing ever gets sent. EDIT: I get a server with 1gb of memory to run out of RAM when pulling from Briefcase which uses the attachment endpoint. Both pulling form the attachment endpoint and the export zip work with 1gb of added swap. There's 400mb of swap used to produce a 115mb zip and again a long pause before anything is transmitted. |
solutions here are imprecise. i can only limit my results from the database by number of rows, not total size in the stream buffer. so when we get blobs to stream i set it to a number that is not likely to ever run out of memory given the number of entries (i think it's like 4 or 8 or something pretty tiny), but it can still happen. either way, it is not true that the media attachments all sit around in node memory. that's what the backpressure's for. the small number of blobs should just sit until the main data is done processing, then the rest of the blobs come in. it just apparently isn't good enough. |
once we insert streams into the archives they are there in that order. we can't "insert" media files midway. |
I did another trial with ~1.5mb images. The export RAM utilization was roughly the same between 1000 and 2000 submissions. When the download starts, there's a spike of about 400mb in memory usage (same as with original scenario) and then that holds steady. In htop, see 8 processes with each roughly the same RAM usage. Seems that's the 8 rows @issa was talking about and I think it's all seeming consistent and explainable. I'm surprised that each row requires so much RAM but for most contexts it shouldn't matter. One thing I'm not clear on is whether each attachment does need to be able to be held entirely in memory. That is, if there's one 500mb attachment, will the process handling it need 500+mb of memory? I vaguely remember someone saying they couldn't export because their audit file got really big but I'm not immediately finding it. Do you know, @issa-tseng? This is also something I could try if we'd rather see how it looks for real. |
We recently found out that we were affected by brianc/node-postgres#2240 which has a big effect on media performance. I haven't verified these exact scenarios with the patch but given what I have tried I'm pretty sure that the behavior is much better now. |
Attempting to export submissions for https://test.central.getodk.org/#/projects/188/forms/all-widgets/submissions produces a 45byte, corrupt zip (presumably empty).
node
andpostgres
go upPossible actions:
Possibly related service log though I don't see it happening with every failed request:
The text was updated successfully, but these errors were encountered: