Thursday, March 15, 2012

Make scheduled jobs in heroku safer for your wallet.

I recently checked my current usage on Heroku to find that I had used a much higher than expected number of dyno-hours. The project CheckTheSock.com is a RC aviation website that provides some weather data. The forecast data is pulled every hour via FTP by a rake task that is run with a scheduled job in Heroku. Normally this takes around a minute to run and uses about 13 or 14 dyno-hours in a month. Less than half way through this month I found that it had already burned through over 200 dyno-hours.

After digging into the problem I found that the FTP connection was hanging for some reason. After a little research I came up with a solution that works pretty nicely and for more than just hanging FTP connections.

It turns out that ruby's standard library includes a library named Timeout which provides a way to terminate the execution of a thread. Using this library it is very simple to set a time limit for a block of code in a rake test.

task :task_that_takes_a_long_time_sometimes do
  Timeout.timeout(30) do
    #The code that takes a long time to run sometimes
  end
end

That will raise a Timeout::Error if the code takes longer than 30 seconds to run. The error will cause the rake task to exit, preventing unexpected dyno-hour usage.

33 comments:

Anna Schafer said...

So what do you think of what we are hearing here? Are you excited for this film and Debney's score?Executive Employers Review

e55y5 said...

Plagiarism Checker are wonderful tools to hit upon plagiarism in files. However, you need to remember the fact that they can not access password protected areas or some thing that isn't always in their databases. Try this to get all http://www.plagiarism-checker.me/

Maani kamili said...

I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time? Thanks for the post..

Digital marketing company in Chennai

Sowmiya said...


Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. thus it is really a good conclusion work.

Online Reputation Management

Unknown said...


this is really a very great blog. the information present in this blow will be very useful for us. thank you for sharing with us.
ROI Services in Chennai

Unknown said...


this is really a very great blog. the information present in this blow will be very useful for us. thank you for sharing with us.
ROI Services in Chennai

Unknown said...

This blog explains the details about changing the ways of doing that business. That is understand well and doing some different process. Provides he best output of others. Thanks for this blog.
Digital Marketing Company in Chennai

Shalini said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.

seo company in india

sathya said...

Excellent .. Amazing .. I will bookmark your blog and take the feeds additionally? I’m satisfied to find so many helpful information here within the put up, we want work out extra strategies in this regard, thanks for sharing..

Hadoop Training in Chennai

Base SAS Training in Chennai

Unknown said...

This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.

SEO Company in India

Unknown said...

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Your write up is a fine example of it.For more details about oracle fusion financial please check our website.

Oracle Fusion Financial Training Institute

Ramya Krishnan said...

Nice Blog, Thanks for sharing your best work.
Oracle DBA Training institute in chennai | Oracle DBA Training institute in velachery

Unknown said...

Interesting blog post.This blog shows that you have a great future as a content writer.waiting for more updates...
Digital Marketing Company in India

Lauren Gottlieb said...

Wow, cool post. I’d like to write like this too – taking time and real hard work to make a great article… but I put things off too much and never seem to get started. Thanks though. Website Design Kansas City

IMF said...

I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks discounts vouchers

fortnite said...

It was a very good post indeed. I thoroughly enjoyed reading it in my lunch time. Will surely come and visit this blog more often. Thanks for sharing. Hostgator 60 off

NOOR said...

I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!. Webmetrix Group Best SEO Agency

pixel studios said...

Stunning post. I really impressed. Thank you for your sharing.
Best Digital Marketing Company In Chennai
Ecommerce Website Development Company In Chennai

fortnite said...

I will look to see if they're matching what is listed in the Google My Business listing and seek to fix any inconsistencies in those listings. hop over to this site Since the traffic that you get is more qualified, you end up spending less.

Ruhi Sukhla said...

BA Exam Result - BA 1st Year, 2nd Year and 3rd Year Result

Bsc Exam Result - Bsc 1st Year, 2nd Year and 3rd Year Result

TNK Design Desk said...

Thank you so much for these kinds of informative blogs.
we also providesseo services
web company in delhi
web desiging company
web design & development banner
web design & development company
web design & development services
web design agency delhi
web design agency in delhi
web design and development services
web design companies in delhi
web design company delhi
web design company in delhi
web design company in gurgaon
web design company in noida
web design company list
web design company services
web design company website
web design delhi
web design development company
web design development services
web design in delhi
web design service
web design services company
web design services in delhi
web designer company
web designer delhi
web designer in delhi
web designers delhi
web designers in delhi
web designing & development
web designing advertisement
web designing and development
web designing and development company
web designing and development services
web designing companies in delhi
web designing company delhi
web designing company in delhi
web designing company in gurgaon
web designing company in new delhi
web designing company in noida
web designing company logo

Tripu Design said...

