<?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: Renato Byrro</title>
    <description>The latest articles on Forem by Renato Byrro (@byrro).</description>
    <link>https://forem.com/byrro</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%2F135778%2F9545e7d7-5bd6-4fbe-8345-54903d8760e3.png</url>
      <title>Forem: Renato Byrro</title>
      <link>https://forem.com/byrro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/byrro"/>
    <language>en</language>
    <item>
      <title>How about an AWS Lambda Spot with 70% savings?</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Thu, 14 May 2020 13:39:38 +0000</pubDate>
      <link>https://forem.com/byrro/how-about-an-aws-lambda-spot-with-70-savings-50ap</link>
      <guid>https://forem.com/byrro/how-about-an-aws-lambda-spot-with-70-savings-50ap</guid>
      <description>&lt;p&gt;A couple of days ago I published this tweet:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1260296325456891905-310" src="https://platform.twitter.com/embed/Tweet.html?id=1260296325456891905"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1260296325456891905-310');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1260296325456891905&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Some people confused my idea saying that Lambda is already Spot. I understand the position they come from. Lambda only charges per usage, it's not 'rented'.&lt;/p&gt;

&lt;p&gt;But the idea I have for Spot is the situation when AWS has idle servers lingering around their data centers, in which they incentivize low-value workloads by lowering prices. Low revenue is better than nothing in those cases.&lt;/p&gt;

&lt;p&gt;Workloads that wouldn't be cost-effective to run on EC2, become interesting on Spot instances.&lt;/p&gt;

&lt;p&gt;Spot has particularities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS can terminate the instance at any moment (when someone else is willing to pay more for it), so your workload must be super fault-tolerant;&lt;/li&gt;
&lt;li&gt;We can bid how much we'd like to pay for each workload, so we'll use the Spot instances only when the price is low enough;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same could happen for Lambda. We store invocations in a particular queue and integrate it with a Lambda Spot, setting a price per invocation and per GB-seconds. When the price is low enough, the Lambda platform will start pulling messages and processing them.&lt;/p&gt;

&lt;p&gt;Under the hood, Lambda runs on Firecracker, which runs on EC2 instances. What we need is a Firecracker running on Spot Instances. They could go away on a snap, which would halt all Lambda executions, but that's fine.&lt;/p&gt;

&lt;p&gt;Leave your suggestions in the comments. Like ❤️ the article if you like the idea 💡&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awslambda</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Why Serverless Apps Fail and How to Design Resilient Architectures</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Tue, 21 Apr 2020 12:48:14 +0000</pubDate>
      <link>https://forem.com/dashbird/why-serverless-apps-fail-and-how-to-design-resilient-architectures-54n0</link>
      <guid>https://forem.com/dashbird/why-serverless-apps-fail-and-how-to-design-resilient-architectures-54n0</guid>
      <description>&lt;p&gt;By observing 100,000's of serverless backend components monitored for 2+ years at &lt;a href="https://dashbird.io/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch-q2-2020&amp;amp;utm_content=serverless-at-scale"&gt;Dashbird&lt;/a&gt;, experience shows that Serverless infrastructure failure boils down to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Throughput and concurrency limitations due to scalability mismatches;&lt;/li&gt;
&lt;li&gt;Increased latency &amp;amp; associated timeout errors;&lt;/li&gt;
&lt;li&gt;Inadequate management of resource allocation;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Isolated faults become causes of widespread failure due to dependencies in our cloud architectures (ref. &lt;a href="https://dashbird.io/knowledge-base/basic-concepts/reliability/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch-q2-2020&amp;amp;utm_content=serverless-at-scale"&gt;Difference of Fault vs. Failure&lt;/a&gt;). If a serverless Lambda function relies on a database that is under stress, the entire API may start returning 5XX errors.&lt;/p&gt;

&lt;p&gt;You may think this is just a fact of life, but we can dodge or at least mitigate these failures in many cases.&lt;/p&gt;

&lt;p&gt;Serverless is not a magical silver bullet. These services have their limitations, especially to &lt;a href="https://dashbird.io/knowledge-base/basic-concepts/scalability/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch-q2-2020&amp;amp;utm_content=serverless-at-scale"&gt;scalability&lt;/a&gt; capacities. &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/introduction-to-aws-lambda/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch-q2-2020&amp;amp;utm_content=serverless-at-scale"&gt;AWS Lambda&lt;/a&gt;, for example, can increase concurrency level up to &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/scalability-and-concurrency/#concurrency-limits-and-scalability?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch-q2-2020&amp;amp;utm_content=serverless-at-scale"&gt;a certain level per minute&lt;/a&gt;. Throw in 10,000 concurrent requests out of thin air and it will throttle.&lt;/p&gt;

&lt;p&gt;A typical architecture looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TaywXCrX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-04-16/when-serverless-apps-will-fail-typical-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TaywXCrX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-04-16/when-serverless-apps-will-fail-typical-architecture.png" alt="Typical Architecture" title="Typical Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It usually works well under a low scale. Put in more load a single component's fault can bring the whole implementation to its knees.&lt;/p&gt;

&lt;p&gt;Consider this scenario: due to market reasons, &lt;em&gt;API Endpoint 1&lt;/em&gt; starts receiving an unusual amount of requests. Your clients are generating more data and your backend needs to store it in the &lt;em&gt;RDS instance&lt;/em&gt;. Relational databases usually don't scale linearly to the I/O level, so we can expect an increase in query latency during this peak demand. &lt;em&gt;API Endpoint 1&lt;/em&gt; or &lt;em&gt;Lambda function 1&lt;/em&gt; will start timing out at some point due to the database delays.&lt;/p&gt;

&lt;p&gt;Another possible fault scenario is throttling from &lt;em&gt;Lambda function 1&lt;/em&gt; due to a rapid increase in concurrency.&lt;/p&gt;

&lt;p&gt;Not only &lt;em&gt;API Endpoint 1&lt;/em&gt; will become unavailable to clients, but also the second endpoint. In the first scenario, &lt;em&gt;Endpoint 2&lt;/em&gt; also relies on the same &lt;em&gt;RDS instance&lt;/em&gt;. In the second scenario, &lt;em&gt;Lambda function 1&lt;/em&gt; will consume the entire concurrency limits for your AWS account, causing &lt;em&gt;Lambda function 2&lt;/em&gt; to throttle requests as well.&lt;/p&gt;

&lt;p&gt;We can avoid this by decoupling the &lt;em&gt;API Endpoint 1&lt;/em&gt; and &lt;em&gt;Lambda function 1&lt;/em&gt;. In the example, our clients are only sending information that needs to be stored, but no processing and customized response are needed. Here is an alternative architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oOIIJKwI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-04-16/when-serverless-apps-will-fail-typical-architecture-solution.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oOIIJKwI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-04-16/when-serverless-apps-will-fail-typical-architecture-solution.png" alt="Using a queue to off-load peak demand" title="Using a queue to off-load peak demand"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of sending requests directly from &lt;em&gt;API Endpoint 1&lt;/em&gt; to the &lt;em&gt;Lambda function 1&lt;/em&gt;, we first store all requests in a highly-scalable &lt;em&gt;SQS queue&lt;/em&gt;. The API can immediately return a 200 message to clients. The &lt;em&gt;Lambda function 1&lt;/em&gt; will later pull messages from the queue in a rate that is manageable for its own concurrency limits and the &lt;em&gt;RDS instance&lt;/em&gt; capabilities.&lt;/p&gt;

&lt;p&gt;With this modification, the potential for widespread failure is minimized by having a queue absorbing peaks in demand. SQS standard queues can handle nearly unlimited throughput. At the same time, all components serving &lt;em&gt;Endpoint 2&lt;/em&gt; can continue to work normally, since data consumption by the &lt;em&gt;Lambda function 1&lt;/em&gt; is smoothed out.&lt;/p&gt;

&lt;p&gt;This is a simplified example, there are several aspects to consider in terms of potential failure points and architectural improvements. We hosted a webinar to cover these topics in much more depth, &lt;a href="https://youtu.be/-cuhYblrofM"&gt;which you can watch here&lt;/a&gt; or below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/-cuhYblrofM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>awslambda</category>
      <category>scalability</category>
      <category>resilience</category>
    </item>
    <item>
      <title>Monitoring 101: AWS CloudWatch vs Serverless-oriented</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Thu, 26 Mar 2020 22:33:07 +0000</pubDate>
      <link>https://forem.com/dashbird/monitoring-101-aws-cloudwatch-vs-serverless-oriented-3d83</link>
      <guid>https://forem.com/dashbird/monitoring-101-aws-cloudwatch-vs-serverless-oriented-3d83</guid>
      <description>&lt;p&gt;At this moment, billions of people are rushing to the internet for work, entertainment, shopping - everything, really. It's great that we developed this virtual world and can keep the lights on, despite what’s happening outside.&lt;/p&gt;

