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

Unicorn timeouts on many requests #82

Closed
pavel-clarityhk opened this issue May 11, 2015 · 1 comment
Closed

Unicorn timeouts on many requests #82

pavel-clarityhk opened this issue May 11, 2015 · 1 comment

Comments

@pavel-clarityhk
Copy link

During testing, discovered that Unicorn would time out (15s timeout) when presented with a lot of CORS requests using this gem. Calling with jQuery from a different machine on the local network on a local server, when doing a loop of even 10 async requests, Unicorn would stall, then restart the workers, and receive 10 OPTIONS and 10 GET requests. When calling manually at a lower rate, everything is fine.

At the same time, the app can handle thousands of non-CORS requests via curl without a hitch. Any ideas what can be going wrong? How high of a load can this middleware handle? I've implemented it with only the steps described in the readme (without explicit routes for OPTIONS, it works) by adding this to application.rb:

    config.middleware.insert_before 0, "Rack::Cors", :debug => true, :logger => (-> { Rails.logger }) do
      allow do
        origins 'http://localhost:3000'

        resource '*',
          :headers => :any,
          :methods => [:get, :post, :delete, :put, :options],
          :max_age => 0,
          :credentials => true
      end
    end

The request call looks like this:

      $.ajax({
        url: 'http://localhost:7000/user/',
        method: 'GET',
        dataType: 'json',
        headers: {
          'Accept': 'application/vnd.myapp.v1',
          'Authorization': 'w2z_UseVMZbtrzqogj1n'
        },
        success: function(e) {
          console.log(e);
        }
      })

Has anyone had a similar problem?

UPDATE:
Unicorn actually has trouble responding even to one request. Often it would take a few seconds until anything is even seen in the log, but sometimes it would even exceed 15 seconds. Disabling concurrency didn't solve the problem.

With Puma, everything is fine and snappy so far. I will actually use Puma in production so it seems fine for me, but leaving this here in case someone runs into problems with Rack::Cors and Unicorn.

@cyu
Copy link
Owner

cyu commented May 7, 2020

I'm closing this issue because there hasn't been any activity on this issue in a while.

If you're still having problems. Please create a new issue and provide the specifics.

@cyu cyu closed this as completed May 7, 2020
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

2 participants