<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ajeetmishra on Medium]]></title>
        <description><![CDATA[Stories by Ajeetmishra on Medium]]></description>
        <link>https://medium.com/@007ajeetmishra?source=rss-5a9de8c077bd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QAWfNQRhXGAkt0fxB473FQ.jpeg</url>
            <title>Stories by Ajeetmishra on Medium</title>
            <link>https://medium.com/@007ajeetmishra?source=rss-5a9de8c077bd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:39:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@007ajeetmishra/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Optimizing Microservices Costs: Leveraging Docker Images on AWS Lambda]]></title>
            <link>https://medium.com/@007ajeetmishra/optimizing-microservices-costs-leveraging-docker-images-on-aws-lambda-7601372d2942?source=rss-5a9de8c077bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/7601372d2942</guid>
            <dc:creator><![CDATA[Ajeetmishra]]></dc:creator>
            <pubDate>Sun, 28 May 2023 14:16:32 GMT</pubDate>
            <atom:updated>2023-05-28T14:24:46.197Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Optimizing Microservices Costs: Leveraging Docker Images on AWS Lambda</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2_FzAL4u8glvpUyAMOcvA.png" /></figure><p>In my previous <a href="https://medium.com/@007ajeetmishra/do-you-really-need-high-end-cpus-in-aws-a3b9b469bdab">article</a>, I explained how we (at <a href="http://www.wisedoc.net/"><strong>Wisedoc AI</strong></a>) achieved cost optimization for one of our microservices using AWS Lambda. I mentioned that we utilized the same Docker image, with some additional configurations specific to AWS Lambda.</p><p>In this article, I will guide you through setting up a basic Express.js application as an example. I will also demonstrate the extra configurations needed to prepare the Docker image for deployment on AWS Lambda.</p><p><strong>Step 1 : Creating basic express app </strong><br> a. Installing required modules:</p><pre>npm install express body-parser cors</pre><ul><li>The express module is the main framework for building web applications in Node.js. It provides a set of functionalities and features for creating server-side applications.</li><li>The body-parser module is used to parse incoming request bodies in a middleware. It simplifies handling data in the request body, such as JSON, URL-encoded, or multipart data.</li><li>The cors module is used to enable Cross-Origin Resource Sharing. It allows the server to handle requests from different origins (domains) and manages the security aspects of cross-origin communication.</li></ul><p>b. Creating an Express Application:<br>Create an app.js file in the root of your folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_glaB0lYgy9sUuQvZh6Ng.png" /></figure><p><strong>Step 2 : Setting up </strong><strong>@vendia/serverless-express</strong></p><p>Installation :</p><pre>npm install @vendia/serverless-express</pre><p>The job of the @vendia/serverless-express library is to enable to run Express.js applications on AWS Lambda.</p><p>Traditionally, Express.js applications are designed to run on servers or virtual machines. However, with the @vendia/serverless-express library, developers can deploy their Express.js applications as serverless functions on AWS Lambda. This approach offers several advantages, such as automatic scaling, reduced operational overhead, and cost optimization, as you only pay for the actual execution time of your functions.</p><p>The primary role of @vendia/serverless-express is to provide a bridge between the Express.js framework and the AWS Lambda environment. It acts as a layer that converts incoming Lambda events into HTTP requests and passes them to the Express.js application for processing. Once the application generates a response, @vendia/serverless-express converts it back into a Lambda-compatible format and returns it to the Lambda runtime, which then sends it back as an HTTP response.<br>Now we need to create one more file called lambda.js(you can name it as superman.js doesn’t matter) and wrap our app.js file <br>This is how lambda.js will look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cf6f0r7icVFjWTiyGSY-Ig.png" /></figure><p>Now our wrapper around app.js is ready which acts as an adapter between the Lambda event format and the Express.js framework. It takes the incoming Lambda event and translates it into a format that the Express.js application can process.</p><p><strong>Step 3 : configure docker file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sYGK3m3gl2tOp03jLSnxGw.png" /></figure><ol><li>FROM public.ecr.aws/lambda/nodejs:14</li></ol><p>This line sets the base image for the Docker image. In this case, it uses the public.ecr.aws/lambda/nodejs image with the 14 tag. This base image provides a pre-configured environment for running Node.js applications in AWS Lambda.</p><p>2. COPY ./package*.json ./</p><p>This line copies the package.json and package-lock.json (if it exists) files from the local directory (./) to the root directory (./) inside the Docker image.</p><p>These files are necessary for installing the dependencies required by the Node.js application.</p><p>3. COPY . .</p><p>This line copies the remaining files and directories from the local directory to the root directory inside the Docker image.</p><p>It includes all the application code and any additional files needed for the Lambda function.</p><p>4. RUN npm install</p><p>This line runs the npm install command inside the Docker image.</p><p>5. EXPOSE 3001</p><p>This line specifies that the Docker image will expose port 3001.</p><p>However, in the context of AWS Lambda, this EXPOSE instruction doesn&#39;t have any practical effect since Lambda functions don&#39;t rely on direct port binding like traditional server applications.</p><p>6. CMD [&quot;lambda.handler&quot;]</p><p>This line specifies the command that will be executed when the Docker container starts.</p><p>In this case, it executes the lambda.handler function, which is likely the entry point for the Lambda function defined in the Node.js application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7601372d2942" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do you really need high end CPUs in AWS ?]]></title>
            <link>https://medium.com/@007ajeetmishra/do-you-really-need-high-end-cpus-in-aws-a3b9b469bdab?source=rss-5a9de8c077bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3b9b469bdab</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[resume]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Ajeetmishra]]></dc:creator>
            <pubDate>Sun, 21 May 2023 09:21:01 GMT</pubDate>
            <atom:updated>2023-05-23T06:15:10.630Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Do you really need high end CPUs in AWS ?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rZhvaQclaen5WtNvtHDWWQ.png" /></figure><p>We’re currently in an era where using AWS EC2 instances has become the de facto thing for any startup or organization. However, have we ever stopped to wonder if the EC2 instance with x core of CPUs and y GB of RAM is really required for the use case that we’re targeting? If not, why pay such a high price for it?</p><p>Let me share a real use case where we at <a href="http://www.wisedoc.net/">Wisedoc </a>— a leading-edge software for creating resumes and cover letters with the help of <strong>AI</strong>— faced this exact scenario of paying for an EC2 instance like it was going out of style.</p><p>In Wisedoc, people can create their resume and cover letter and download it in both docx and pdf formats. We’re using two different microservices to achieve this goal. For our PDF microservice, we used an EC2 instance with x GB of RAM and y core of CPUs with both x and y being on the higher end. to make the PDF download process fast, and it was fast. We rented that machine for a month and ended up paying a fortune for it.</p><p>We’re not Instagram, Twitter, or Facebook, where people stay active all the time to download PDFs and create resumes. So, we decided to figure out a solution that would save us some money. Our first thought was to reduce the size of the RAM and cores of CPUs. But, do we really need that machine 24*7?</p><p>After some brainstorming, we decided to move to a serverless architecture. We deployed the same Docker container with some extra configuration to make it compatible with the Lambda service on AWS. I won’t go into the details here about how we configured our Docker image for AWS Lambda. That’s a topic to discuss on another day.</p><p>The time it takes to download a PDF has increased slightly, but it is still manageable.</p><p>By adopting a serverless architecture, we were able to reduce our costs significantly. This move not only saved us a lot of money, but it also enabled us to scale our operations easily. So, if you’re running a startup or organization and wondering if you really need high-end CPUs in AWS, take a closer look at your use case and consider a serverless architecture. It might just save you a fortune!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3b9b469bdab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>