Viji
Viji

Reputation: 2629

Heroku Request timeout issue, - Any other alt Solution?

I have the dev set up of Heroku which uses Professional 1X dyno ($25) and for the backend the app uses MongoLab.

The problem is more than the actual page load, frequently I'm getting Request timeout error. Its so annoying.

My Local code connecting to MongoLab service works perfectly without any issue with the same rails environment setup.

Log:

2015-09-19T05:58:55.478168+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path=“/pro/busi/3" host=appname.herokuapp.com request_id=637b8ed8-f85c-4bf3-ae01-1d81f4495bed fwd="73.170.78.112" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0

2015-09-19T05:59:26.347172+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=appname.herokuapp.com request_id=815dc81d-6adc-4aca-b30d-f7631d935f7b fwd="73.170.78.112" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0

I'm planning to move from heroku to another web hosting. Can anyone please let me know the system requirement for Ruby on rails + mongodb configuration for production setup / another web hosting solution?

Please advise.

Upvotes: 1

Views: 1107

Answers (2)

bbozo
bbozo

Reputation: 7311

6000 AR records is a lot of memory - those are some pretty heavy objects in Rubyland, it's possible your workers get bloated, and then killed when they go over the heroku limit, and the timeout you experience is while you wait for them to get respawned,

try using ActiveRecord::Batches.find_each in the view and see what happens, does the problem go away with lower batch sizes (around 200 for example)?

Check out your memory consumption logs, see if they spike after you do ctrl+R four times on that page.

EDIT, as for alternatives... You could always set up your own EC2 instance, but I try not to get into sysadmin area. The problem is probably not just heroku, there's also something about your app rubbing it wrong and worth investigating,

how many dynos do you have running?

Upvotes: 2

korada
korada

Reputation: 586

If you are just looking for an alternative to Heroku, there are many which you can easily find by googling 'heroku alternatives'. For example: https://www.engineyard.com

But you might run into the same problem there also if the issue is with your code.

With limited information you provided one can only do some guesswork. Anyway here are some suggestions you can try while on Heroku:

  1. Avoid N+1 queries
  2. Paginate if pulling large number of records. Why would anyone wants to see 6000+ records on one page anyway?
  3. Set up New Relic if you have not already done so. Monitor the response time.
  4. Try 2x dyno and see if that solves problem.
  5. Which app server are you using in production? If it is Unicorn, review the settings and make sure that you are not allocating too many processes.

Coming back to Heroku vs others, unless you are an experienced DevOps person, I recommend to go with Heroku initially since it is very easy to deploy on and manage the infrastructure.

Upvotes: 2

Related Questions