Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:34:04+00:00 2026-06-17T08:34:04+00:00

Solution I am switching to unicorn in development mode. One worker process for each

  • 0

Solution

I am switching to unicorn in development mode. One worker process for each level of recursion is needed to prevent the deadlock situation, so I am running with 2 worker processes.

Problem

I am working on the Thin server in my development environment. I use port 3000 (the default in dev environment). My problem is getting the server to make requests to itself.

Let’s say I have the following controller:

# app/controllers/recursions_controller.rb
class RecursionsController < ApplicationController

    # /recursions
    def index

        # synchronously call recursions#show
        RestClient.get("http://localhost:3000/recursions/1") 

        # finish!
        render :text => 'index'

    end

    # /recursions/:id
    def show

        # finish immediately
        render :text => 'show'

    end

end

Here is the corresponding route:

# config/routes.rb
resources :recursions

Here is output from the request log when I initially request recursions#index:

[INFO] 2013-01-15 12:09:05 -0800 Started GET "/recursions" for 127.0.0.1 at 2013-01-15 12:09:05 -0800
Processing by RecursionsController#index as HTML
Completed 500 Internal Server Error in 60049ms

[FATAL] 2013-01-15 12:10:05 -0800 RestClient::RequestTimeout (Request Timeout):
  app/controllers/recursions_controller.rb:8:in `index'
  Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
  Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
  Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.4ms)

[INFO] 2013-01-15 12:10:05 -0800 

[INFO] 2013-01-15 12:10:05 -0800 

[INFO] 2013-01-15 12:10:05 -0800 Started GET "/recursions/1" for 127.0.0.1 at 2013-01-15 12:10:05 -0800
Processing by RecursionsController#show as XML
  Parameters: {"id"=>"1"}
  Rendered text template (0.0ms)
Completed 200 OK in 7ms (Views: 5.5ms)

I suspect what is going on here is some kind of deadlock situation. Request A cannot return until request B returns (recursive ordering, can’t help it), but request B cannot be processed until request A returns (apparent limitation built into my webserver?). The deadlock is resolved when RestClient times out, causing an exception and terminating request A with a 500. Only then is request B handled, though it’s moot at this point.

It seems to me like my webserver cannot handle concurrent requests. That said, here are my questions:

  1. Is there a webserver I can switch to in my dev environment that is not limited this way? We use Unicorn in production which can spawn multiple worker processes and therefore handle concurrent requests, but Unicorn seems too heavy for a dev environment. The same thing that makes Unicorn a solution to my problem could make it difficult to read the log output. This is my last resort solution.

  2. Is there a tricky way to make a request to the Rails/Rack frameworks that circumvents the apparent concurrent request limitation?

  3. Can anyone provide me with docs stating this limation explicitly? I don’t know if it’s a limitation inherent to all single-process Ruby on Rails webservers or just Thin.

Note: This is just a toy problem to demonstrate the blocking issue I am having. If you need to know the actual reason for this, it is that I am moving some HTTP services from another part of our infrastructure into our RoR app. Our RoR app consumes these service at many different points in our code, so I am trying to leave the client code for these services untouched and only change the implementation. That means making circular HTTP requests. This will be optimized at a later date, when everything has stabilized.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:34:06+00:00Added an answer on June 17, 2026 at 8:34 am

    You are correct that by default your app will only process one request at a time. This limitation is implemented by the Rack::Lock middleware – it will be there no matter what webserver you use.

    You can change this by calling config.thread_safe! in the appropriate environment.rb file. However rails’ development mode code reloading is not thread safe and is disabled by this setting, which makes it not really usable in development. Exactly what config.thread_safe! does is described in the rails configuration guide.

    passenger, pow, unicorn all make it easy to run multiple instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Solution: API 11 is needed see answer below! Easy Question: After downloading a File
Solution at end of this post. By default the time is set to one
I'm looking at switching to a new unified logging solution for use in our
I'm thinking of switching to cassandra from my current SQL-esque solution (simpledb) mainly due
After each build, Visual Studio 2012 switches from the Solution Explorer to the Code
Possible Duplicate: How does XOR variable swapping work? I found a solution to switching
Thinking about a solution to my previous question about switching between numerical and analytical
Ever since switching from TABLE-layout to DIV-layout, one common problem remains: PROBLEM : you
solution:[a-zA-Z0-9.!#$%&'*+-/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)* is a good choice I am using a regular expression like the below
SOLUTION Make sure in the plist that the storyboard name is listed as the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.