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

  • Home
  • SEARCH
  • 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 9048335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:07:59+00:00 2026-06-16T12:07:59+00:00

https://devcenter.heroku.com/articles/request-timeout 30 Seconds and a timeout error fires according to their documentation. I’m uploading

  • 0

https://devcenter.heroku.com/articles/request-timeout


30 Seconds and a timeout error fires according to their documentation.

I’m uploading and parsing a CSV file to save to my database. One of those files is 1.7MB in size and has 37000 rows.

This process takes a bit long to process, certainly more than 30 seconds.

What can I do in these cases? What options do I have?

require 'csv'

class DatabaseImporterController < ApplicationController
  def index
  end

  def import
    # Receive the uploaded CSV file and import to the database.
    csv_file = params[:csv_file].tempfile

    i = 0
    CSV.foreach(csv_file) do |row|
      # Structure for CSV file: Year, Make, Model, Trim
      if i > 0 then
        make = Make.find_or_create_by_name(row[1])
        model = make.model.create(:year => row[0], :name => row[2], :trim => row[3])
      end

      i += 1
    end
    redirect_to :action => 'list'
  end

  def list
    @models = Model.all
  end
end
  • 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-16T12:08:01+00:00Added an answer on June 16, 2026 at 12:08 pm

    Instead of processing your CSV file in the controller have it push a notification to a queue with the location of the uploaded file. Then have a worker dyno handle that processing.

    You’ll pay a little bit more, especially if you’re trying to stick with the free single dyno tier, but this is a scalable design (which is why I’d imagine there’s a 30 second timeout on HTTP processing).

    An alternative is to push the data directly into a table and execute a stored procedure asynchronously. This pushes the work off to Postgres to handle off the HTTP thread and may place your request under the 30 second time limit, though with larger files you may breech this cap anyway.

    Before you bother restructuring your entire application you’ll want to run a test to ensure that Heroku has not disabled libpq-asynch.

    The big cost here in your code above is Make.find_or_create_by_name which is invoking 37,000 separate – as per your example input – SELECT and possibly an INSERT for each row in your CSV. If libpq-asynch is not an option you’ll have to create a stored procedure that will perform this functionality in batches of 100 or 1000 rows at a time – that way your controller code isn’t making so many round trips to the database. Postgres supports arrays in the classical ordinal index style as well as arrays of row types so this is actually much less painful than it sounds.

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

Sidebar

Related Questions

I'm doing the Heroku walkthrough: https://devcenter.heroku.com/articles/django#prerequisites for python developers, and I get an error
I've read Heroku's documentation: http://devcenter.heroku.com/articles/custom-domains#wildcard_domains They say to add: To use with a custom
I'm following the Python/Flask tutorial on Heroku: https://devcenter.heroku.com/articles/python These are the steps I take:
ON MAC OS X 1.7.2 I tried following the instructions https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-postgres So I tried
I've followed the getting started guide to deploy a nodejs application to heroku: https://devcenter.heroku.com/articles/nodejs
I'm following the Heroku scala tutorial at https://devcenter.heroku.com/articles/scala I was able to get everything
I'm following a tutorial to create a scala web app with Heroku here: https://devcenter.heroku.com/articles/scala
I am a begineer with Node and Heroku. Was going through this link https://devcenter.heroku.com/articles/nodejs
I am trying to follow the instructions here: https://devcenter.heroku.com/articles/clojure-web-application Everything is going okay until
I've recently gone through the database migration process as outlined here: https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-postgres Now I'm

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.