Repository navigation
|
While I'm trying to overcome the 64KiB limit based on the discussion at reactphp/http#412 I found out that this is not possible with the current Middleware implementation by framework-x. Framework X bypasses the default ReactPHP Any idea how to solve this issue? |
Replies: 3 comments 7 replies
|
@HLeithner Excellent question! There's indeed a 64 KiB default limit for the request body when using the built-in web server as covered in the documentation https://framework-x.clue.engineering/docs/api/request/#uploads You're right that this can indeed by configured on the underlying The main reason why this wasn't done yet: The request body will always be kept in memory to avoid any disk I/O. This means that for large request bodies, we could potentially end up storing megabytes or even gigabytes in memory for incoming requests. What do you think about this, I wonder how we could handle this? |
|
This is an absolute dealbreaker for me - I need to handle quite a lot uploaded files, mainly documents but also user avatars etc. all of which are way bigger than 64KB. Even worse I found out about this limitation only after investing quite a lot time into refactoring the current project to ReactPHP and then lately using Framework X. While being able to increase the limit just like in ReactPHP would definitely help a bit, the memory usage indeed becomes an issue very quickly. My project runs on several (auto-scaling) "Cloudlets" where the smallest instance begins with just 128 MB of RAM. The tiny footprint + impressive performance of the built-in ReactPHP webserver and the resulting tiny Docker images seemed to be a perfect fit... Unfortunately, I don't know enough about the internals and aforementioned limitations of the request parser to propose a solution... I have a feeling that being able to pipe the request body as a stream through a handler/middleware that on detecting the start of a file fires an event where one could handle the file (again, as a stream) and e.g. write/pipe it to disk would be a nice way. |
|
@HLeithner @pfk84 Just merged #311 which exposes this as an experimental option: you can now pass ReactPHP HTTP middleware such as |
@HLeithner @pfk84 Just merged #311 which exposes this as an experimental option: you can now pass ReactPHP HTTP middleware such as
StreamingRequestMiddlewareto the built-in web server to raise the 64 KiB limit, together with a concurrency limit to keep memory usage in check. See https://framework-x.org/docs/best-practices/deployment/#request-body-limit, this will be part of the upcomingv0.18.0release 👍