<?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>Forem: Raiyan Memon</title>
    <description>The latest articles on Forem by Raiyan Memon (@raiyan_memon).</description>
    <link>https://forem.com/raiyan_memon</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%2F1630906%2Ff4b23462-365e-4fcf-b126-319be736de17.jpg</url>
      <title>Forem: Raiyan Memon</title>
      <link>https://forem.com/raiyan_memon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/raiyan_memon"/>
    <language>en</language>
    <item>
      <title>Determine Server Capacity to handle the requests</title>
      <dc:creator>Raiyan Memon</dc:creator>
      <pubDate>Sat, 19 Oct 2024 09:53:38 +0000</pubDate>
      <link>https://forem.com/raiyan_memon/determine-server-capacity-to-handle-the-requests-2gl9</link>
      <guid>https://forem.com/raiyan_memon/determine-server-capacity-to-handle-the-requests-2gl9</guid>
      <description>&lt;p&gt;Knowing how much load your server can take at once is crucial.&lt;/p&gt;

&lt;p&gt;In this blog, we will learn how many requests your server can handle at once.&lt;/p&gt;

&lt;p&gt;We are going to fire an Apache Command with some configurations in it to know the capacity of our server and push it to its limit so that we get to know whether to increase the size of our server or add a load balancer to it.&lt;/p&gt;

&lt;p&gt;A command line tool that we are going to use is known as ApacheBench (ab). It tests the performance of a server by sending a specified number of requests and measuring the response times.&lt;/p&gt;

&lt;p&gt;Also provides insights like requests per second, time taken per request, and transfer rates.&lt;/p&gt;

&lt;p&gt;Copy and paste the below command on the local or live server works but make sure the apache2 server is installed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ab -n 1000 -c 10 https://raiyanmemon.in/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you are getting any error try with “http” rather than using “https”.&lt;/p&gt;

&lt;p&gt;It mostly throws an error of ssl with “https” just on the local server but works same.&lt;/p&gt;

&lt;p&gt;Here’s a breakdown of the parameters:&lt;/p&gt;

&lt;p&gt;ab: Apache Bench.&lt;br&gt;
-n 1000: The total number of requests to send. In this case, 1000 requests.&lt;br&gt;
-c 10: The concurrency level, meaning 10 requests will be sent simultaneously.&lt;br&gt;
&lt;a href="https://raiyanmemon.in/:" rel="noopener noreferrer"&gt;https://raiyanmemon.in/:&lt;/a&gt; The URL of the server you are testing. At last, the forward slash (/) is mandatory.&lt;br&gt;
You can change the number of requests or the concurrency level if you want to create a heavy load on your server.&lt;/p&gt;

&lt;p&gt;You can also change your server URL to an IP address something like this: &lt;a href="http://192.168.1.17/" rel="noopener noreferrer"&gt;http://192.168.1.17/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your Response to the above command will be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server Software:        *******
Server Hostname:        raiyanmemon.in
Server Port:            443
SSL/TLS Protocol:       *************
Server Temp Key:        ********
TLS Server Name:        raiyanmemon.in

Document Path:          /
Document Length:        9607 bytes

Concurrency Level:      10
Time taken for tests:   4.202 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      1029945 bytes
HTML transferred:       960700 bytes
Requests per second:    23.80 [#/sec] (mean)
Time per request:       420.214 [ms] (mean)
Time per request:       42.021 [ms] (mean, across all concurrent requests)
Transfer rate:          239.36 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      119  136  48.9    123     344
Processing:    40  129 259.1     42    1317
Waiting:       40  128 259.1     42    1316
Total:        160  264 302.3    165    1661
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Just spend some time to analyse the response and you will get to understand how simple it is.&lt;/p&gt;

&lt;p&gt;After hitting the command to know whether the command has an effect or not, just log in to your server and see the CPU usage you will notice an instant hike.&lt;/p&gt;

&lt;p&gt;If you didn’t notice any change on the CPU try increasing your number of requests and concurrency level.&lt;/p&gt;

&lt;p&gt;This is it. You are ready to test your server capacity to handle the requests.&lt;/p&gt;

&lt;p&gt;Feel free to comment if you have any recommendations.&lt;/p&gt;

&lt;p&gt;Keep coding and exploring ❤️&lt;/p&gt;

</description>
      <category>capacity</category>
    </item>
    <item>
      <title>Running Laravel Queue Worker in Production</title>
      <dc:creator>Raiyan Memon</dc:creator>
      <pubDate>Thu, 17 Oct 2024 17:25:55 +0000</pubDate>
      <link>https://forem.com/raiyan_memon/running-laravel-queue-worker-in-production-24b2</link>
      <guid>https://forem.com/raiyan_memon/running-laravel-queue-worker-in-production-24b2</guid>
      <description>&lt;p&gt;Laravel Queue Worker plays an important role in running in the background. It does not put a load on our web application.&lt;/p&gt;

&lt;p&gt;For firing mail and any other stuff that takes time for such tasks, we can schedule a queue worker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this we are going to see how we can schedule our queue worker on the production server.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most people including me had a hard time running this command on the production server we can just keep running “php artisan queue:work” every time so I got the solution.&lt;/p&gt;

&lt;p&gt;Go inside your code folder on the server and just place this command and hit enter twice.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nohup php artisan queue:work --daemon &amp;amp;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! You just fired a command which will keep the worker running even if you close the console of your server.&lt;/p&gt;

&lt;p&gt;One more thing if you have made any changes in the queue worker code and something related to that and the changes do not reflect on the production link just restart the queue with this command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan queue:restart&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will stop the command of keeping up the queue worker and then run&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan optimize:clear&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command is mandatory because Laravel stores the cache and does not clear it by default.&lt;/p&gt;

&lt;p&gt;After this just hit the first command and your queue worker is automated again.&lt;/p&gt;

&lt;p&gt;Keep coding and exploring❤️&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>queue</category>
      <category>worker</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
