suave icon indicating copy to clipboard operation
suave copied to clipboard

File upload fails, using several hundred MBs of RAM on Suave hosted WebSharper project

Open reneederer opened this issue 7 years ago • 5 comments

When uploading a file, the process memory usage quickly rises from ~100MB to over 1000 MB (and keeps rising). The server side function is never reached. This happens with a small file, with an empty text file, and even when no file is chosen. While hosting my WebSharper project on Owin, uploading files worked.

You can recreate the bug by creating a new Visual Studio project with the template "WebSharper 4 Suave-hosted Site". Then replace the Main() function in Client.fs with

    let Main () =
        div
          [ formAttr
              [ attr.method "post"
                attr.action "/about"
                attr.enctype "multipart/form-data"
              ]
              [ inputAttr
                  [ attr.``type`` "file"
                    attr.name "myFile"
                  ]
                  []
                buttonAttr
                  [ attr.``type`` "submit" ]
                  [ text "Upload" ]
              ]
          ]

reneederer avatar Jan 09 '18 14:01 reneederer

What version? We upload ~5 MiB files around the clock without rebooting the server for months.

haf avatar Jan 10 '18 09:01 haf

Suave Version: 2.2.1 WebSharper Version: 4.0.195.127 Target Framework: .NET Framework 4.6.1 Target F# runtime: F# 4.1 (FSharp.Core, 4.4.1.0)

reneederer avatar Jan 10 '18 12:01 reneederer

I am experiencing the same problem with Suave 2.2.1 and WebSharper 4.1.5.205. Is there any information on a fix or workaround?

edit: Same problem on Suave 2.3.0-beta3. It seems that process memory consumption will grow and grow until it runs out of memory. The request never reaches the WebSharper sitelet.

stevehv avatar Feb 10 '18 01:02 stevehv

Note that 100 mb is the default max upload size.

https://github.com/SuaveIO/suave/blob/master/src/Suave/Web.fs#L94

You need to increase this value in the configuration record to handle larger files.

On Feb 9, 2018 8:19 PM, "stevehv" [email protected] wrote:

I am experiencing the same problem with Suave 2.2.1. Is there any information on a fix or workaround?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SuaveIO/suave/issues/683#issuecomment-364613440, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIl_IWMBPjrcYUKJIoAGcJp7msWu_LMks5tTO6LgaJpZM4RX77d .

ademar avatar Feb 10 '18 07:02 ademar

Sorry I just realized this issue is probably a bug in the owin implementation.

On Feb 10, 2018 2:43 AM, "Ademar Gonzalez" [email protected] wrote:

Note that 100 mb is the default max upload size.

https://github.com/SuaveIO/suave/blob/master/src/Suave/Web.fs#L94

You need to increase this value in the configuration record to handle larger files.

On Feb 9, 2018 8:19 PM, "stevehv" [email protected] wrote:

I am experiencing the same problem with Suave 2.2.1. Is there any information on a fix or workaround?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SuaveIO/suave/issues/683#issuecomment-364613440, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIl_IWMBPjrcYUKJIoAGcJp7msWu_LMks5tTO6LgaJpZM4RX77d .

ademar avatar Feb 10 '18 07:02 ademar