&lt;p&gt;On the other hand, cloud systems and developers are under pressure to meet an unparalleled demand. At &lt;a href="https://dashbird.io/aws-monitoring/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=small-teams&amp;amp;utm_content=dashbird-vs-cloudwatch"&gt;Dashbird&lt;/a&gt;, we have always thought developers deserve the most efficient tools to discover and resolve issues in order to keep cloud apps running smoothly.&lt;/p&gt;

&lt;p&gt;For applications running on AWS, CloudWatch might have been enough so far. In our research, though, we identified that teams relying solely on CloudWatch tend to lag behind on issue discovery and resolution time.&lt;/p&gt;

&lt;p&gt;We have compiled this feature comparison list between &lt;a href="https://dashbird.io/aws-monitoring/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=small-teams&amp;amp;utm_content=dashbird-vs-cloudwatch"&gt;Dashbird&lt;/a&gt; and AWS CloudWatch to help you decide on the most efficient tool for your specific needs:&lt;/p&gt;

&lt;p&gt;If you haven't yet, you can &lt;a href="https://dashbird.io/register?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=small-teams&amp;amp;utm_content=dashbird-vs-cloudwatch"&gt;start your free 14-day trial with Dashbird&lt;/a&gt; today and test out the premium features yourself. No credit card required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vjn8Obu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-03-20/dashbird-vs-cloudwatch-comparison-table.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vjn8Obu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/blog/2020-03-20/dashbird-vs-cloudwatch-comparison-table.png" alt="AWS CloudWatch vs. Dashbird"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>aws</category>
      <category>awslambda</category>
      <category>serverless</category>
    </item>
    <item>
      <title>The Serverless Trilemma: Build High-Quality Architectures</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Mon, 23 Mar 2020 17:21:30 +0000</pubDate>
      <link>https://forem.com/dashbird/the-serverless-trilemma-build-high-quality-architectures-3hb</link>
      <guid>https://forem.com/dashbird/the-serverless-trilemma-build-high-quality-architectures-3hb</guid>
      <description>&lt;p&gt;Hey, we just published a video in the Serverless Well-Architected series. It covers three essential concepts to high-quality architectures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Black-box&lt;/li&gt;
&lt;li&gt;Double-billing&lt;/li&gt;
&lt;li&gt;Substitution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me know your thoughts in the comments. &lt;a href="https://dashbird.io/subscribe?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=well-architected&amp;amp;utm_content=serverless-trilemma"&gt;Subscribe&lt;/a&gt; to receive updates on future content. &lt;a href="https://dashbird.io/#register/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=well-architected&amp;amp;utm_content=serverless-trilemma"&gt;Try a serverless monitoring tool&lt;/a&gt; that can help you improve your architecture.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2n_bCGEGvsY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>aws</category>
      <category>lambda</category>
      <category>architecture</category>
    </item>
    <item>
      <title>The Serverless Trilemma</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Wed, 26 Feb 2020 13:51:20 +0000</pubDate>
      <link>https://forem.com/byrro/the-serverless-trilemma-35il</link>
      <guid>https://forem.com/byrro/the-serverless-trilemma-35il</guid>
      <description>&lt;h1&gt;
  
  
  Quick Intro
&lt;/h1&gt;

&lt;p&gt;The &lt;strong&gt;Serverless Trilemma&lt;/strong&gt; is a framework developed by researchers in IBM a couple of years ago (&lt;a href="https://drive.google.com/file/d/1-M9_oK4kWMcsx38DFRhxrdSWE958O7bh/view?usp=sharing"&gt;full academic paper&lt;/a&gt;). It helps us evaluate the quality of architectural designs and make better decisions by understanding the trade-offs involved.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is an introductory article, we'll publish more hands-on guidance on how to apply these principles in next articles on this series. To stay tuned, please &lt;a href="https://dashbird.io/subscribe-knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=serverless-trilemma"&gt;subscribe here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Basic Constraints
&lt;/h1&gt;

&lt;p&gt;There are three desired properties we should look for in a serverless architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Black-box&lt;/li&gt;
&lt;li&gt;Double-billing&lt;/li&gt;
&lt;li&gt;Substitution&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Black-box
&lt;/h2&gt;

&lt;p&gt;The Black Box principle indicates that each function should work&lt;br&gt;
independently from the rest of the system and no implementation details should be leaked.&lt;/p&gt;

&lt;p&gt;Consider two functions running on &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/introduction-to-aws-lambda/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=serverless-trilemma"&gt;AWS Lambda&lt;/a&gt;: &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Function A&lt;/code&gt; uses the AWS SDK to invoke &lt;code&gt;Function B&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lDWGt7hd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ywde4ghmlu0gfvy1uxrr.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lDWGt7hd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ywde4ghmlu0gfvy1uxrr.PNG" alt="Black-box Functions A and B in AWS Lambda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What happens if we need to move the &lt;code&gt;Function B&lt;/code&gt; code to another infrastructure? Perhaps the &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/introduction-to-aws-lambda/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=serverless-trilemma"&gt;AWS Lambda&lt;/a&gt; memory limits aren't enough anymore.&lt;/p&gt;

&lt;p&gt;The AWS SDK invocation process will not work anymore. In order to migrate &lt;code&gt;Function B&lt;/code&gt;, a concomitant modification is required in &lt;code&gt;Function A&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ULib7cBg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i92mi0gj2mtskcp28b52.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ULib7cBg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i92mi0gj2mtskcp28b52.PNG" alt="Black-box AWS SDK fails"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This type of architecture makes it difficult to introduce changes and increases the likelihood of unintended consequences.&lt;/p&gt;

&lt;p&gt;The problem here is that &lt;code&gt;Function B&lt;/code&gt; is leaking its implementation details, thus not working as a Black-box. The leakage is having &lt;code&gt;Function A&lt;/code&gt; aware that &lt;code&gt;Function B&lt;/code&gt; is deployed in &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/introduction-to-aws-lambda/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=serverless-trilemma"&gt;AWS Lambda&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To satisfy the Black Box principle, we could create an HTTP API. By routing requests through the API, we can decouple the functions. Later we can just update the API routing to the new infrastructure when migrating Function B.&lt;/p&gt;

&lt;p&gt;This simplifies change, which can be extremely valuable as the system and development team grows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hGAe0dIA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0u0wes6k6k2lmj5ln9e8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hGAe0dIA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0u0wes6k6k2lmj5ln9e8.gif" alt="Black-box - decoupling with an HTTP API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Double-billing
&lt;/h2&gt;

&lt;p&gt;This principle is relatively simple: two functions should not run at the same time while one is in idle state waiting for the other.&lt;/p&gt;

&lt;p&gt;In Serverless, we pay for the function execution time. Consider &lt;code&gt;Function A&lt;/code&gt; starts processing and being billed. At some point, it invokes &lt;code&gt;Function B&lt;/code&gt; and waits for a response.&lt;/p&gt;

&lt;p&gt;Problem is: While &lt;code&gt;B&lt;/code&gt; is processing, &lt;code&gt;A&lt;/code&gt; continues to be charged, despite being idle. &lt;code&gt;Function B&lt;/code&gt; processing time is effectively being charged twice, which is arguably undesirable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8R5HyMpr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xbtoya5vxo75zxkwdf6j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8R5HyMpr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xbtoya5vxo75zxkwdf6j.gif" alt="Double Billing Animated Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Substitution
&lt;/h2&gt;

&lt;p&gt;Substitution is about having a composition of functions behaving just like any normal function.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But what is composition?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Consider a user requests an invoice from a billing system, which is served by a serverless function. This function may rely on a second one to apply any discounts available to this user. Yet another function is responsible for calculating Sales Tax, for instance.&lt;/p&gt;

&lt;p&gt;All three functions are composed to work as a group, hence the name "composition".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IVp461Gt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jt5myub4cyfak3298v0y.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IVp461Gt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jt5myub4cyfak3298v0y.PNG" alt="Functions Composition"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The substitution principle indicates that all three functions&lt;br&gt;
together should behave like a function. From invocation methods to timeout to dead-letter-queue, everything behaves as if they were a single function.&lt;/p&gt;

