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

StaticFilesHandler freezing #308

Closed
jolhoeft opened this issue Jan 4, 2016 · 9 comments
Closed

StaticFilesHandler freezing #308

jolhoeft opened this issue Jan 4, 2016 · 9 comments

Comments

@jolhoeft
Copy link
Member

jolhoeft commented Jan 4, 2016

I have a small webpage/app that is freezing on loading some static content. There are two css and four js files being loaded. The freeze does not always occur, but when it does, it is usually in the last file listed in the header of the webpage. I am not seeing any freezing with the dynamic content of my web app, just loading the preliminary static files.

The frozen download sometimes times out, or loads after a minute or more (75 seconds on my most recent repro). I've turned the log level to debug, and don't see any messages from nickel or hyper about the download for the first 75 seconds, then it seems to complete in the expected time (a few milliseconds).

I can regularly reproduce this with Firefox, and have reports of it on Chrome, too.

@Ryman
Copy link
Member

Ryman commented Jan 4, 2016

This sounds related to keep-alive, as the default timeout is currently 75 seconds:

keep_alive_timeout: Some(Duration::from_secs(75))

What version of rustc are you compiling with? Do you have a public link to repro with?

@therealbstern
Copy link

I'm working with @jolhoeft and we're using rustc 1.4.0 (8ab8581f6 2015-10-27), which I built. I don't think we have any public links right now.

@jolhoeft
Copy link
Member Author

jolhoeft commented Jan 4, 2016

I've also build it with rustc 1.5.0 (3d7cd77e4 2015-12-04), and see the same issue.

I see in the logs it appears we have only five threads handling connections (2016-01-03T19:27:38-08:00 DEBUG hyper::server - threads = 5). If all the threads were used, I could see connections blocking. Is there an easy way to increase the number of threads?

@jolhoeft
Copy link
Member Author

jolhoeft commented Jan 6, 2016

Further investigation revealed it was a thread exhaustion issue as discussed in the docs for Nickel::keep_alive_timeout, and hyperium/hyper#368. Disabling keep-alives has resolved the issue while we are doing small scale testing, but I am concerned about the performance impact when we scale to higher volumes.

@Ryman
Copy link
Member

Ryman commented Jan 7, 2016

Thanks for investigating! Yeah I think raising the threadpool amount, or lowering the keep-alive should be the fix here. Perhaps the nginx default of 75 seconds is unreasonably high for us as we don't currently have async i/o, did a lower value help you at all with this?

Is there an easy way to increase the number of threads?

I don't think we've actually exposed this, but I'd be happy to review a PR to add it, or I'll look to add it soon if you don't have the time!

@jolhoeft
Copy link
Member Author

I didn't try a lower values, just disabling them completely. Our application drives an XMLHttpRequest every second or so, so a lower keep alive wouldn't be very helpful. We will be migrating to websockets for that part though.

I'll try to create a PR in the next couple days. We don't have an immediate need for this, but in general being able to tune thread counts along with keep alives seems necessary.

@jolhoeft
Copy link
Member Author

PR #309 submitted

@Ryman
Copy link
Member

Ryman commented May 10, 2016

We've released 0.8.1 with a change based on the PR mentioned above, so I'm going to close this now. Please feel free to reopen if you continue to have issues.

@inv2004
Copy link

inv2004 commented Dec 6, 2017

I have the lastest version of rust and nickel - and situation is the same.

All my app - is just static content from directory: ~4 files is ok, and 5th is hang for ~15secs.
Iron and Rocket are ok in the same situation.

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

4 participants