<?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: suraj upadhaya</title>
    <description>The latest articles on DEV Community by suraj upadhaya (@surajupadhaya).</description>
    <link>https://dev.to/surajupadhaya</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%2F1451805%2Fc00e1f42-3cae-4095-8880-8e6ac0ee000b.png</url>
      <title>DEV Community: suraj upadhaya</title>
      <link>https://dev.to/surajupadhaya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/surajupadhaya"/>
    <language>en</language>
    <item>
      <title>API Rate Limiting Server</title>
      <dc:creator>suraj upadhaya</dc:creator>
      <pubDate>Fri, 01 Nov 2024 11:06:11 +0000</pubDate>
      <link>https://dev.to/surajupadhaya/api-rate-limiting-server-21jd</link>
      <guid>https://dev.to/surajupadhaya/api-rate-limiting-server-21jd</guid>
      <description>&lt;p&gt;This project implements an HTTP server with rate limiting. It ensures no more than 5 requests per second can be processed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Features&lt;/li&gt;
&lt;li&gt;Github link&lt;/li&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;li&gt;Endpoints&lt;/li&gt;
&lt;li&gt;Usage&lt;/li&gt;
&lt;li&gt;Test&lt;/li&gt;
&lt;li&gt;License&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The API rate limiting server limits the number of requests per second to prevent abuse and manage server load effectively. It provides detailed logging and health check endpoints to monitor server status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Rate limiting to 5 requests per second&lt;/li&gt;
&lt;li&gt;Health check endpoint to monitor server status&lt;/li&gt;
&lt;li&gt;Detailed request logging&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Github Link
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/surajupadhaya/Simple-API-RateLimit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Clone the repository:

   #git clone https://github.com/surajupadhaya/Simple-API-RateLimit
   #cd Simple-API-RateLimit


2. Install dependencies:
   #go mod tidy

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Endpoints
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. /: Default route returns a "stupid request" message with status 400.

2. /healthcheck: Endpoint to check the health status of the server. Returns "Health Passed" if the /healthcheck file exists, otherwise "Health Failed".

3. /api/v1/product: Example endpoint for the product API. Returns "This is a Product API" if the /api/v1/product file exists, otherwise "There is no Product API".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Run the API rate limiting server:
   #go run main.go
2. Access the server:
   #curl -w %{http_code}http://localhost:8080 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Run Httperf tool to test the rate limiting 
Below httperf command is sending 6 connection parallelly in one sec 
Out of 6 only 1 will receive 503 code (due to throttling) remaining will receive based on behavior 
#httperf --server localhost --port 8080 --uri /healthcheck --num-conns 6

Sample output :

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/842aqi7lmzqw7sa1mcs1.png)



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  License
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This project is licensed under the MIT License. See the LICENSE file for details.

This `README.md` should cover the current state of your project, focusing on the API rate limiting aspect. Ready to roll? 🚀


This should cover everything your project entails. You can add, modify, or remove sections as needed. 🚀
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>go</category>
      <category>api</category>
      <category>devops</category>
    </item>
    <item>
      <title>Docker Container health Dashboard in Go</title>
      <dc:creator>suraj upadhaya</dc:creator>
      <pubDate>Sun, 12 May 2024 17:51:32 +0000</pubDate>
      <link>https://dev.to/surajupadhaya/docker-container-health-dashboard-in-go-4ehe</link>
      <guid>https://dev.to/surajupadhaya/docker-container-health-dashboard-in-go-4ehe</guid>
      <description>&lt;h2&gt;
  
  
  Under the Hood
&lt;/h2&gt;

&lt;p&gt;At its core, the application is written in Go, a language known for its simplicity and performance.  It interacts with Docker through the docker/docker client, which provides a rich set of functions to manage container lifecycles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Container Health Check&lt;/strong&gt;: The ContainerHandler function serves as an endpoint that lists all Docker containers and their statuses, providing a quick health check for the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dashboard Serving&lt;/strong&gt;: The customHandler function serves a static HTML dashboard, allowing users to visualize the state of their Docker environment.&lt;/p&gt;

&lt;p&gt;Snippet of Dashboard&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio16k9wqrw5okjv0sd3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio16k9wqrw5okjv0sd3f.png" alt="Image description" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/surajupadhaya/containerDashboard"&gt;https://github.com/surajupadhaya/containerDashboard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>go</category>
      <category>learning</category>
    </item>
    <item>
      <title>Use Circle CI to deploy Flask-Python app in Docker</title>
      <dc:creator>suraj upadhaya</dc:creator>
      <pubDate>Fri, 26 Apr 2024 19:12:34 +0000</pubDate>
      <link>https://dev.to/surajupadhaya/use-circle-ci-to-deploy-flask-python-app-in-docker-23af</link>
      <guid>https://dev.to/surajupadhaya/use-circle-ci-to-deploy-flask-python-app-in-docker-23af</guid>
      <description>&lt;h3&gt;
  
  
  &lt;em&gt;Clone the repo&lt;/em&gt;
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Repo: &lt;a href="https://github.com/surajupadhaya/Portfolio-app"&gt;https://github.com/surajupadhaya/Portfolio-app&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;Push the same code to your repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Setup the Circle CI (free CI/CD tool) with GitHub&lt;/em&gt;
&lt;/h3&gt;

&lt;h6&gt;
  
  
  Sign in to your CircleCI account.
&lt;/h6&gt;

&lt;p&gt;Connect your GitHub account to CircleCI.&lt;br&gt;
Once connected, you’ll see your existing projects populate on your CircleCI dashboard.&lt;br&gt;
Add the environment variable by click on project setting option you will find Environment variable option&lt;br&gt;
$Hub_Pass = docker hub password&lt;br&gt;
$Hub_user = docker hub username&lt;/p&gt;
&lt;h4&gt;
  
  
  Now make changes in templates/index.html file as needed
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Suraj Upadhaya&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        /* Basic styling */
        body {
            font-family: 'IBM Plex Mono', monospace;
            margin: 0;
            padding: 0;
            overflow: hidden;
            background: url('../static/stars2.jpg') fixed;
            background-size: cover;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.8);
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        h1 {
            color: #833AB4;
            font-size: 36px;
            font-weight: bold;
            text-align: center;
            margin-bottom: 20px;
        }
        p {
            color: #333;
            font-size: 18px;
            text-align: center;
        }
        a {
            color: #FD1D1D;
            text-decoration: none;
        }
        .logo-container {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 20px;
        }
        .logo {
            width: 30px;
            height: 30px;
            margin-right: 10px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="stars"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="container"&amp;gt;
        &amp;lt;h1&amp;gt;!! Hey !!&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;Check out my &amp;lt;a href="https://github.com/surajupadhaya"&amp;gt;GitHub profile&amp;lt;/a&amp;gt; and connect with me on &amp;lt;a href="https://www.linkedin.com/in/surajupadhaya/"&amp;gt;LinkedIn&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;
    &amp;lt;p style="font-family: Arial, sans-serif; font-size: 18px; color: #333;"&amp;gt;Tech Stack:&amp;lt;/p&amp;gt;
    &amp;lt;ul style="font-family: 'Courier New', monospace; font-size: 16px; color: #666;"&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href="https://docs.ansible.com/"&amp;gt;Ansible&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href="https://www.gnu.org/software/bash/manual/"&amp;gt;Bash&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href="https://www.perl.org/docs.html"&amp;gt;Perl&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/"&amp;gt;Azure Bicep&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href="https://docs.python.org/3/"&amp;gt;Python&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
        &amp;lt;div class="logo-container"&amp;gt;
            &amp;lt;a href="https://github.com/surajupadhaya"&amp;gt;&amp;lt;img class="logo" src="../static/github-logo.png" alt="GitHub Logo"&amp;gt;&amp;lt;/a&amp;gt;
            &amp;lt;a href="https://www.linkedin.com/in/surajupadhaya/"&amp;gt;&amp;lt;img class="logo" src="../static/linkedin-logo.png" alt="LinkedIn Logo"&amp;gt;&amp;lt;/a&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;change Title name , GitHub repo link , LinkedIn link&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;title&amp;gt;Suraj Upadhaya&amp;lt;/title&amp;gt;
&amp;lt;p&amp;gt;Check out my &amp;lt;a href="https://github.com/surajupadhaya"&amp;gt;GitHub profile&amp;lt;/a&amp;gt; and connect with me on &amp;lt;a href="https://www.linkedin.com/in/surajupadhaya/"&amp;gt;LinkedIn&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push to your repository with the changes, Once pushed you will see the circle Ci pipeline get triggered and it starts to build the Docker images with python app and try to push the image to docker hub registry.&lt;br&gt;
Once build is complete it will start with deploy the container and try to curl the localhost on port 5500 for html output of that application.   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you don't want to trigger the pipeline for any change push to repository then use [skip ci] in your commit message &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basic Structure of .circleci/config.yml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jobs:
  build :
     steps:
       - run:
         command: echo "hello word"
  deploy:
     steps:
       - run:
         command: echo "hello word"
workflows:
   "how you want your jobs to run "

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Snippet below &lt;/p&gt;

&lt;h2&gt;
  
  
  BUILD :
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jobs:

  build:
    docker:
      - image: cimg/base:current
    steps:
      - checkout
      - setup_remote_docker
      - run :
           name: Build the image from Docker file 
           command: |
             docker build -t suru12/portflask-cci:v1 .
             echo $Hub_Pass |docker login -u $Hub_user --password-stdin
             docker push suru12/portflask-cci:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step  images will get create according to the Dockefile and the image will get pushed to docker hub&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffi7768l1gr6ez8l7ig9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffi7768l1gr6ez8l7ig9n.png" alt="Build" width="800" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DEPLOY:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - run :
           name: Run the docker container with suraj/portflask-cci:v1 images 
           command: |
              docker run -d  --name portfolio -p 5500:5000 suru12/portflask-cci:v1
              sleep 20 
              curl localhost:5500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step will run the docker container using the same image you just created and try to run curl on localhost:5500&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffiwe7w4vb78ow8ai39wr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffiwe7w4vb78ow8ai39wr.png" alt="Deploy" width="800" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>learning</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
