Don’t Let Your Rails App Crash Under Pressure
If you use Active Record to work with databases, you must be cautious as a backend Ruby developer when querying them.
Generating too many queries can cause problems, even though the N+1 problem is well-known. It is challenging to outsmart ORMs every time. Thus, we need an automated way to identify the problem. Like most of us, I have used Bullet in development and staging environments for the past few years.
Without appropriate loading tests, there is a risk of a system crash during the most critical time.
Load testing is a test type that answers the question of how many simultaneous users the system can handle for a given period.
For instance, thousands of users may try to place an order if you launch a top-rated product on your website. Stress testing focuses on how the system behaves when the user limit is hit rather than verifying the number of users the system can handle.
Performance testing is the parent of stress and load testing.
Performance tests aim to get specific metrics that can help us enhance an application’s code. These metrics are necessary to interpret the test output and decide whether to change the code.
The type of metrics that are obtained can vary depending on the testing tool. But, they can be grouped into a set of standard metrics, which include:
- Response time is the time between the request and the browser’s response. It indicates how long the user has to wait before receiving the requested information. It is also sometimes referred to as process time.
- Memory usage: This metric indicates the memory used for a given request.
- Object allocation: A high memory allocation can lead to high memory usage and longer response times. This metric can help identify the location in the code where many objects are being allocated so it can be inspected immediately.
JMeter is a Java-based program that can be installed on any operating system.
The configuration process includes the following steps:
- Adding the thread group: This step specifies the number of users and the duration of each user’s visit to your website.
- Configuring HTTP request: This step specifies the endpoint JMeter should hit.
- Setting the metrics of interest.
A load test can identify your application’s pain points. Then, you can perform a stress test to observe your application’s behavior under the user’s limit. Without proper load testing, there’s a risk of a system crash during critical times.
Experiment with the number of users and other configuration options to observe how your application behaves under load. A load test can identify your application’s pain points, and then you can perform a stress test to observe your application’s behavior under the user limit.