How to Install Stress on Amazon Linux 2023

How to Install Stress on Amazon Linux 2023

How to Install Stress on Amazon Linux 2023

Stress and stress-ng are both stress testing utilities and they have different strengths and weaknesses. You can use them to stress/load test our Amazon Linux 2023 EC2 Instance. For that, you can install stress or stress-ng on your Amazon Linux 2023.

Dear Reader, I hope you are doing amazing today. In my last few posts, I have shared with you how to install GitAnsibleNginxDockerJava, Apache, MariaDB, MySQL, Jenkins, PHP, Python etc. on Amazon Linux 2023 or AL2023 EC2 Instance.

In this article, we’ll discuss how to install Stress on Amazon Linux 2023 EC2 instance.

So are you ready?

Alright, let’s start.

Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.

Background on Stress and Amazon Linux 2023(AL2023)

Stress: Stress utility is a software application that is used to test the stability of a system by generating a large amount of load on the system.

For example, stress utility can generate CPU/Memory/Disk stress on your EC2 so that you can test certain situations like autoscaling.

  • It will help you spike the CPU/Memory utilisation of an EC2 instance.
  • You can install stress or stress-ng on your EC2 instance
  • Then you can run a command to put the configurable amount of stress

Amazon Linux 2023: Amazon Linux 2023 or AL2023 is the next-generation Amazon Linux AMI provided by AWS. It is rpm-based and optimized for the cloud. It is designed with the latest Linux innovations to deliver high-performance and stable Linux systems.

Prerequisite

Alright, before you install Stress on your Amazon Linux 2023 or AL2023 EC2 instance, You need to have an EC2 instance up and running.

Here is how you can launch an Amazon Linux 2023 easily-

Additionally, if you don’t have a free tier account, check out how to setup a free tier AWS account in right way. Having said that, don’t forget to set up a cost budget to avoid last-minute billing shocks.

Steps to Install Stress on Amazon Linux 2023 Instance

  1. Connect to your Amazon Linux 2023 Instance
  2. Run System Update
  3. Search for Stress Utility on Amazon Linux 2023
  4. Install Stress on Amazon Linux 2023
  5. Verify Stress Installation
  6. Stress your EC2 CPU
  7. Uninstall Stress from Amazon Linux 2023(Optional)

Step 1: Connect to your Amazon Linux 2023 Instance

By this time, I assume you already have an Amazon Linux 2023 instance up and running. Therefore you are all set to install Stress on it. However If that’s not the case, feel free to launch one using one of my previous tutorials.

If you are trying to SSH into your instance from local system, use bbelow command –

ssh -i /path/my-key-pair.pem ec2-user@instance-public-ip

Using this command, you should be able to connect to your instance.

However I prefer, EC2 Instance connext to connect from browser iteself.

For that, select your instance and click on Connect as shown in the below screenshot.

Connect to EC2 Instance Instance using Ec2 instance connect

Verify that ec2-user is showing in the user name field and click Connect again.

In a matter of seconds, you should be connected to your instance as shown below.

Connected to Ec2 Instance AL2023

Step 2: Run System Update

Before installing a new software in your Amazon Linux 2023 instance, you should run system update to update your system packages to the latest.

Run the system update using the below command-

sudo dnf update

Type sudo dnf update and hit enter.

How to Install Python on Amazon Linux 2023 3

Step 3: Search for Stress Utility on Amazon Linux 2023

You can search for stress package in Amazon Linux 2023 as shown below-

dnf search stress
How to Install Stress on Amazon Linux 2023 1

As you can notice there are packages –stress and stress-ng

Which one should you install then?

Well both of these are stress utility and you can install any one of them to stress your EC2 instance. stress-ng is kind of an enhanced version of stress and provides better features.

Step 4: Install Stress or Stress-ng on Amazon Linux 2023

The one-line to install stress or stress-ng would look like-

sudo dnf install stress -y

or

sudo dnf install stress-ng -y

As soon as you hit enter, the stress utility gets installed.

How to Install Stress on Amazon Linux 2023 2
Stress installed on Amazon Linux 2023

Step 5: Verify Stress Installation

As we just installed stress, let’s verify the installation. Just type stress and hit enter-

stress
How to Install Stress on Amazon Linux 2023 3

If it is installed successfully, you will see options as shown in the above screenshot.

Congratulation !!!

You have successfully installed Stress on your Amazon Linux 2023 EC2 Instance.

Step 6: Stress your EC2 CPU

Let’s stress the Amazon Linux 2023 Ec2 instance using the below stress command-

stress --cpu 4 --timeout 300
How to Install Stress on Amazon Linux 2023 5

Explanation: cpu specifies the number of cores, timeout specifies the number of seconds this command will run

Go to the Monitoring tab of your EC2 and open the CPU utilisation matrix. It will open it in CloudWatch.

In sometimes you will see the CPU utilisation has spiked to 100% as seen in below screenshot.

CPU utilisation matrix

That means our stress installation is working fine. Using the stress command we were able to stress the CPU utimisation to 100% successfully.

Step 7: Uninstall Stress from Amazon Linux 2023

If you don’t need stress anymore, you can uninstall it using below command.

[ec2-user@ip-172-31-2-26 ~]$ sudo dnf remove stress
Dependencies resolved.
=====================================================================================================================================================
 Package                       Architecture                  Version                                       Repository                           Size
=====================================================================================================================================================
Removing:
 stress                        x86_64                        1.0.4-28.amzn2023.0.2                         @amazonlinux                         78 k

Transaction Summary
=====================================================================================================================================================
Remove  1 Package

Freed space: 78 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                             1/1 
  Erasing          : stress-1.0.4-28.amzn2023.0.2.x86_64                                                                                         1/1 
  Running scriptlet: stress-1.0.4-28.amzn2023.0.2.x86_64                                                                                         1/1 
  Verifying        : stress-1.0.4-28.amzn2023.0.2.x86_64                                                                                         1/1 


=====================================================================================================================================================

Removed:
  stress-1.0.4-28.amzn2023.0.2.x86_64                                                                                                                

Complete!
[ec2-user@ip-172-31-2-26 ~]$

Conclusion

In this how-to guide, we talked about How to Install Stress on Amazon Linux 2023 Instance.

First of all, we started with checking available packages for stress. We found stress and stress-ng to be available on Amazon Linux 2023.

Then, we installed stress on Amazon Linux 2023 and stressed our CPU utilisation to 100%.

Lastly, we saw how to uninstall stress from Amazon Linux 2023 if you don’t need it anymore.

Were you able to install Stress on Amazon Linux 2023 using this tutorial? Let me know in the comment section.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

Don’t forget to motivate us-

Suggested Read:

Leave a Reply

Your email address will not be published. Required fields are marked *