zero-divisor
zero-divisor

Reputation: 600

Timeouts in Rails/Nginx -- Best Practices

I'm having working on a Rails application that is supposed to run on an Nginx server. Depending on the input, the application may take very long to process the requests (or hang up in case of bugs), so I want to prevent processes from running forever. Apart from the Nginx configuration, which ensures that the client gets a timeout signal, I think I still may have to make sure that my app stops working on those requests. Where should this be handled? Within my Rails app (using Timeout/Thread from std-lib) or externally (killing processes)?

Upvotes: 2

Views: 793

Answers (1)

Abe Voelker
Abe Voelker

Reputation: 31564

I usually do this at the Rack layer using Rack::Timeout.

# config/initializers/timeout.rb
Rack::Timeout.timeout = 10  # seconds

Upvotes: 1

Related Questions