<?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: Isha Training Solutions</title>
    <description>The latest articles on DEV Community by Isha Training Solutions (@isha_kumargupta_01fbbf71).</description>
    <link>https://dev.to/isha_kumargupta_01fbbf71</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4238988%2F60fc39d0-7f5d-48b1-8562-d77f43783546.jpeg</url>
      <title>DEV Community: Isha Training Solutions</title>
      <link>https://dev.to/isha_kumargupta_01fbbf71</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isha_kumargupta_01fbbf71"/>
    <language>en</language>
    <item>
      <title>How to Write Your First k6 Load Test in 10 Minutes</title>
      <dc:creator>Isha Training Solutions</dc:creator>
      <pubDate>Sat, 14 Nov 2026 10:01:00 +0000</pubDate>
      <link>https://dev.to/isha_kumargupta_01fbbf71/how-to-write-your-first-k6-load-test-in-10-minutes-1h24</link>
      <guid>https://dev.to/isha_kumargupta_01fbbf71/how-to-write-your-first-k6-load-test-in-10-minutes-1h24</guid>
      <description>&lt;p&gt;If you have never done performance testing before, k6 is one of the easiest tools to start with. It is free, open source, and you write tests in simple JavaScript. In this short tutorial you will install k6, write your first load test and understand the results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install k6&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows:&lt;/strong&gt; &lt;code&gt;winget install k6&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mac:&lt;/strong&gt; &lt;code&gt;brew install k6&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux (Debian/Ubuntu):&lt;/strong&gt; follow the steps on the official k6 installation page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;k6 version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Write your first test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a file called &lt;code&gt;first-test.js&lt;/code&gt; and paste this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'k6/http'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'k6'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;vus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="c1"&gt;// 10 virtual users&lt;/span&gt;
  &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'30s'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// run for 30 seconds&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://test.k6.io'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s1"&gt;'status is 200'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// wait 1 second, like a real user&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;vus&lt;/strong&gt; is the number of virtual users hitting the site at the same time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;duration&lt;/strong&gt; is how long the test runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;check&lt;/strong&gt; confirms the page returned status 200 (OK).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sleep&lt;/strong&gt; adds a pause between requests so the load behaves like real users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Run the test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;k6 run first-test.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Read the results&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the test finishes, k6 prints a summary. The most important lines are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;http_req_duration&lt;/strong&gt;: how long requests took. Look at &lt;code&gt;avg&lt;/code&gt; and &lt;code&gt;p(95)&lt;/code&gt;. The p(95) value means 95% of requests were faster than this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;http_req_failed&lt;/strong&gt;: the percentage of failed requests. Ideally 0%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;checks&lt;/strong&gt;: how many of your checks passed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;iterations&lt;/strong&gt;: how many times the test function ran.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Add a pass/fail rule (thresholds)
&lt;/h2&gt;

&lt;p&gt;In real projects you want the test to fail automatically if performance is too slow. Add &lt;code&gt;thresholds&lt;/code&gt; to your options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;vus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'30s'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;thresholds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;http_req_duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'p(95)&amp;lt;500'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// 95% of requests under 500 ms&lt;/span&gt;
    &lt;span class="n"&gt;http_req_failed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'rate&amp;lt;0.01'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// less than 1% errors&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now k6 marks the test as failed if these limits are crossed, which is perfect for running in CI/CD pipelines like Jenkins or GitHub Actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to learn next&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ramping users up and down with &lt;code&gt;stages&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Testing APIs with POST requests and authentication tokens&lt;/li&gt;
&lt;li&gt;Sending results to Grafana dashboards&lt;/li&gt;
&lt;li&gt;Running k6 tests in CI/CD&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Written by the team at &lt;a href="https://www.ishatrainingsolutions.org/" rel="noopener noreferrer"&gt;Isha Training Solutions&lt;/a&gt;, where we teach live online k6 and performance testing courses with real-time projects.&lt;/em&gt;&lt;/p&gt;

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