How can I simulate load/traffic on my local machine

1k Views Asked by At

I have an application that is meant to check the status of text messages and resend same, if failed, but each time after I restart it on Heroku, it works well for about 15 minutes, before it crashes with the following error: ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)):

This I suspect is being caused by the high number of hit to the application endpoint.

I am trying to reproduce this error locally on my computer, so I won't need to have to push changes each time before I can know if it works or not.

could anybody point me in the right direction to take?

I am thinking of googling for something like stress testing, or load testing

FYI: I am using rspec for my testing

2

There are 2 best solutions below

0
On

You can use some load testing tool, that works from the console, to test your app on localhost:

https://github.com/tsenart/vegeta

https://github.com/lubia/sniper

0
On

I don't know if you've already looked through it, but the Rails docs have a pretty good guide on performance testing: http://guides.rubyonrails.org/v3.2.13/performance_testing.html

The benchmarker section might be particularly useful if you want to hit an ActiveRecord query a number of times: http://guides.rubyonrails.org/v3.2.13/performance_testing.html#benchmarker