&lt;p&gt;The requester doesn't actually know this is a composition of functions. Any developer can rely on this composition without worrying about how it behaves, they just apply everything they already know.&lt;/p&gt;

&lt;p&gt;This property improves productivity and overall quality by reducing errors and unintended consequences.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AHu7o48p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t0cabsxqwg8jduq7kfs7.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AHu7o48p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t0cabsxqwg8jduq7kfs7.PNG" alt="Functions Composition behaves as a single function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Trade-offs involved
&lt;/h1&gt;

&lt;p&gt;Most of the time, it is not possible to have all the properties together. Applying the Black box principle is usually easy. When it comes to the other two, there is usually a trade-off.&lt;/p&gt;

&lt;p&gt;When we prioritize one, such as &lt;strong&gt;Substitution&lt;/strong&gt; it becomes difficult to apply &lt;strong&gt;Double-billing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nS_tJIMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/royi2uqy79nmqlw1cysw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nS_tJIMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/royi2uqy79nmqlw1cysw.gif" alt="Trade-off animated gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Serverless Trilemma framework helps to make architectural decisions&lt;br&gt;
and identify what needs to be prioritized:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Black Box&lt;/strong&gt; improves maintainability, scalability, and resilience by decoupling components&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Double-billing&lt;/strong&gt; enables cost-efficiency and reduces the overall concurrency level of the system&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Substitution&lt;/strong&gt; enables code reusability and improves the quality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What should be prioritized will really depend on each case. We'll dive into more details about this decision-making process in the next articles coming on this series.&lt;/p&gt;

&lt;p&gt;To stay tuned, &lt;a href="https://dashbird.io/subscribe-knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=serverless-trilemma"&gt;subscribe here for free&lt;/a&gt; to receive announcements when we publish again.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>architecture</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Production-ready: Microservices Composition and Orchestration</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Mon, 20 Jan 2020 11:15:30 +0000</pubDate>
      <link>https://forem.com/dashbird/production-ready-microservices-composition-and-orchestration-37jn</link>
      <guid>https://forem.com/dashbird/production-ready-microservices-composition-and-orchestration-37jn</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published in the &lt;a href="https://dashbird.io/knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;Cloud Knowledge Base&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;A strong and mature trend in modern cloud software development is to implement components that are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single-purpose&lt;/li&gt;
&lt;li&gt;Small&lt;/li&gt;
&lt;li&gt;Deployed independently&lt;/li&gt;
&lt;li&gt;Easily testable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These component services are then composed (or orchestrated) into a cohesive and organized workflow to fulfill higher-level tasks and accomplish the business or practical purposes expected from the system.&lt;/p&gt;

&lt;p&gt;Having independent components enables software reusability and decoupling of the software architecture. As a result, the entire system can be easier to test, extend and maintain.&lt;/p&gt;

&lt;h1&gt;
  
  
  How about composition in Serverless?
&lt;/h1&gt;

&lt;p&gt;Composing serverless functions, such as &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/introduction-to-aws-lambda/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;AWS Lambda&lt;/a&gt;, is not as easy as it may sound. Many benefits that developers appreciate in serverless functions are dependent on certain properties.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High scalability of functions depends on its stateless property&lt;/li&gt;
&lt;li&gt;Pay-per-use model (no idle resource waste) is only possible because functions are ephemeral, run on-demand, with no long-running processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same properties that make serverless so attractive are also what poses some challenges for services composition.&lt;/p&gt;

&lt;p&gt;In function composition architectures, we would want at least three principles met:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Substitution&lt;/strong&gt;: being able to replace (or perhaps extend/modify) a component without breaking the rest of the system;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation&lt;/strong&gt;: each component should be a black-box, no service should be aware of other services' implementation details;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-waste&lt;/strong&gt;: since serverless is about pay-per-use, we would like to avoid a double-billing situation, for example (more on that below)&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Serverless composition challenges
&lt;/h1&gt;

&lt;p&gt;Let's consider a trivial situation: a user creates a free account (no payments involved) and subscribes to an online service. Some tasks should be performed as a result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Persist the user data in a database store&lt;/li&gt;
&lt;li&gt;Send a message to validate the user e-mail address&lt;/li&gt;
&lt;li&gt;Notify a webhook to track marketing campaign performance (conversion from lead to a subscribed user)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If each of these &lt;em&gt;tasks&lt;/em&gt; should be performed by isolated and independent components, how should we coordinate them together?&lt;/p&gt;

&lt;p&gt;A flat, simple implementation would be having a function running behind an API and coordinating all other tasks sequentially. We will see next why this implementation is sub-optimal, but please check the diagram below first:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vn0r5OA2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-sequential-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vn0r5OA2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-sequential-architecture.png" alt="Sequential Composition"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recovering the three principles we are looking to meet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Substitution&lt;/li&gt;
&lt;li&gt;Isolation&lt;/li&gt;
&lt;li&gt;Zero-waste&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The implementation above does not meet any of these desired properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaks Substitution
&lt;/h2&gt;

&lt;p&gt;First, it makes it difficult to replace and extend components. Suppose this system has been running for a while. Now there is a requirement to also validate the user mobile phone number with an SMS. When &lt;code&gt;CreateUser&lt;/code&gt; invokes the &lt;code&gt;ValidateEmail&lt;/code&gt; function, it only provides a recipient e-mail address, not a phone number. We cannot just replace &lt;code&gt;ValidateEmail&lt;/code&gt; with a more general-purpose &lt;code&gt;ValidateContacts&lt;/code&gt;, for example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaks Isolation
&lt;/h2&gt;

&lt;p&gt;Second, the &lt;code&gt;CreateUser&lt;/code&gt; function must be aware of other services and at least some of their implementation details. For example, it must be aware that these services are implemented as a Lambda function. This breaks the &lt;em&gt;isolation&lt;/em&gt; property.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaks Zero-waste
&lt;/h2&gt;

&lt;p&gt;Finally, there is a lot of double-billing going on. While the &lt;code&gt;StoreUserData&lt;/code&gt; is communicating with the backend database, for example, the &lt;code&gt;CreateUser&lt;/code&gt; keeps waiting in idle state before moving to the next task. Even if the code is implemented asynchronously, there will still be some latency in which multiple functions will be billed at the same time. This breaks the &lt;code&gt;zero-waste&lt;/code&gt; property.&lt;/p&gt;

&lt;h1&gt;
  
  
  Considering options
&lt;/h1&gt;

&lt;p&gt;Let's find out whether we can meet all three desired principles while orchestrating our functions. We will cover several different approaches to function composition below, both in the client and in the backend.&lt;/p&gt;

&lt;p&gt;Some of these patterns should be avoided, others are recommended, but have their strong sides and weaknesses and should be considered depending on the context and use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client-side
&lt;/h2&gt;

&lt;p&gt;For processes that have some sort of interaction with a UI (user interface), the orchestration logic could be embedded in the client-side.&lt;/p&gt;

&lt;p&gt;In the user subscription example above, this could be structured as such:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RAkV9LQ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-client-side.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RAkV9LQ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-client-side.png" alt="Client-side Composition"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The client-side software is responsible for invoking each of the endpoints needed for fulfilling the user creation process. All invocations can be executed in parallel to speed up the overall processing time for the end-user.&lt;/p&gt;

&lt;p&gt;There are a few downsides and caveats to this model, though:&lt;/p&gt;

&lt;h3&gt;
  
  
  Lacks reusability
&lt;/h3&gt;

&lt;p&gt;The client-side model makes code reusability harder. Since enabling reusability is one of the main purposes of designing modular component architecture in the first place, it might not be a good fit for our goals.&lt;/p&gt;

&lt;p&gt;The orchestration process is implemented for one single type of client: a web browser. The code implemented for this client cannot be easily transported into a backend serverless environment.&lt;/p&gt;

&lt;p&gt;What happens if, for instance, we would like to support programmatic account creation through an API or CLI (Command Line Interface), instead of a browser UI?&lt;/p&gt;

&lt;p&gt;One could argue: &lt;em&gt;the same Javascript code running in the browser could be used in a NodeJS serverless function&lt;/em&gt;. While that is technically true, from an architectural perspective it may lead to bad implementation.&lt;/p&gt;

&lt;p&gt;By moving this client-side diagram architecture to a backend serverless function, we would be back in a situation similar to the &lt;em&gt;sequential model&lt;/em&gt; described above. In this model, our composition fails to meet all of the three design principles we are looking for.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difficult to handle consistency
&lt;/h3&gt;

&lt;p&gt;What happens if the &lt;code&gt;StoreUserData&lt;/code&gt; function could not reach the database at the moment the account was being created? The user data would remain pending for storage. Database-wise speaking, the account wouldn't have been created yet.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should the client still request the validation e-mail?&lt;/li&gt;
&lt;li&gt;How about the webhook, should it still be notified?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These decisions will all have to be made in the client, increasing the complexity of the software running on the client-side. Depending on the answers to the questions above, it won't be possible to request all three endpoints in parallel. But responding to the user only after a three-step sequential API interaction might be too long.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exposes internal business rules
&lt;/h3&gt;

&lt;p&gt;Some business rules that would ideally be kept private have to be exposed on the client-side for the orchestration to run there. This is inherent to running code on the client-side and can't really be solved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asynchronous Messaging
&lt;/h2&gt;

&lt;p&gt;We covered asynchronous messaging more extensively &lt;a href="https://dashbird.io/knowledge-base/architectural-patterns/asynchronous-messaging/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;in another page&lt;/a&gt;, so we won't go into details about the concept here.&lt;/p&gt;

&lt;p&gt;It is possible to satisfy all three principles with this architecture: substitution, isolation, zero-waste.&lt;/p&gt;

&lt;p&gt;The disadvantages of this approach are when we need more fine-grained control over the workflow logic. The same questions related to handling consistency in the Client-side model also apply here. If one step fails, for example, it is very difficult - if not impossible - to control how other steps of the process should behave.&lt;/p&gt;

&lt;p&gt;That doesn't mean this pattern shouldn't be used. As a matter of fact, it is perhaps one of the most commonly and successfully used patterns for a serverless composition strategy that is both scalable and maintainable. It's just not a good fit for all use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chaining
&lt;/h2&gt;

&lt;p&gt;Each function could be wired up, having one invoking the next after the end of each task execution. The end-user waiting time could be reduced by having the API responding early with a confirmation message that the request was received and is being processed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Msgb7Y-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-chaining.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Msgb7Y-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dashbird.io/images/knowledge-base/architecture/composition-chaining.png" alt="Chaining Composition"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This model unfortunately also breaks some of the design principles we are looking for.&lt;/p&gt;

&lt;p&gt;It is not possible to easily replace a component without affecting other parts of the system. &lt;strong&gt;Substitution&lt;/strong&gt; is broken.&lt;/p&gt;

&lt;p&gt;Different components must be aware of each other and some implementation details are leaked to one another. &lt;strong&gt;Isolation&lt;/strong&gt; is broken. This could be solved by using an internal &lt;a href="https://dashbird.io/knowledge-base/api-gateway/what-is-an-api-gateway/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;API Gateway&lt;/a&gt; or a &lt;a href="https://dashbird.io/knowledge-base/architectural-patterns/message-queue/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;Message Queue&lt;/a&gt; as an interface between components, though.&lt;/p&gt;

&lt;p&gt;The last principle, &lt;strong&gt;Zero-waste&lt;/strong&gt; is satisfied, since there would be no double-billing in this model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asynchronous Orchestrator
&lt;/h2&gt;

&lt;p&gt;This pattern involves the usage of a concept called Finite-state Machine (FSM). If you are not familiar, please take a look at &lt;a href="https://dashbird.io/blog/introduction-to-step-functions/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=architectural-patterns"&gt;this introductory article&lt;/a&gt; we published recently before moving forward.&lt;/p&gt;

&lt;p&gt;In an FSM, it is possible to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easily replace components without breaking the rest of the system&lt;/li&gt;
&lt;li&gt;Have components acting as complete black-boxes, without knowledge of each other or implementation details leakage&lt;/li&gt;
&lt;li&gt;Avoid double-billing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some additional advantages to this pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run multiple tasks in parallel&lt;/li&gt;
&lt;li&gt;Easily handle retry in case of failure in a specific step of the process&lt;/li&gt;
&lt;li&gt;Handle complex logic such as:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if Step_1 returns True:
    run Step_2
else:
    run Step_3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Along with Asynchronous Messaging discussed above, this is one of the most commonly and successfully used patterns for serverless functions composition.&lt;/p&gt;

&lt;p&gt;Although it is a bit more difficult to implement, deploy and test, it meets the needs of more complex workflows while still delivering a scalable and maintainable architectural design.&lt;/p&gt;

&lt;p&gt;Most cloud service providers will have managed/serverless offerings of an FSM, which greatly simplifies the implementation and maintenance. AWS, for example, has the &lt;a href="https://aws.amazon.com/step-functions/"&gt;StepFunctions&lt;/a&gt; service.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://essay.utwente.nl/79476/1/Bolscher_MA_EWI.pdf"&gt;Leveraging Serverless Cloud Computing Architectures (Master Thesis)&lt;/a&gt;, by R.T.J. Bolscher&lt;/p&gt;

&lt;p&gt;&lt;a href="https://researcher.watson.ibm.com/researcher/files/us-tardieu/debs19.pdf"&gt;Composition of Serverless Functions&lt;/a&gt;, by Olivier Tardieu&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/pdf/1807.11248.pdf"&gt;Comparison of FaaS Orchestration Systems&lt;/a&gt;, by Pedro García López, Marc Sánchez-Artigas, Gerard París, Daniel Barcelona Pons, Álvaro Ruiz Ollobarren and David Arroyo Pinto&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dl.acm.org/doi/abs/10.1145/3133850.3133855?download=true"&gt;The serverless trilemma: function composition for serverless computing&lt;/a&gt;, by Ioana Baldini, Perry Cheng, Stephen Jason Fink, Nick Mitchell, Vinod Muthusamy, Rodric M. Rabbah, Philippe Suter, Olivier Tardieu&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>patterns</category>
      <category>serverless</category>
      <category>awslambda</category>
    </item>
    <item>
      <title>Solve The Cold Start Issue with Lambda Provisioned Concurrency</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Mon, 09 Dec 2019 12:57:47 +0000</pubDate>
      <link>https://forem.com/byrro/solve-the-cold-start-issue-with-lambda-provisioned-concurrency-54mj</link>
      <guid>https://forem.com/byrro/solve-the-cold-start-issue-with-lambda-provisioned-concurrency-54mj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://dashbird.io/blog/aws-lambda-provisioned-concurrency/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=reinvent&amp;amp;utm_content=lambda-provisioned-concurrency"&gt;Originally published in Dashbird Blog&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://dashbird.io/blog/cold-starts-impact/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=reinvent&amp;amp;utm_content=lambda-provisioned-concurrency"&gt;Cold Starts&lt;/a&gt; have been a massive issue with FaaS. In summary, it makes functions slower to startup in some cases. That's in the opposite way of every effort to improve web applications performance.&lt;/p&gt;

&lt;p&gt;Many &lt;a href="https://dashbird.io/blog/can-we-solve-serverless-cold-starts/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=reinvent&amp;amp;utm_content=lambda-provisioned-concurrency"&gt;efforts&lt;/a&gt; have been made in the recent years to &lt;a href="https://github.com/dashbird/xlambda"&gt;solve&lt;/a&gt; AWS Lambda cold starts or &lt;a href="https://dashbird.io/blog/reducing-cold-start-impact/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=reinvent&amp;amp;utm_content=lambda-provisioned-concurrency"&gt;educate on handling&lt;/a&gt; them. Many have mitigated the issue, but none really solved it.&lt;/p&gt;

&lt;p&gt;AWS has just made a great progress on the area with the Provisioned Capacity feature announcement. As the function scales up, instead of waiting new requests to come in before provisioning resources to serve them, AWS will proactively provision new instances of the function in advance.&lt;/p&gt;