Very useful and informative blog. Thank you so much for these kinds of informative blogs.
We are also a graphic services in gurgaon and we provide the website design services,
web design services, web designing services, logo design services.
please visit our website to see more info about this.
Freelance Graphic Designing
Freelance Catalogue Designing in delhi
Freelance Catalogue Designing in gurgaon
Freelance Brochure Designing
Freelance Label Designing
Freelance Banner Designer
Freelance Poster Designer
graphic design services in delhi
graphic design services in gurgaon
Freelance Catalogue Designing in delhi
Freelance Catalogue Designing in gurgaon
Freelance Brochure Designing
Freelance Label Designing
Freelance Banner Designer
Freelance Poster Designer
graphic design services in delhi
graphic design services in gurgaon
Freelance Catalogue Designing in delhi
Freelance Catalogue Designing in gurgaon
Freelance Brochure Designing
Freelance Label Designing
Freelance Banner Designer
Freelance Poster Designer
graphic design services in delhi
graphic design services in gurgaon
Freelance Catalogue Designing in delhi
Freelance Catalogue Designing in gurgaon
Freelance Brochure Designing
Freelance Label Designing
Freelance Banner Designer
Freelance Poster Designer
graphic design services in delhi
graphic design services in gurgaon
graphic designer in gurgaon
freelance graphic designer in gurgaon
freelance graphic designer in gurgaon
freelance graphic designer in gurgaon
freelance logo designer in gurgaon
freelance logo designer in gurgaon
freelance web designer in gurgaon

TNK Design Desk said...

Very useful and informative blog. Thank you so much for these kinds of informative blogs.
who provides seo services, web development services, logo design services, graphic design ,
digital markeing and all kind of web design, development and digital marketing services.
website designing in gurgaon
best website design services in gurgaon
web company in delhi
web desiging company
web design & development banner
web design & development company
web design & development services
web design agency delhi
web design agency in delhi
web design and development services
web design companies in delhi
web design company delhi
web design company in delhi
web design company in gurgaon
web design company in noida
web design company list
web design company services
web design company website
web design delhi
web design development company
web design development services
web design in delhi
web design service
web design services company
web design services in delhi
web designer company
web designer delhi
web designer in delhi
web designers delhi
web designers in delhi
web designing & development
web designing advertisement
web designing and development
web designing and development company
web designing and development services
web designing companies in delhi
web designing company delhi
web designing company in delhi
web designing company in gurgaon
web designing company in new delhi

Gerardoavery cristian said...

Page content is central to all the on-page SEO processes. their video channel Promote content to website visitors by retargeting, promoting it to people within your area (note: it is a must to use great content, so if you have not created such, start now) and utilize all possible advertising tools to get likes, views and shares for your content.

Watson Henry said...

If the server that handled the client's original request becomes unavailable, subsequent requests can be automatically routed to another server without the client knowing or caring Toronto IT Support

Nisha Verma said...

Best Job Courses after graduation course 100% Jobs CIITN

Job Guaranteed Professional courses after graduation Degree with job placement | CIITN

Courses after Bcom | Software engineer courses | 100% Jobs |CIITN

Guaranteed jobs near me.? | 100% Placements | CIITN

Software developer courses | 100% Placements | CIIT NOIDA

Software development courses training |100% Jobs| CIIT NOIDA

Best Job Courses after graduation course | 100% Jobs |CIITN

Job oriented short term courses after graduation | 100% Pleacements | CIITN

short term job oriented courses after graduation in India

6 month industrial training Institute |100% Placements|CIITN

Nisha Verma said...

Courses which guarantee a job

Course with job guarantee

Courses that guarantee jobs

it training with job guarantee

100 job guarantee

job guarantee courses

job guarantee courses

Arena Infosolution said...


Arena Infosolution is the best company for the Digital Marketing Internship in Jaipur. Our company offers an internship that gives a good job after completion of the internship which gives a path to your career and makes your future bright in digital marketing.

We offer Digital Marketing Internship in Jaipur that lays a path that drives you to the world of opportunities. Here you will get a chance to learn the skills that will be helpful for building a remarkable career in Digital Marketing.

For more info:-
Contact : +91-8094351234, 8955536801
https://arenainfosolution.com/digital-marketing-internship-in-jaipur/

mary Brown said...

IEEE Final Year projects Project Center in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

JavaScript Training in Chennai

JavaScript Training in Chennai

The Angular Training covers a wide range of topics including Components, project projects for cseAngular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

naksha dekho said...

hy thanks for sharing useful information.very helpfuluseful

naksha dekho said...

hy thanks for sharing this information.very helpful and useful thanks

naksha dekho said...

hy thanks for sharing this information.very helpful and useful thanks

naksha dekho said...

nakshahomemap@gmail.com it is really helpful. the information in this article is satisfied me. And the information it is very interesting. Thanks for this kind of article. thanks