Skip to content
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

Unable to upload large files >100mb consistently. #1158

Closed
mcolyer opened this issue Apr 28, 2024 · 1 comment
Closed

Unable to upload large files >100mb consistently. #1158

mcolyer opened this issue Apr 28, 2024 · 1 comment
Assignees

Comments

@mcolyer
Copy link
Contributor

mcolyer commented Apr 28, 2024

Setting .init.lua to:

local fm = require "fullmoon" -- (1)

ProgramMaxPayloadSize(1024 * 1024 * 500) -- 500MB
LaunchBrowser()

fm.setRoute("/", "/index.html")
fm.setRoute({"/api/upload", method = "POST"}, function(r)
  Barf("file.txt", r.params.multipart.file.data)
  return "File uploaded"
end)
fm.run()

Where index.html contains a multipart upload that POSTs to /api/upload. If you select a 100mb file and run redbean it works on the first upload attempt, fails on the second but then works on the third.

Here's the output:

D2024-04-27T21:46:05+019210:tool/net/redbean.c:6758:redbean:65217] (token) can't acquire accept() token for client
V2024-04-27T21:46:05+000069:tool/net/redbean.c:6767:redbean:65217] (srvr) accept 127.0.0.1:57448 via 127.0.0.1:8080
D2024-04-27T21:46:05+003892:tool/net/redbean.c:6426:redbean:65221] (stat) 127.0.0.1:57448 read 439 bytes
I2024-04-27T21:46:05+000839:tool/net/redbean.c:5972:redbean:65221] (req) received 127.0.0.1:57448 HTTP11 GET http://127.0.0.1:8080/ "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"
V2024-04-27T21:46:05+000425:tool/net/redbean.c:6195:redbean:65221] (rsp) 200 OK
D2024-04-27T21:46:05+000220:/zip/.lua/fullmoon.lua:61:redbean:65221] (fm) match 2 route(s) against '/'
D2024-04-27T21:46:05+000811:/zip/.lua/fullmoon.lua:61:redbean:65221] (fm) route '/' matched
D2024-04-27T21:46:05+000396:tool/net/redbean.c:6017:redbean:65221] (srvr) RoutePath("/index.html")
D2024-04-27T21:46:05+000261:tool/net/redbean.c:2764:redbean:65221] (srvr) ServeAssetPrecompressed()
V2024-04-27T21:46:05+000018:tool/net/redbean.c:6195:redbean:65221] (rsp) 200 OK
D2024-04-27T21:46:05+000275:tool/net/redbean.c:6357:redbean:65221] (stat) "/" latency r: 3,698µs c: 7,163µs
D2024-04-27T21:46:12.067860:tool/net/redbean.c:6426:redbean:65221] (stat) 127.0.0.1:57448 read 535 bytes
I2024-04-27T21:46:12+060332:tool/net/redbean.c:5972:redbean:65221] (req) received 127.0.0.1:57448 HTTP11 POST http://127.0.0.1:8080/api/upload "http://127.0.0.1:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"
V2024-04-27T21:46:12+000116:tool/net/redbean.c:6195:redbean:65221] (rsp) 200 OK
D2024-04-27T21:46:12+000037:/zip/.lua/fullmoon.lua:61:redbean:65221] (fm) match 2 route(s) against '/api/upload'
D2024-04-27T21:46:12+000179:/zip/.lua/fullmoon.lua:61:redbean:65221] (fm) route '/' not matched
D2024-04-27T21:46:12+000017:/zip/.lua/fullmoon.lua:61:redbean:65221] (fm) route '/api/upload' matched
D2024-04-27T21:46:12+114112:tool/net/redbean.c:6357:redbean:65221] (stat) "/api/upload" latency r: 174,847µs c: 6,342,644µs
D2024-04-27T21:46:13.450035:tool/net/redbean.c:6426:redbean:65221] (stat) 127.0.0.1:57448 read 535 bytes
I2024-04-27T21:46:13+006172:tool/net/redbean.c:5534:redbean:65221] (stat) 127.0.0.1:57448 payload slowloris with 15,597,204 unprocessed and 2 handled (1 workers)
E2024-04-27T21:46:13+000138:tool/net/redbean.c:2536:redbean:65221] (srvr) failure: 408 Request Timeout 127.0.0.1:57448 HTTP11 POST "127.0.0.1:8080" "/api/upload" "http://127.0.0.1:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"
V2024-04-27T21:46:13+000101:tool/net/redbean.c:6195:redbean:65221] (rsp) 408 Request Timeout
D2024-04-27T21:46:13+001372:tool/net/redbean.c:6329:redbean:65221] (clnt) could not synchronize message stream
D2024-04-27T21:46:13+000041:tool/net/redbean.c:6357:redbean:65221] (stat) "/api/upload" latency r: 7,825µs c: 7,557,848µs
D2024-04-27T21:46:13+000098:tool/net/redbean.c:5537:redbean:65221] (stat) 127.0.0.1:57448 connection closed with 3 messages handled
D2024-04-27T21:46:13+000015:tool/net/redbean.c:6813:redbean:65221] (stat) 127.0.0.1:57448 closing after 7,557,963µs
D2024-04-27T21:46:13.480368:tool/net/redbean.c:1311:redbean:65217] (stat) 65221 exited (0 workers remain)
D2024-04-27T21:46:13+000603:tool/net/redbean.c:1326:redbean:65217] (stat) resource report for pid 65221
 ballooned to 344,888kb in size
 needed 151,116us cpu (68% kernel)
 caused 86,403 page faults (100% memcpy)
 103 context switches (40% consensual)
 received 119 message and sent 3
D2024-04-27T21:46:14.752808:tool/net/redbean.c:6758:redbean:65217] (token) can't acquire accept() token for client
V2024-04-27T21:46:14+000039:tool/net/redbean.c:6767:redbean:65217] (srvr) accept 127.0.0.1:57449 via 127.0.0.1:8080
D2024-04-27T21:46:14+008759:tool/net/redbean.c:6426:redbean:65251] (stat) 127.0.0.1:57449 read 965,096 bytes
I2024-04-27T21:46:14+055632:tool/net/redbean.c:5972:redbean:65251] (req) received 127.0.0.1:57449 HTTP11 POST http://127.0.0.1:8080/api/upload "http://127.0.0.1:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"
V2024-04-27T21:46:14+000632:tool/net/redbean.c:6195:redbean:65251] (rsp) 200 OK
D2024-04-27T21:46:14+000267:/zip/.lua/fullmoon.lua:61:redbean:65251] (fm) match 2 route(s) against '/api/upload'
D2024-04-27T21:46:14+000951:/zip/.lua/fullmoon.lua:61:redbean:65251] (fm) route '/' not matched
D2024-04-27T21:46:14+000120:/zip/.lua/fullmoon.lua:61:redbean:65251] (fm) route '/api/upload' matched
D2024-04-27T21:46:14+118066:tool/net/redbean.c:6357:redbean:65251] (stat) "/api/upload" latency r: 176,543µs c: 184,403µs

DDOS mitigations have been disabled and I'm a little lost at this point about what to try next. I have noticed the slowloris lines in the output but am not sure where I can disable that. I checked all of the RLIMITs and they all seem to be effectively unlimited.

@pkulchenko pkulchenko self-assigned this Apr 28, 2024
@pkulchenko
Copy link
Collaborator

pkulchenko commented Apr 28, 2024

@mcolyer, I suspect this was fixed in e323527 (#737, which fixed #736), as there was indeed an issue with this error returned when a certain number of reads was exceeded. I'd try this on the current master (and I'd expect it to work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants