<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://blog.tanayvan.com</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 09:31:57 GMT</lastBuildDate><atom:link href="https://blog.tanayvan.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Too Many Requests? Understand the Art of Rate Limit]]></title><description><![CDATA[One fine day, we decided to develop a face recognition system at my company, and I was eager to dive into the coding process.
Little did I know that I would soon find myself trapped in the dreaded realm of 'Too Many Requests.' The reason? I was makin...]]></description><link>https://blog.tanayvan.com/too-many-requests-understand-the-art-of-rate-limit</link><guid isPermaLink="true">https://blog.tanayvan.com/too-many-requests-understand-the-art-of-rate-limit</guid><category><![CDATA[ratelimit]]></category><category><![CDATA[GCP]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[cloud tasks]]></category><dc:creator><![CDATA[Tanay Van]]></dc:creator><pubDate>Sat, 30 Sep 2023 01:39:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/FrGYMDjdg4U/upload/5dc6852402ee38a67a44dd509f74b12b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One fine day, we decided to develop a face recognition system at my company, and I was eager to dive into the coding process.</p>
<p>Little did I know that I would soon find myself trapped in the dreaded realm of 'Too Many Requests.' The reason? I was making numerous calls to third-party APIs, each with its distinct rate limit per second.</p>
<p>However, I persevered, and eventually, I managed to fine-tune the entire system to operate as smoothly as a car cruising along an empty road.</p>
<p>To overcome this challenge, I implemented rate limiting using Google Cloud Tasks.</p>
<h2 id="heading-what-is-google-cloud-tasks">WHAT IS GOOGLE CLOUD TASKS?</h2>
<p>Think of it as a supervisor that monitors all the APIs you're using. It ensures that your system follows certain rules, such as how many APIs can be used simultaneously and how often they can be called within a specific time frame.</p>
<p>From a coding perspective, It's similar to sending an email without having to worry about anything at all.</p>
<p>Lets dig into the Google Cloud Platform and take a look at it.</p>
<p>This is how the Cloud Tasks user interface looks as of the day I'm writing this blog.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696035450968/b4137e9b-ae54-4203-9695-26a3d9d9db8f.png" alt class="image--center mx-auto" /></p>
<p>Let's click on 'Create Push Queue' and explore its functionality.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696035566846/e4f49461-d392-4c2b-b1a9-f782bfe54784.png" alt class="image--center mx-auto" /></p>
<p>Let's break down the meaning of all these technical terms one by one.</p>
<p><strong>Max Dispatches</strong>: This is the maximum number of API calls we want to make per second.</p>
<p><strong>Note: If you want to make, for example, 20 calls per minute, which translates to 0.333 calls per second, configuring it directly from the GCP console is not possible.</strong></p>
<p><strong>Instead, you should use the Google Cloud Tasks SDK or the Google CLI for this specific configuration.</strong></p>
<p><strong>Max Concurrent Dispatches</strong>: This is the maximum number of simultaneous API calls that can be made.</p>
<p><strong>Retry Configuration</strong>: it is used to determine how many times a task should retry in case the API encounters an error.</p>
<p>I won't dive into all the details here for Retry Configuration; consider this a personal assignment to explore and learn more on your own. 😉</p>
<p>Now, let's go ahead and create a queue and write some actual code.</p>
<p>I'll be using Node.js to add tasks to the queue.</p>
<p>install the module and import it</p>
<pre><code class="lang-javascript">npm i @google-cloud/tasks
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { CloudTasksClient } = <span class="hljs-built_in">require</span>(<span class="hljs-string">"@google-cloud/tasks"</span>);
</code></pre>
<pre><code class="lang-javascript">
<span class="hljs-keyword">const</span> main = <span class="hljs-function">() =&gt;</span> {
     <span class="hljs-keyword">const</span> payload = {<span class="hljs-string">"data"</span>:<span class="hljs-string">"PUT YOUR ACTUAL JSON HERE"</span>}
    <span class="hljs-keyword">const</span> request = {
        <span class="hljs-attr">parent</span>: <span class="hljs-string">`projects/<span class="hljs-subst">${projectId}</span>/locations/us-west2/queues/my-rate-limit-saviour`</span>,
        <span class="hljs-attr">task</span>: {
          <span class="hljs-attr">httpRequest</span>: {
            <span class="hljs-attr">httpMethod</span>: <span class="hljs-string">"POST"</span>,
            <span class="hljs-attr">url</span>: <span class="hljs-string">`API TO CALL THIS CAN BE YOUR BACKEND API OR CLOUD FUNCTIONS`</span>,
            <span class="hljs-attr">body</span>: Buffer.from(<span class="hljs-built_in">JSON</span>.stringify(payload)).toString(<span class="hljs-string">"base64"</span>),
            <span class="hljs-attr">headers</span>: { <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span> },
          },
        },
     };
      <span class="hljs-keyword">try</span> {
            <span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> CloudTasksClient();
            <span class="hljs-keyword">const</span> [response] = <span class="hljs-keyword">await</span> client.createTask(request);
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Task added to Queue"</span>, response.name);
            <span class="hljs-keyword">return</span> { <span class="hljs-attr">success</span>: <span class="hljs-literal">true</span> };
          } <span class="hljs-keyword">catch</span> (error) {
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Error While adding to queue"</span>, error);
            <span class="hljs-keyword">return</span> { <span class="hljs-attr">success</span>: <span class="hljs-literal">false</span> };
          }
}
</code></pre>
<p>If you're wondering whether I'll be including any third-party APIs in the URL, the answer is no. I'll be doing some processing with the response data, not directly calling external APIs.</p>
<p>This will begin adding tasks to the queue while consistently adhering to the defined task rules.</p>
<p>If you're working with multiple third-party APIs, each having different rate limits, make sure to configure separate tasks with the required rate limits and add those to their respective queues.</p>
<p>That's all for today. If you spot any errors or inaccuracies, please don't hesitate to reach out. I'm always eager to learn and improve my knowledge. Thank you, and I'll see you in the next blog with an exciting topic!</p>
]]></content:encoded></item><item><title><![CDATA[Automate Your React Deployment Using Aws Codebuild]]></title><description><![CDATA[In the previous blog, we learned how manual deployment is done for a react app. But that's a boring job to do every time when you have changes in your code. What if I tell you, that we can automate this process. Every time, you push your code on Gith...]]></description><link>https://blog.tanayvan.com/automate-your-react-deployment-using-aws-codebuild</link><guid isPermaLink="true">https://blog.tanayvan.com/automate-your-react-deployment-using-aws-codebuild</guid><category><![CDATA[AWS]]></category><category><![CDATA[React]]></category><category><![CDATA[Devops]]></category><category><![CDATA[CI/CD]]></category><category><![CDATA[ci-cd]]></category><dc:creator><![CDATA[Tanay Van]]></dc:creator><pubDate>Wed, 03 Aug 2022 04:31:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/m_HRfLhgABo/upload/v1658907180575/D4uc_iA1d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous blog, we learned how manual deployment is done for a react app. But that's a boring job to do every time when you have changes in your code. What if I tell you, that we can automate this process. Every time, you push your code on Github(or any other source provider) it gets auto-deploy on your s3 bucket. For this, we will use the AWS CodeBuild.</p>
<p>The flow of the blog goes like this-</p>
<ol>
<li>We will configure our frontend app for auto deployment.</li>
<li>Set up AWS Codebuild.</li>
<li>That's it .there is nothing much in it.</li>
</ol>
<h1 id="heading-what-is-aws-code-build">What is AWS CODE BUILD?</h1>
<p>In simple terms, It will build our frontend app on a cloud machine, and then we can copy those build files into our s3 bucket. 
For more understanding, you should try searching on your own.</p>
<p>I am assuming you already know how to build a react app manually. If not you should first take a look at it from  <a target="_blank" href="https://blog.tanayvan.com/how-to-host-your-react-project-on-aws-s3">here </a>.</p>
<h1 id="heading-configuring-our-react-project">Configuring our react project</h1>
<p>For this, we will create a new file named <strong>buildspec.yml </strong> in our project root directory.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658904341614/J9uthjprg.png" alt="project structure.png" /></p>
<p>This file will contain what commands should be executed  and the specific node version needed to build our project.
The buildspec.yml looks like this - </p>
<pre><code><span class="hljs-attribute">version</span>: <span class="hljs-number">0.2</span>
<span class="hljs-attribute">phases</span>:
  <span class="hljs-attribute">install</span>: 
    <span class="hljs-attribute">runtime-versions</span>:
      <span class="hljs-attribute">nodejs</span>: <span class="hljs-number">12</span>
    <span class="hljs-attribute">commands</span>:
      - echo <span class="hljs-string">"Installing dependencies..."</span>
      - npm install
  <span class="hljs-attribute">build</span>:
    <span class="hljs-attribute">commands</span>:
      - echo <span class="hljs-string">"Building React project..."</span>
      - npm run build
  <span class="hljs-attribute">post_build</span>:
    <span class="hljs-attribute">commands</span>:
      - echo <span class="hljs-string">"Updating files in the S3 bucket..."</span>
      - aws s3 sync build/ <span class="hljs-attribute">s3</span>:<span class="hljs-comment">//BUCKET_NAME/</span>
</code></pre><p><strong>Here BUCKET_NAME should be changed with your actual bucket name.
</strong></p>
<p>Here you can see there are 3 phases - </p>
<ul>
<li>Install</li>
<li>build</li>
<li>post_build </li>
</ul>
<p>In the <strong>install phase</strong>, we will add those commands which is needed to be executed before we run our next command that is build.</p>
<p>In the <strong>build phase</strong>, we will add those commands to build our project.</p>
<p>For react it will be <strong>npm run build</strong>.</p>
<p>Lastly, for <strong>post_build</strong> we will execute commands which are needed if the build gets succeded.
For example, in our case, it would be to copy the content to our s3 bucket.</p>
<p> this can be done via this command: <strong>aws s3 sync build/ s3://BUCKET_NAME/ </strong></p>
<p>This is the only file we need to add to our project now we can push these changes to 
Github or the only other platform.</p>
<h1 id="heading-set-up-aws-codebuild">Set up AWS Codebuild</h1>
<p>Login to your AWS Account and head over to AWS CodeBuild.</p>
<p>Click on <strong>Create Build Project</strong> button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658905498320/OrUVrpiZE.png" alt="create build project .png" /></p>
<p>For Project configuration, enter the project name of your choice.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658905610950/7Vw75StDD.png" alt="project_configuration.png" /></p>
<p>For Source, select Source provider as per your requirement and select your repository.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658905750236/OPQVXW8hG.png" alt="source.png" />
For Primary source webhook events, we will check the rebuild every time option and for event type, we will select <strong>PUSH</strong>. There are also different Event types too such as PULL_REQUEST_CREATED, PULL_REQUEST_MERGED, and many more.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658905919361/4a7a8PGZ_.png" alt="primary_source_event.png" /></p>
<p>For Environment, we will select Linux as Operating System.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658906065943/eNvjH2jB-.png" alt="Enviroment.png" /></p>
<p>In the Service role, we will create a new role and make sure AWS S3 full access policy is attached to our newly created role. If not, we need to add it manually from IAM .</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658906233567/_BXNeHxi2.png" alt="service.png" /></p>
<p>For Buildspec, we will select <strong>Use a buildspec file</strong> option.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658906329156/rLneEkSGS.png" alt="buildspec.png" /></p>
<p>Other than that we will keep other settings as default for now and click on <strong>Create build project</strong>. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658906463770/2BXMobyBs.png" alt="create build project button.png" /></p>
<p>After successful completion, you can push something on your repo and the build will start automatically, or click on Start Build in the top right corner to manually fire a build and in some time you will see the changes on your s3 endpoint.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658906642860/77oYh5vlH.png" alt="start_build.png" /></p>
<p>Congrats 🎉! You have just set up your own fully managed continuous integration service
using AWS CodeBuild. If you find this blog informative or helpful leave a like or let me know in the comments. </p>
]]></content:encoded></item><item><title><![CDATA[How To Host Your React Project On Aws S3]]></title><description><![CDATA[Hey there, this is my first blog article today so if you see any mistake please ignore it just the way your crush ignores you 😜.
Everybody knows how to code but only a few know how to host it on different platforms and make it production ready. Toda...]]></description><link>https://blog.tanayvan.com/how-to-host-your-react-project-on-aws-s3</link><guid isPermaLink="true">https://blog.tanayvan.com/how-to-host-your-react-project-on-aws-s3</guid><category><![CDATA[AWS]]></category><category><![CDATA[Amazon S3]]></category><category><![CDATA[React]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Tanay Van]]></dc:creator><pubDate>Mon, 25 Jul 2022 17:22:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/xrVDYZRGdw4/upload/v1658769875822/DdtjOAMJO.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey there, this is my first blog article today so if you see any mistake please ignore it just the way your crush ignores you 😜.</p>
<p>Everybody knows how to code but only a few know how to host it on different platforms and make it production ready. Today we will learn one of the ways to do it. The Flow of the blog goes like this-</p>
<ol>
<li>We will create a new react project.</li>
<li>We will build the react project.</li>
<li>Upload our build files to AWS S3 and enable Static web hosting.</li>
</ol>
<p>if you are not familiar with anything from the above don't worry. you will understand everything at the end of the blog.</p>
<p>First, we will create a new react app with the following command -</p>
<pre><code>npx create<span class="hljs-operator">-</span>react<span class="hljs-operator">-</span>app my<span class="hljs-operator">-</span>app
</code></pre><p>Then, we will run the app and check it using :</p>
<pre><code>npm run <span class="hljs-keyword">start</span>
</code></pre><p>Everything seems fine till now and you may already know this thing.</p>
<p>To build the react app we have to use the following command on your terminal:</p>
<pre><code><span class="hljs-built_in">npm</span> run build
</code></pre><p>It may take a while to create an optimized production build. </p>
<p>On successful completion, you will see a new folder name <strong>build </strong>on your project root directory.</p>
<p> We need to upload files inside our build folder on AWS S3.</p>
<p>Login to your AWS Account and head over to S3.</p>
<p>We will create a new bucket using create bucket button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658767855430/qZnMcv2Rx.png" alt="s3-create-bucket.png" /></p>
<p>Name your bucket (<em>it would be better to name it with the domain name on which you will open this website</em>  ) and select the region as per your need.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768033995/0Ad0hG5aa.png" alt="bucketname.png" /></p>
<p>By default the bucket access is private we need to make it public in order to be accessible on the internet.
Uncheck the Block all public access and check the acknowledge button as shown below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768166110/x1OGiNCll.png" alt="public_access.png" /></p>
<p>After that click, "Create Bucket" at the end.</p>
<p>After the bucket is created but still our public access is not enabled so we need to add a bucket policy under "Permissions" as shown below to make it public.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768326357/lBKRjwKkj.png" alt="permissions.png" /></p>
<p>Edit the Bucket Policy under permissions and Add the following JSON </p>
<pre><code>{
    <span class="hljs-attr">"Version"</span>: <span class="hljs-string">"2012-10-17"</span>,
    <span class="hljs-attr">"Statement"</span>: [
        {
            <span class="hljs-attr">"Sid"</span>: <span class="hljs-string">"PublicReadGetObject"</span>,
            <span class="hljs-attr">"Effect"</span>: <span class="hljs-string">"Allow"</span>,
            <span class="hljs-attr">"Principal"</span>: <span class="hljs-string">"*"</span>,
            <span class="hljs-attr">"Action"</span>: <span class="hljs-string">"s3:GetObject"</span>,
            <span class="hljs-attr">"Resource"</span>: <span class="hljs-string">"arn:aws:s3:::BUCKET_NAME/*"</span>
        }
    ]
}
</code></pre><p><strong>Here Replace the BUCKET_NAME with the bucket name you provided earlier.
</strong></p>
<p>Now we will upload our files in this bucket which are inside our build folders.</p>
<p>The structure of files will somewhat look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768601636/hLC1Pq0_w.png" alt="build structure.png" /></p>
<p>After the Upload of the file is done we will enable  Static website hosting so we can access our website.</p>
<p>Head over to the Properties tab and scroll at the bottom where you will see Static website hosting.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768768376/0RPLT2_YU.png" alt="disabled_static_web_hosting.png" /></p>
<p>Click on Edit and Enable the option and in the Index document add <strong>index.html</strong> and save changes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658768915525/ALJrIvzmW.png" alt="setting_static_web_hosting.png" />.</p>
<p>Congrats! 🎉 .You just deployed your first
 react app and you can access it from the Bucket website endpoint from here.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658769087029/6VlWk1u8j.png" alt="endpoint_static_web_hosting.png" /></p>
<p>In our next blog, we will try to set up a CI/CD for our react app using AWS CodeBuild.
 Thank You Guys. </p>
]]></content:encoded></item></channel></rss>