&lt;p&gt;This behavior guarantees the performance of &lt;strong&gt;every request&lt;/strong&gt; will stay within &lt;strong&gt;double digit milliseconds&lt;/strong&gt;, up to the Provisioned Concurrency threshold set to the function. There are some caveats that developers should be aware though. For example: it makes your functions inelligible to the Lambda Free Tier.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://dashbird.io/knowledge-base/aws-lambda/provisioned-concurrency/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=reinvent&amp;amp;utm_content=lambda-provisioned-concurrency"&gt;Here is a detailed and step-by-step guide to learn everything about this feature&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Lambda Provisioned Concurrency is &lt;a href="https://aws.amazon.com/pt/about-aws/whats-new/2019/12/aws-lambda-announces-provisioned-concurrency/"&gt;generally available in several regions&lt;/a&gt; and already integrated with AWS SAM, CodeDeploy and other serverless frameworks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Image credits to &lt;a href="https://unsplash.com/@dnevozhai?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Denys Nevozhai&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/traffic?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>awslambda</category>
      <category>concurrency</category>
      <category>coldstart</category>
    </item>
    <item>
      <title>If You Learn to Build Scalable Applications, You Can Change Your Career</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Mon, 25 Nov 2019 14:40:31 +0000</pubDate>
      <link>https://forem.com/dashbird/if-you-learn-to-build-scalable-applications-you-can-change-your-career-42le</link>
      <guid>https://forem.com/dashbird/if-you-learn-to-build-scalable-applications-you-can-change-your-career-42le</guid>
      <description>&lt;h1&gt;
  
  
  What we're up to
&lt;/h1&gt;

&lt;p&gt;The web is huge, and it's getting bigger. Every. Single. Minute.&lt;/p&gt;

&lt;p&gt;More people. Doing more things. Using more devices. On faster connections.&lt;/p&gt;

&lt;p&gt;Everything indicates that load pressure over all kinds of applications is only up to increase: from small to big ones, from B2C through B2B. More companies will need teams that can deliver on the scalability promise.&lt;/p&gt;

&lt;p&gt;Likely, only a handful out of every 100 developers nowadays is really into building things that can scale. You can be at the top of the market.&lt;/p&gt;

&lt;h1&gt;
  
  
  First Steps
&lt;/h1&gt;

&lt;p&gt;A scalable system is one that can continue to perform in a &lt;a href="https://dashbird.io/knowledge-base/basic-concepts/reliability/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;reliable manner&lt;/a&gt; under highly variable and often increasing levels of load.&lt;/p&gt;

&lt;p&gt;A system's scalability problem is rarely a single variable analysis. It usually involves at least two-dimensional thinking: a &lt;strong&gt;load metric&lt;/strong&gt; and a &lt;strong&gt;time-period&lt;/strong&gt;. More often than not, it's a multi-dimensional beast.&lt;/p&gt;

&lt;p&gt;Some two-dimension problem examples are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How does the database system scales when IOPS&lt;sup id="fnref1"&gt;1&lt;/sup&gt; increases from 1,000 to 10,000 over one second?&lt;/li&gt;
&lt;li&gt;How load time is affected when website pageview requests grow from 200 to 5,000 over one minute?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bear with me along the next lines to understand the multi-dimension ones.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fz9t8dan35zw39shux4pb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fz9t8dan35zw39shux4pb.jpg" alt="Hands with elastic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Load Profile
&lt;/h1&gt;

&lt;p&gt;What we first need is to express what load means for each of our systems.&lt;/p&gt;

&lt;p&gt;For a website, load can be online visitors or pageviews per second. For a database, it could be concurrent queries, the number of I/O operations, or the amount of data getting in and out.&lt;/p&gt;

&lt;p&gt;How load is described also depends on the system architecture and the business case. This is where things start to get complicated.&lt;/p&gt;

&lt;p&gt;In an e-commerce website, for example, the system may scale well to serve 10,000 people shopping at the same time across a thousand-item catalog. But what happens if a huge group is shopping for a single item?&lt;/p&gt;

&lt;p&gt;Perhaps a very positive review by popular social-influencer just went viral on social networks.&lt;/p&gt;

&lt;p&gt;We don't wanna be the ones explaining why the hot moment was missed due to system restrictions.&lt;/p&gt;

&lt;h1&gt;
  
  
  When scalability collides with consistency
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7egdpmpykxnj9hyumfhq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7egdpmpykxnj9hyumfhq.jpg" alt="Bull collision"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take a scalable database system. It will employ some sort of multi-node replication. Think of it as the product description, price, etc. replicated across different servers to handle a huge amount of &lt;strong&gt;read&lt;/strong&gt; requests.&lt;/p&gt;

&lt;p&gt;If each server can manage 1,000 RPS (req. per sec.) and we need to handle 10,000 RPS, we'll need at least 10 of those servers. The same data will be replicated in all of them. One will act as the main server to receive updates or delete requests. Once a data point is modified, the main server will notify the other servers to follow along with the update.&lt;/p&gt;

&lt;p&gt;This is usually called a Master-Slave replication system&lt;sup id="fnref2"&gt;2&lt;/sup&gt; and is very common in database setups.&lt;/p&gt;

&lt;p&gt;Think about consistency now. You know "over-booking" in airline seats? That's sort of a consistency issue. Airlines do it consciously. But we don't want two shoppers ordering the same physical item, because the store won't be able to fulfill both orders.&lt;/p&gt;

&lt;p&gt;When a purchase is confirmed, the system will decrement the number of items available in stock. And here comes the problem: the DB might be able to handle decrementing hundreds of different items at once. But what happens if thousands try to decrement the same value in a very short period?&lt;/p&gt;

&lt;p&gt;This is the sort of circumstance that happens due to market trends and human behavior. Developers must account for these factors when thinking about load and scalability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvktvxscgqcou54sesqla.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvktvxscgqcou54sesqla.jpg" alt="Woman Stretching"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Handling Load
&lt;/h1&gt;

&lt;p&gt;The more we strive to anticipate possible challenging load scenarios for the system, the better it will perform in reality.&lt;/p&gt;

&lt;p&gt;It is necessary to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The load profiles and metrics&lt;/li&gt;
&lt;li&gt;How much and how fast load can vary&lt;/li&gt;
&lt;li&gt;Which resources are needed to cope with these variations without hurting performance or reliability&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Thinking about load profile
&lt;/h2&gt;

&lt;p&gt;Let's dive deeper into the e-commerce example.&lt;/p&gt;

&lt;p&gt;Say the shopping cart module is responsible for checking an item's availability before confirming a purchase. A naive approach is to read the number of items available in the product's profile stored in the database and decrement it right after confirming its availability.&lt;/p&gt;

&lt;p&gt;That strategy can lead to bottlenecks and crash under increasing loads because all order requests will be rushing to decrement the same value consistently. Not only the master node but all replicas must be updated at the same time to ensure consistency.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fys07bp1id9fmjf1in5px.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fys07bp1id9fmjf1in5px.jpg" alt="Hands holding plants"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Better approaches
&lt;/h3&gt;

&lt;p&gt;One solution would be using Multi-Master&lt;sup id="fnref3"&gt;3&lt;/sup&gt; replication. This type of system provides the logic to handle concurrent requests. It is usually not trivial to implement, though. &lt;/p&gt;

&lt;p&gt;Some database services will provide multi-master out of the box. This is the case of the serverless &lt;a href="https://dashbird.io/knowledge-base/dynamodb/overview-and-main-concepts/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;DynamoDB&lt;/a&gt; service, by AWS.&lt;/p&gt;

&lt;p&gt;Using this type of service can save a lot of time. Instead of solving the infrastructure cluster and low-level replication issues, we can focus on the scalability issues specific to the user problem at hand.&lt;/p&gt;

&lt;p&gt;Another possibility is using a message queue as a buffer, instead of having the shopping cart rushing directly to the database. All the ordered items are placed into a queue. A background job is responsible for pulling orders from the queue and processing them (check availability, decrement stock, etc).&lt;/p&gt;

&lt;p&gt;Once all items from an order are processed, another background job can confirm the customer's purchase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F907fwdkq29rx9m9ipahy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F907fwdkq29rx9m9ipahy.png" alt="Message Queue Buffer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The queue buffer decouples the front and backend systems from the database and allows each to scale separately. It makes tackling scalability challenges much easier. Even when using a Multi-Master database, the message buffer is usually a good architectural pattern to consider.&lt;/p&gt;

&lt;p&gt;How load is profiled and scalability challenges are tackled will depend a lot on the use case. There is no one-size-fits-all strategy here.&lt;/p&gt;

&lt;p&gt;And here is where you can differentiate yourself in your software career. For many companies (not only larger but especially startups that need to grow fast), it is a must-have for the DEV team to think about scalability, anticipate challenges and build a resilient and scalable system.&lt;/p&gt;

