rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
333 stars 12 forks source link

Slowness and random crashes when sending multiple image files #44

Closed lpil closed 7 months ago

lpil commented 7 months ago

Hello!

I'm using Mist and Wisp's https://hexdocs.pm/wisp/wisp.html#serve_static to serve some images on Fly.io.

The images are not very large

-rw-r--r--  1 louis  staff   692K  2 Apr 22:31 belltent.jpg
-rw-r--r--  1 louis  staff   548K  2 Apr 22:31 boat.jpg
-rw-r--r--  1 louis  staff   591K  2 Apr 22:31 entrance.jpg
-rw-r--r--  1 louis  staff   685K  2 Apr 22:31 firepit.jpg
-rw-r--r--  1 louis  staff   614K  2 Apr 22:31 flag.jpg
-rw-r--r--  1 louis  staff   499K  2 Apr 22:31 roundhouse.jpg
-rw-r--r--  1 louis  staff   646K  2 Apr 22:31 tea.jpg
-rw-r--r--  1 louis  staff   516K  2 Apr 22:31 tipi.jpg

When I load the image that has them they load slowly, and a random 2 to 4 of them will fail with a 500.

If I check the logs I get the error {case_clause,'$busy'}. I was unable to find the atom '$busy' anywhere in the OTP codebase or in an internet search.

The problem doesn't seem to occur locally. I'm not sure what the issue could be.

If I make rapid requests to a single image it doesn't fail or load slowly. It seems to be something to do with having a browser concurrently loading multiple images?

Thanks, Louis

lpil commented 7 months ago

I believe this to be some interaction with SQLite and Fly and Mist. Outside of Fly it works, and if I don't send any files it works.

edit: The slowness of loading happens outside of Fly too, though less pronounced. I have not had it crash outside of Fly yet.

varnerac commented 7 months ago

$busy atom: https://github.com/mmzeeman/esqlite/blob/89366d461ef90c0923463ae18c65e579fe63dc5e/c_src/esqlite3_nif.c#L825

philipgiuliani commented 7 months ago

I've started to get the "Busy" messages from SQLite (in an Elixir project) when hosting the DB on a NFS Mount (which is officialy not supported by SQLite). I think this has nothing to do with mist.

lpil commented 7 months ago

Thank you all!