<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AJ Tarachanowicz II</title>
    <description>The latest articles on DEV Community by AJ Tarachanowicz II (@ajt2).</description>
    <link>https://dev.to/ajt2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F969634%2Fbef59c96-6294-46b9-9599-555fa4d96805.png</url>
      <title>DEV Community: AJ Tarachanowicz II</title>
      <link>https://dev.to/ajt2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajt2"/>
    <language>en</language>
    <item>
      <title>Load Testing with Locust</title>
      <dc:creator>AJ Tarachanowicz II</dc:creator>
      <pubDate>Thu, 30 May 2024 08:10:31 +0000</pubDate>
      <link>https://dev.to/ajt2/load-testing-with-locust-4h1p</link>
      <guid>https://dev.to/ajt2/load-testing-with-locust-4h1p</guid>
      <description>&lt;p&gt;This week at work I was tasked with continuing some load testing that a previous Engineer had started. They had used &lt;a href="https://locust.io/"&gt;locust&lt;/a&gt; which is an open source load testing tool to run the initial load testing on the &lt;code&gt;staging&lt;/code&gt; environment. I now needed to do the same for &lt;code&gt;production&lt;/code&gt; so I followed in their footsteps.&lt;/p&gt;

&lt;p&gt;First I installed &lt;code&gt;locust&lt;/code&gt; using &lt;code&gt;homebrew&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install locust
locust --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, I asked ChatGPT to give me a basic test that worked with basic http authentication and let me send GET variables to make a GraphQL request to Magento 2.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from locust import HttpUser, TaskSet, task, between
from requests.auth import HTTPBasicAuth
class WebsiteTasks(TaskSet):
    # def on_start(self):
    #     """ on_start is called when a Locust user starts before any task is scheduled """
    #     self.client.auth = HTTPBasicAuth('username', 'password')
    # @task(1)
    # def index(self):
    #     self.client.get("/")
    @task(1)
    def graphql_query(self):
        query = "/graphql?query=query+getCurrencyData%7Bcurrency%7Bdefault_display_currency_code+available_currency_codes+__typename%7D%7D&amp;amp;operationName=getCurrencyData&amp;amp;variables=%7B%7D"
        self.client.get(query)
class WebsiteUser(HttpUser):
    tasks = [WebsiteTasks]
    wait_time = between(5, 15)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get a baseline I started things off by scaling down to a single instance for the api endpoint and tested in 50 user increments up to 200 users. &lt;/p&gt;

&lt;p&gt;Next, I enabled autoscaling and started to increase the number of users until the alarm to scale up was triggered increasing the number of instances from 2 to 4. I kept increasing users until I scaled up to 5 total instances.&lt;/p&gt;

&lt;p&gt;I had a pretty basic use case for this tool but if you'd like to see how it can be used to do more in-depth testing checkout this article &lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnosity.com/edtech-blog/how-we-manipulated-locust-to-test-system-performance-under-pressure/#:%7E:text=Locust%20is%20an%20open%2Dsource,(TaskSets)%20attached%20to%20them"&gt;https://learnosity.com/edtech-blog/how-we-manipulated-locust-to-test-system-performance-under-pressure/#:~:text=Locust%20is%20an%20open%2Dsource,(TaskSets)%20attached%20to%20them&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I also found a tool to convert HAR files into locust test files. This would make it easy to record a user session and replay it with load testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/SvenskaSpel/har2locust"&gt;https://github.com/SvenskaSpel/har2locust&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was definitely the easiest load testing tool I've used to get up and running out of the box. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>scaling</category>
      <category>aws</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>Excited for a new space in my life</title>
      <dc:creator>AJ Tarachanowicz II</dc:creator>
      <pubDate>Tue, 30 Apr 2024 18:12:16 +0000</pubDate>
      <link>https://dev.to/ajt2/excited-for-a-new-space-in-my-life-43de</link>
      <guid>https://dev.to/ajt2/excited-for-a-new-space-in-my-life-43de</guid>
      <description>&lt;p&gt;I'm really excited to finally have a space in my life where I can share all the things that I geek out on with others. Facebook definitely isn't the space for that. Nor is LinkedIn. Twitter used to be that space for me before it turned into a giant dumpster fire. &lt;/p&gt;

&lt;p&gt;I'm going to work on trying to do short posts with a weekly recap of the different technologies I'm working with and the problems I'm experiencing as a way to get in the habit of posting here on dev.to&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