&lt;p&gt;Learn how to scale systems, and you can change your career. At the end of this article, there is an indication of a great book, in case you'd like to dive deeper. It's not easy and you can never study the topic too much.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thinking about resources
&lt;/h2&gt;

&lt;p&gt;Resources can scale:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vertically (&lt;em&gt;scale-up&lt;/em&gt;): increasing CPU power or RAM, for example&lt;/li&gt;
&lt;li&gt;Horizontally (&lt;em&gt;scale-out&lt;/em&gt;): adding more servers to a cluster, for instance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F97pdmacvkmfqgzjmpsjw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F97pdmacvkmfqgzjmpsjw.jpg" alt="Vertical vs Horizontal Scaling"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A great number of healthy architectures will mix both approaches. Sometimes, having many small servers is cheaper than a few high-end machines, especially for highly variable loads. Large machines can lead to increased over-provisioning and wasted idle resources.&lt;/p&gt;

&lt;p&gt;When load scales down, it's much easier to kill a couple of idle small machines than to frequently move a system from big to smaller machines.&lt;/p&gt;

&lt;p&gt;In other cases, perhaps a big machine would perform faster and cheaper than a cluster of small ones.&lt;/p&gt;

&lt;p&gt;It depends on the case and developers must try different approaches to find one that suits both performance requirements and project budget.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://dashbird.io/knowledge-base/basic-concepts/what-is-serverless/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;serverless systems&lt;/a&gt; greatly simplifies the level of responsibility developers have over how systems cope with load. These services abstract away decision-making about &lt;em&gt;scaling-up&lt;/em&gt; or &lt;em&gt;out&lt;/em&gt;, for example, and also provide SLAs that the development team can rely on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0jd7og4i00vdi5im1ja0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0jd7og4i00vdi5im1ja0.png" alt="Serverless Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned above, one great database service is &lt;a href="https://dashbird.io/knowledge-base/dynamodb/overview-and-main-concepts/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;AWS DynamoDB&lt;/a&gt;. It solves the lower level scalability and availability issues out of the box.&lt;/p&gt;

&lt;p&gt;For small and mid-sized teams, projects that need short time-to-market and fast iterations, using services like &lt;a href="https://dashbird.io/knowledge-base/dynamodb/overview-and-main-concepts/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;DynamoDB&lt;/a&gt; can be a great competitive advantage. It allows us to abstract away undifferentiated infrastructure issues to focus on the scalability challenges of the business case at hand.&lt;/p&gt;

&lt;p&gt;Mastering these types of services is also a great knowledge acquisition in a developer's scalability belt. Check this &lt;a href="https://dashbird.io/knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;Knowledge Base&lt;/a&gt; to learn more about scalable databases, compute engines and more.&lt;/p&gt;

&lt;h1&gt;
  
  
  Load Metrics and Statistics
&lt;/h1&gt;

&lt;p&gt;Metrics will need some sort of aggregation or statistical representation. Average (arithmetical mean) is usually a bad way to represent metrics because it can be misleading. It doesn't tell how many users experienced that level of performance. In reality, no user might have experienced it at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnfn3ngn6p2ljadjoyk7l.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnfn3ngn6p2ljadjoyk7l.jpg" alt="Metrics Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider the following application load and user base:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;User&lt;/th&gt;
&lt;th&gt;Response time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;210 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;250 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;240 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;20 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The average response time would be 180 milliseconds. But no user experienced that response time. 75% of the users experienced a performance that is worse than average. The arithmetic mean is highly sensitive to outliers, which is the case of the distribution above.&lt;/p&gt;

&lt;p&gt;This is why percentiles are more commonly used to express systems performance. They are also the basis for service level objectives (SLOs)&lt;sup id="fnref4"&gt;4&lt;/sup&gt; and agreements (SLAs)&lt;sup id="fnref5"&gt;5&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;The most common percentiles are 95th, 99th, and 99.9th (also referred to as p95, p99, and p999).&lt;/p&gt;

&lt;p&gt;A p95 level is a threshold in which at least 95% of the response times fall below. In the example above, our p95 would be 250 ms. Since we have only a handful of request samples, it would be the same threshold for all percentiles. If we were to compute a p75, it would be 240 ms, meaning: three out of four (75%) of the requests were served within 240 milliseconds.&lt;/p&gt;

&lt;h1&gt;
  
  
  Wrapping up
&lt;/h1&gt;

&lt;p&gt;Thinking about a system load and preparing it to scale smoothly under different load profiles is no easy task. That is precisely why you should get better at it.&lt;/p&gt;

&lt;p&gt;Gone are the times when only a handful of applications on the web needed to worry about scale. The web is already huge, and it's getting bigger.&lt;/p&gt;

&lt;p&gt;More and more people are joining it every day. With more devices: laptops, smartphones, tablets, smartwatches, smart glasses, smart rings... Who knows what else they'll &lt;em&gt;smart'ify&lt;/em&gt; next!?&lt;/p&gt;

&lt;p&gt;IoT devices are exploding. Networks are only getting faster.&lt;/p&gt;

&lt;p&gt;As I said in the beginning: everything indicates that load pressure over all kinds of applications is only up to increase. More and more companies will need teams that can provide scalable systems.&lt;/p&gt;

&lt;p&gt;You can be one of the few, top 1% of the market delivering it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dashbird.io/subscribe-knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=article&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=basic-concepts"&gt;Subscribe to our Knowledge Base&lt;/a&gt; and receive notifications when we publish content similar to this one.&lt;/p&gt;

&lt;h1&gt;
  
  
  Acknowledgements and Footnotes
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;This article was heavily inspired by the &lt;a href="http://shop.oreilly.com/product/0636920032175.do" rel="noopener noreferrer"&gt;Designing Data-Intensive Aplications&lt;/a&gt; book, by &lt;a href="https://www.linkedin.com/in/martinkleppmann/" rel="noopener noreferrer"&gt;Martin Kleppmann&lt;/a&gt;. I strongly recommend the read if you are interested in getting deeper into the topic.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cover Image by &lt;a href="https://unsplash.com/@kateelue?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Katee Lue&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/stretch?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Holding plants image by &lt;a href="https://unsplash.com/@artic_studios?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Daniel Hjalmarsson&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/grow?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hands with elastic image by &lt;a href="https://unsplash.com/@neonbrand?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;NeONBRAND&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/elastic?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Woman stretching image by &lt;a href="https://unsplash.com/@andresloquesea?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Andrés Gómez&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/stretch?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Metrics dashboard image by &lt;a href="https://unsplash.com/@lukechesser?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Luke Chesser&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/metrics?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Bull collision image by &lt;a href="https://unsplash.com/@soberanes?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Uriel Soberanes&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/collision?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Vertical vs. Horizontal scaling &lt;a href="https://images.squarespace-cdn.com/content/v1/5ab6b93e5b409be7fa331cf1/1523001777249-CYQZIR0WV2SY3DR6KCTF/ke17ZwdGBToddI8pDm48kKV1s-T0nWNuwjqsNjsPwcFZw-zPPgdn4jUwVcJE1ZvWQUxwkmyExglNqGp0IvTJZUJFbgE-7XRK3dMEBRBhUpxDzIMjWIPEzafHMdHfN3QHBei96SzLB0UzwOTDCJoQCaAoTr99QRu9sX7E0VnQKhI/Horizontal_Scaling_Vertical_Scaling_Comparison.jpg" rel="noopener noreferrer"&gt;image&lt;/a&gt; by &lt;a href="https://www.accionlabs.com/articles/2018/4/6/horizontal-versus-vertical-scaling-which-is-right-for-you" rel="noopener noreferrer"&gt;AccionLabs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Message queue buffer &lt;a href="https://blog.cdemi.io/content/images/2016/12/Queue-Based-Load-Levelling-min.png" rel="noopener noreferrer"&gt;image&lt;/a&gt; by &lt;a href="https://blog.cdemi.io/design-patterns-queue-based-load-leveling-pattern/" rel="noopener noreferrer"&gt;Christopher Demicoli&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Serverless architecture &lt;a href="https://www.ritchievink.com/img/post-17-serverless_model/serverless-architecture.png" rel="noopener noreferrer"&gt;image&lt;/a&gt; by &lt;a href="https://www.ritchievink.com/blog/2018/09/16/deploy-any-machine-learning-model-serverless-in-aws/" rel="noopener noreferrer"&gt;Ritchie Vink&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/IOPS" rel="noopener noreferrer"&gt;IOPS: Input/Output Operations Per Second&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Master/slave_(technology)" rel="noopener noreferrer"&gt;Master/Slave (technology)&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Database_replication" rel="noopener noreferrer"&gt;Database Replication&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn3"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Multi-master_replication" rel="noopener noreferrer"&gt;Multi-Master Replication&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn4"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Service-level_objective" rel="noopener noreferrer"&gt;SLO: Service Level Objective&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn5"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Service-level_agreement" rel="noopener noreferrer"&gt;SLA: Service Level Agreement&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>aws</category>
      <category>serverless</category>
    </item>
    <item>
      <title>In a RollerCoaster-Driven Development Era, We Must Connect the Dots</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Fri, 15 Nov 2019 11:46:26 +0000</pubDate>
      <link>https://forem.com/dashbird/in-a-rollercoaster-driven-development-era-we-must-connect-the-dots-183k</link>
      <guid>https://forem.com/dashbird/in-a-rollercoaster-driven-development-era-we-must-connect-the-dots-183k</guid>
      <description>&lt;h1&gt;
  
  
  🎢 RollerCoaster-Driven Development
