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

Backend is crashing every few days with "Too many files" errors #7

Open
joshkunz opened this issue Aug 8, 2021 · 0 comments
Open

Comments

@joshkunz
Copy link
Owner

joshkunz commented Aug 8, 2021

Every few days, Gotham starts throwing these errors:

 ERROR gotham > Socket Error: Too many open files (os error 24)
 ERROR gotham > Socket Error: Too many open files (os error 24)
 ERROR gotham > Socket Error: Too many open files (os error 24)
 ERROR gotham > Socket Error: Too many open files (os error 24)

For every connection request (typically every prometheus scrape). This Gotham issue suggest that it's due to half-open connections, likely left by Prometheus, makes sense. It points to Hyper, the underlying HTTP framework as the culprit. Searching through Hyper's issues, it seems like there's plenty of instance of people running into similar errors. For example this issue. I'm really not sure what's going on here, since searching around it looks like nobody else is having trouble with Prometheus leaving half-open connections. Seems like it's likely some kind of cleanup problem in Gotham/Hyper.

This is pretty Yikes too me. I would expect any major HTTP (or server library in general) to be able to deal with half-open connections since it's a juicy DoS opportunity. As I see it, I have a few options:

  1. Add a /healthy endpoint to the server + write a wrapper to poll it and re-start the server if it gets borked.
  2. Figure out what the issue within Gotham/Hyper is and fix it.
  3. Try to switch to something like actix.rs, that is not based on Hyper, and see if that fixes things.
  4. Re-write the backend in another language, like Go.

I don't really like any of these options, so I'm not sure what to do.

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

1 participant