&lt;/h1&gt;

&lt;p&gt;Software development has evolved at a thrilling pace in the past years. Every developer has felt genuinely overwhelmed at some point, undoubtedly.&lt;/p&gt;

&lt;p&gt;You might be feeling overwhelmed &lt;strong&gt;right now&lt;/strong&gt; with so much to learn and account for in your work. 😟&lt;/p&gt;

&lt;p&gt;How many frontend frameworks have we had to learn in five years? How many more there will be in the next ones?&lt;/p&gt;

&lt;p&gt;A big stone in the developer journey is finding and organizing trusted sources for learning and advancing its knowledge and capabilities.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Am I doing this right? Is there a better way? 😰&lt;br&gt;
Where can I find a trusted reference for good practices for this?&lt;br&gt;
Is this the most accurate and up-to-date resource for learning &lt;em&gt;XYZ&lt;/em&gt;?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Too-much, Too-little
&lt;/h1&gt;

&lt;p&gt;We never had so much information and knowledge readily available like today.&lt;/p&gt;

&lt;p&gt;That is absolutely true. 👏&lt;/p&gt;

&lt;p&gt;But all this content is scattered. Disorganized. No time-relevancy ordering. Difficult to navigate and reason. It's hard to connect the dots. &lt;/p&gt;

&lt;p&gt;There only so much that search engines can do to help ourselves.&lt;/p&gt;

&lt;p&gt;Javascript. Typescript. Node.js. Python. SPA. Cloud. Serverless. Less than 20% of technologies available dominate +80% of modern web development stack.&lt;/p&gt;

&lt;p&gt;So why does everyone have to go through the very same learning pains over and over? Thousands of developers have to learn the same things. But all. Same. Pain! Why? ❓&lt;/p&gt;

&lt;h1&gt;
  
  
  ✨ Connecting the Dots
&lt;/h1&gt;

&lt;p&gt;We've suffered enough with these pains at &lt;a href="https://dashbird.io/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=announcement"&gt;Dashbird&lt;/a&gt; while cracking our minds around finding the best ways to successful cloud serverless implementations.&lt;/p&gt;

&lt;p&gt;We decided to stop. Start to organize everything we find valuable for developers. Compile it in an open repository. A single one. Always up-to-date. :neckbeard:&lt;/p&gt;

&lt;p&gt;We called it &lt;a href="https://dashbird.io/knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=announcement"&gt;Cloud Knowledge Base&lt;/a&gt;. It is about connecting the dots. So that you don't have to.&lt;/p&gt;

&lt;p&gt;It aims to cover everything related to web and mobile development. From &lt;strong&gt;basic concepts&lt;/strong&gt; to &lt;strong&gt;productivity tooling&lt;/strong&gt; to &lt;strong&gt;advanced architectural patterns&lt;/strong&gt;. As well as reliable cloud services that enable successful implementations.&lt;/p&gt;

&lt;p&gt;The MVP is live now. 🚀 We will keep working consistently. Perfecting what's published. Expanding with new content. Every day, week, month.&lt;/p&gt;

&lt;p&gt;As in any startup endeavor, we kicked off an MVP with a minimal set of topics covered. Subscribe to receive updates 🔥 (by &lt;a href="https://dashbird.io/subscribe-knowledge-base/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=knowledge-base&amp;amp;utm_content=announcement"&gt;email&lt;/a&gt; or &lt;a href="https://dashbird.io/knowledge-base/index.xml"&gt;Atom feed&lt;/a&gt;) as we push forward.&lt;/p&gt;

&lt;p&gt;Suggestions and contributions from the development community are more than welcome. Let us know which topics you'd like to see covered, or if you have anything to share or ask: &lt;a href="//mailto:renato@dashbird.io"&gt;renato@dashbird.io&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Cover image credits: &lt;a href="https://unsplash.com/@shateley?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Stephen Hateley&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/rollercoaster?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>javascript</category>
      <category>node</category>
      <category>python</category>
    </item>
    <item>
      <title>Last Chance to Join: Design Patterns for Secure and Scalable APIs on AWS Lambda</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Thu, 31 Oct 2019 13:38:53 +0000</pubDate>
      <link>https://forem.com/dashbird/last-chance-to-join-design-patterns-for-secure-and-scalable-apis-on-aws-lambda-jhh</link>
      <guid>https://forem.com/dashbird/last-chance-to-join-design-patterns-for-secure-and-scalable-apis-on-aws-lambda-jhh</guid>
      <description>&lt;p&gt;&lt;a href="https://zoom.us/webinar/register/WN_nVMlXyd3TFmujapq8PNKcw"&gt;Join our Tech Talk today&lt;/a&gt; with &lt;a href="https://dev.to/eoinsha"&gt;Eoin Shanaghy&lt;/a&gt; (CTO @ &lt;a href="https://fourtheorem.com/"&gt;fourTheorem&lt;/a&gt;) on:&lt;/p&gt;

&lt;h2&gt;
  
  
  Securing APIs on AWS Lambda
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Learn &lt;strong&gt;proven&lt;/strong&gt; and &lt;strong&gt;scalable&lt;/strong&gt; architectural patterns to secure internal APIs on AWS Lambda 🔐&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hands-on&lt;/strong&gt; presentation, from &lt;strong&gt;technical implementation&lt;/strong&gt; to architectural &lt;strong&gt;decision factors&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interact&lt;/strong&gt; with panelists to address your questions in &lt;strong&gt;real-time&lt;/strong&gt; 💬&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://zoom.us/webinar/register/WN_nVMlXyd3TFmujapq8PNKcw"&gt;Reserve your seat now&lt;/a&gt;.
&lt;/h2&gt;

</description>
      <category>serverless</category>
      <category>lambda</category>
      <category>awslambda</category>
      <category>apigateway</category>
    </item>
    <item>
      <title>Is There a Cat in The Code!?</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Thu, 24 Oct 2019 19:32:22 +0000</pubDate>
      <link>https://forem.com/byrro/there-s-a-cat-in-the-code-4fh2</link>
      <guid>https://forem.com/byrro/there-s-a-cat-in-the-code-4fh2</guid>
      <description>&lt;p&gt;Just saw this on &lt;a href="https://twitter.com/kaydacode/status/1187364168489459712" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd9xed2wpibj6w0cebg13.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd9xed2wpibj6w0cebg13.PNG" alt="There's a cat in the code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😆 😆 &lt;/p&gt;

</description>
      <category>jokes</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How I Fixed JWT Security Flaws in 3 Steps</title>
      <dc:creator>Renato Byrro</dc:creator>
      <pubDate>Mon, 14 Oct 2019 08:31:57 +0000</pubDate>
      <link>https://forem.com/dashbird/how-i-fixed-jwt-security-flaws-in-3-steps-264k</link>
      <guid>https://forem.com/dashbird/how-i-fixed-jwt-security-flaws-in-3-steps-264k</guid>
      <description>&lt;h3&gt;
  
  
  There are just too many ways to do JWT wrong. 😢
&lt;/h3&gt;

&lt;p&gt;And I fell for some... Don't panic, but it's likely to be your case as well.&lt;/p&gt;

&lt;p&gt;Check these 3 commonly overlooked security areas on JWT implementations. It will take only a few minutes.&lt;/p&gt;




&lt;h1&gt;
  
  
  1) Broken libraries
&lt;/h1&gt;

&lt;p&gt;There are +1,600 libraries &lt;a href="https://www.npmjs.com/search?q=jwt" rel="noopener noreferrer"&gt;matching "jwt" on npm&lt;/a&gt;. 😳&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6rj1v12f7myg36pt6fu9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6rj1v12f7myg36pt6fu9.PNG" alt="npm jwt libraries"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And &lt;a href="https://pypi.org/search/?q=jwt" rel="noopener noreferrer"&gt;+300 on Pypi&lt;/a&gt;. 😲&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2nijzxuld30pejlvu5st.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2nijzxuld30pejlvu5st.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do we need them all? Certainly not. Are they all secure? I won't trust. 😖&lt;/p&gt;

&lt;p&gt;There are &lt;a href="https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/" rel="noopener noreferrer"&gt;several ways&lt;/a&gt; your JWT library of choice might be compromised.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we cut to a simple solution?
&lt;/h3&gt;

&lt;p&gt;Yes, I am also bored with security blah, blah, blah. 💤&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://jwt.io/#libraries" rel="noopener noreferrer"&gt;this resource&lt;/a&gt; and double-check which libraries follow practices proven to be safe. Most will by now. But better safe than sorry.&lt;/p&gt;




&lt;h1&gt;
  
  
  2) Unsafe token generation and distribution
&lt;/h1&gt;

&lt;p&gt;The &lt;em&gt;joyfull&lt;/em&gt; implementation: 🍀&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;a. Frontend requests user authentication&lt;/p&gt;

&lt;p&gt;b. Backend authenticates and generates JWT&lt;/p&gt;

&lt;p&gt;c. JWT is sent in the response body payload&lt;/p&gt;

&lt;p&gt;d. Frontend store JWT in the &lt;code&gt;localStorage&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ah, yes... The world would be beautiful without &lt;a href="https://hackernoon.com/can-timing-attack-be-a-practical-security-threat-on-jwt-signature-ba3c8340dea9" rel="noopener noreferrer"&gt;bad guys&lt;/a&gt; and if &lt;a href="https://medium.com/101-writeups/hacking-json-web-token-jwt-233fe6c862e6" rel="noopener noreferrer"&gt;ugly things&lt;/a&gt; could &lt;a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/january/jwt-attack-walk-through/" rel="noopener noreferrer"&gt;not happen&lt;/a&gt;. 😇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fulqxllccxbtqk6ah6wdf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fulqxllccxbtqk6ah6wdf.jpg" alt="Cupcakes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well. Back to the real world. 😎&lt;/p&gt;

&lt;p&gt;Avoid following the above outline.&lt;/p&gt;

&lt;p&gt;To help with items (a) &amp;amp; (b), make sure you selected a JWT library that follows best practices. Or that you implemented correctly on your own. Not that difficult really. Just care enough.&lt;/p&gt;

&lt;p&gt;It's also &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html#which-events-to-log" rel="noopener noreferrer"&gt;good practice&lt;/a&gt; to log every authentication attempt (success and failures) and all contextual data you may possibly have.&lt;/p&gt;

&lt;p&gt;JWT is frequently used in &lt;a href="https://serverless-stack.com/chapters/what-is-serverless.html" rel="noopener noreferrer"&gt;Serverless&lt;/a&gt; environments (because both are stateless, niiice!).&lt;/p&gt;

&lt;p&gt;If that's your case, make sure you have &lt;a href="https://dashbird.io/blog/top-serverless-monitoring-tools/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=article&amp;amp;utm_content=educational"&gt;professionals monitoring your logs&lt;/a&gt; and alerting you proactively. If that's not your case, the advice still holds. 😉&lt;/p&gt;

&lt;p&gt;To address items (c) &amp;amp; (d):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Do not&lt;/strong&gt; send JWT in the &lt;strong&gt;response body&lt;/strong&gt; payload&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do not&lt;/strong&gt; store JWT in &lt;strong&gt;&lt;code&gt;localStorage&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Problem is: any JavaScript code in your frontend is able to access the JWT. And do whatever it wants.&lt;/p&gt;

&lt;h2&gt;
  
  
  And that's &lt;a href="https://developer.okta.com/blog/2018/06/20/what-happens-if-your-jwt-is-stolen" rel="noopener noreferrer"&gt;dangerous&lt;/a&gt;.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6urds06z62day9urqo5i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6urds06z62day9urqo5i.jpg" alt="scorpion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine what can happen if someone manages to inject malicious code in your frontend... and get all your users' JWTs?... Hum... Houston...&lt;/p&gt;

&lt;p&gt;No. Instead, the backend should set the JWT as a cookie in the user browser. Make sure you flag it as &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies" rel="noopener noreferrer"&gt;&lt;code&gt;Secure&lt;/code&gt; and &lt;code&gt;httpOnly&lt;/code&gt; cookie&lt;/a&gt;. And &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#SameSite_cookies" rel="noopener noreferrer"&gt;&lt;code&gt;SameSite&lt;/code&gt; cookie&lt;/a&gt;. Boy, that's a multi-flavor cookie.&lt;/p&gt;

&lt;p&gt;This way, the JWT will be available to the backend in all subsequent requests, while remaining outside the reach of potentially dirty JS hands.&lt;/p&gt;

&lt;p&gt;In your response body payload, send only what's necessary for the frontend to provide the features expected by the user. Did I mention to not include anything sensitive here? Should not.&lt;/p&gt;

&lt;p&gt;I know. A cookie is not as cool as &lt;code&gt;localStorage&lt;/code&gt;. But, look, they can be colorful! And &lt;strong&gt;SAFE&lt;/strong&gt;. He's our friend. Let's treat him well. Deal? 🙌 🍪&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fshhl4a23fvu12hmc4l6c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fshhl4a23fvu12hmc4l6c.jpg" alt="Cookies/Macarrons"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  3) Not handling secret keys securely
&lt;/h1&gt;

&lt;p&gt;Any JWT implementation will involve some sort of secret data. Regardless of using a symmetric (one secret key) or an asymmetric (public/private keys) way to sign tokens.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Personally, I prefer symmetric implementations with HMAC. Simplifies things. But sometimes I use asymmetric RSA. Lately, I have been using the latter only. Well, they'll never know which one I really use. 😜&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No one should ever know how &lt;strong&gt;YOU&lt;/strong&gt; implement JWT either. Not to mention your secret or private keys.&lt;/p&gt;

&lt;p&gt;Things you should avoid doing with your secret/private key when possible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💻 Storing in a &lt;code&gt;config&lt;/code&gt; file and committing to your Git repo&lt;/li&gt;
&lt;li&gt;📣 Sharing with your team on your Drive, Dropbox, Slack, whatever&lt;/li&gt;
&lt;li&gt;♻️ Having the same keys for local, test, and production environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✌️ Distribute keys for your development team to use only in local and testing environments&lt;/li&gt;
&lt;li&gt;👍 Store production keys in a safe place, only available to the production app&lt;/li&gt;
&lt;li&gt;🔐 Keep the production keys away from prying eyes, load them as environment variables, on-demand, protected against unintended access&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Further reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/" rel="noopener noreferrer"&gt;Auth0 blog post&lt;/a&gt; about vulnerabilities on JWT libraries&lt;/li&gt;
&lt;li&gt;OWASP cheatsheet &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html" rel="noopener noreferrer"&gt;about JWT&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OWASP cheatsheet on &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Key_Management_Cheat_Sheet.html" rel="noopener noreferrer"&gt;managing security keys&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dashbird.io/blog/securing-serverless-with-critical-logs/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=article&amp;amp;utm_content=educational"&gt;Critical security logs&lt;/a&gt; on Serverless applications&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Full disclosure&lt;/strong&gt;: I work as a Developer Advocate at &lt;a href="https://dashbird.io/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=article&amp;amp;utm_content=educational"&gt;Dashbird&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Image credits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cover image: &lt;a href="https://unsplash.com/@vincentvanzalinge?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Vincent van Zalinge&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/tiger?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cupcakes: &lt;a href="https://unsplash.com/@sonance?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Viktor Forgacs&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/candies?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Scorpion: &lt;a href="https://unsplash.com/@shayyyyyyyna?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Shayna Take&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/scorpion?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cookies (not really, they're actually &lt;em&gt;macarrons&lt;/em&gt;): &lt;a href="https://unsplash.com/@mockaroon?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Mockaroon&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/cookie-colorful?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>jwt</category>
      <category>security</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
