<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chris More</title>
    <description>The latest articles on DEV Community by Chris More (@chrismore).</description>
    <link>https://dev.to/chrismore</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%2F733878%2F574229c4-e459-4725-b7ff-23510cb40127.jpeg</url>
      <title>DEV Community: Chris More</title>
      <link>https://dev.to/chrismore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chrismore"/>
    <language>en</language>
    <item>
      <title>Scalable CRON job executor for AWS Lambda</title>
      <dc:creator>Chris More</dc:creator>
      <pubDate>Thu, 30 Dec 2021 14:41:02 +0000</pubDate>
      <link>https://dev.to/chrismore/scalable-cron-job-executor-for-aws-lambda-3p98</link>
      <guid>https://dev.to/chrismore/scalable-cron-job-executor-for-aws-lambda-3p98</guid>
      <description>&lt;p&gt;Running scheduled jobs at scale in the cloud is an interesting problem to solve. In this post I will describe an architecture we came up with at &lt;a href="https://fusebit.io/" rel="noopener noreferrer"&gt;Fusebit&lt;/a&gt; that allows us to execute a large number of arbitrarily scheduled CRON jobs in AWS using Lambda, SQS, and CloudWatch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Say you are building a large-scale, multi-tenant system where tenants define programmatic jobs to be executed in the cloud on a given schedule. You have a large number of such jobs, each with a potentially different execution schedule.&lt;/p&gt;

&lt;p&gt;In the context of &lt;a href="https://fusebot.io/" rel="noopener noreferrer"&gt;Fusebit&lt;/a&gt;, we needed a solution to this problem to enable customers of our integration platform to implement and run integration logic on a given schedule. For example, to export new leads from HubSpot to MailChimp every night, or to send a status report based on Jira tickets to Slack every hour.&lt;br&gt;
The non-scalable CRON solution&lt;/p&gt;

&lt;p&gt;We have decided to use AWS Lambda to run the customer-provided logic. While Lambda is not an ideal compute layer for all types of integration workloads, in our case it satisfied the functional requirements while providing a convenient way of scaling and isolating workloads of multiple tenants.&lt;/p&gt;

&lt;p&gt;Once the infrastructure was in place to run the customer code, the next step was to trigger it on a customer-defined schedule. There are many ways to trigger execution of a Lambda function in AWS. One of them uses &lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html" rel="noopener noreferrer"&gt;scheduled CloudWatch Events&lt;/a&gt;. On the surface, CloudWatch Events meet all the requirements. You can define an arbitrary CRON schedule following which a CloudWatch Event will be triggered, and attach a specific Lambda function to execute in response.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmpwroo7swzepf5s8l5n.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmpwroo7swzepf5s8l5n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Non-scalable CRON executor for AWS Lambda
&lt;/h2&gt;

&lt;p&gt;The problem with using CloudWatch Events in a highly scalable system is the limits. Per AWS region and account, one can only support up to 100 scheduled events (as of this writing), which was not sufficient to support the needs of a highly scalable multi-tenant system. We clearly needed a different approach.&lt;br&gt;
The scalable CRON solution&lt;/p&gt;

&lt;p&gt;After looking around for the right building blocks, a lesser known feature of Amazon SQS drew our attention: &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-delay-queues.html" rel="noopener noreferrer"&gt;SQS delay queues&lt;/a&gt;. The feature enables a message published to an SQS queue to remain invisible to consumers for a configurable time, up to 15 minutes.&lt;/p&gt;

&lt;p&gt;Equipped with this new tool, we have split our CRON processing pipeline by adding SQS delay queues in the middle, and using two additional Lambda functions: a scheduler and an executor.&lt;/p&gt;

&lt;p&gt;First, we defined a single scheduled CloudWatch Event that triggered the scheduler Lambda function every 10 minutes, starting at minute 8 of an hour. So the scheduler Lambda was running at minute 8, 18, 28, 38 etc. of every hour.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhm018j3np174hzywtd27.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhm018j3np174hzywtd27.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Scalable CRON executor for AWS Lambda
&lt;/h2&gt;

&lt;p&gt;The purpose of the scheduler Lambda was to consider all scheduled jobs in the system (possibly millions), and select those that were due for execution in the subsequent whole-10-minute interval. For example, if the scheduler Lambda was running at 3:18, it would determine all scheduled job executions that need to occur in the 3:20-3:30 time span. The scheduler Lambda would then enqueue those job definitions to the SQS queue, setting the delayed delivery for each to correspond to the exact intended moment of execution of that job. For example, if a job was to run at 3:24, the scheduler Lambda running at 3:18 would enqueue that job to SQS setting the delayed execution to 6 minutes. The granularity of delayed execution allows the execution time to be set with 1 second precision.&lt;/p&gt;

&lt;p&gt;Lastly, the executor Lambda would consume messages from SQS as they are released following their delayed delivery settings. The executor Lambda would then invoke the appropriate customer-defined Lambda function to execute the intended logic.&lt;/p&gt;

&lt;p&gt;With this architecture, we were able to use a single CloudWatch Event to schedule a very large number of jobs and support our scheduled integration needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shameless plug
&lt;/h2&gt;

&lt;p&gt;This is just one of many interesting technical problems we are continuously solving when building the integration platform at &lt;a href="https://fusebit.io/" rel="noopener noreferrer"&gt;Fusebit&lt;/a&gt;. If you enjoy working on developer-centric products and cracking this type of technical problems on a daily basis and in a good company, we are hiring. Also, if you need code-first integrations and connectors to 3rd-party SaaS platforms, check out our &lt;a href="https://fusebit.io/integrations/" rel="noopener noreferrer"&gt;integrations&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>cloud</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Make Git Your API</title>
      <dc:creator>Chris More</dc:creator>
      <pubDate>Sat, 23 Oct 2021 03:09:46 +0000</pubDate>
      <link>https://dev.to/chrismore/make-git-your-api-5alh</link>
      <guid>https://dev.to/chrismore/make-git-your-api-5alh</guid>
      <description>&lt;p&gt;When designing HTTP APIs for your application, it sometimes makes sense to embrace git as a part of the protocol. &lt;/p&gt;

&lt;p&gt;If your application operates on data that your users naturally manage using a source control system like git, adding first-class git support to your APIs may be a good idea.&lt;/p&gt;

&lt;p&gt;If you choose to add first-class git support to your own APIs, the fusebit/cloud-git project may come in handy. It provides a lightweight, pure JavaScript implementation of the git protocol that enables you to add git endpoints to your Node.js application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fusebit.io/blog/make-git-your-api/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=post&amp;amp;utm_content=cmore"&gt;Check our cloud-git and the open source github repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>news</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Fusetunnel - A Fast, Scalable, and Free Tunnel</title>
      <dc:creator>Chris More</dc:creator>
      <pubDate>Sat, 23 Oct 2021 03:03:07 +0000</pubDate>
      <link>https://dev.to/chrismore/fusetunnel-a-fast-scalable-and-free-tunnel-47g0</link>
      <guid>https://dev.to/chrismore/fusetunnel-a-fast-scalable-and-free-tunnel-47g0</guid>
      <description>&lt;p&gt;There are many times where we want to share our localhost app with the world, either for testing purposes, to show progress, demo websites or run personal cloud services from your home. Fusetunnel helps you to do this easily! No need to mess with DNS or deploy to have others test out your changes.&lt;/p&gt;

&lt;p&gt;Fusetunnel is great for working with browser testing tools like Browserling or external API callback services like Twilio, which require a public URL for callbacks.&lt;/p&gt;

&lt;p&gt;Fusetunnel is Fusebit’s version of localtunnel.&lt;/p&gt;

&lt;p&gt;The main difference with localtunnel (and other tunnels) is that Fusetunnel is end-to-end encrypted, giving the user greater security, promoting data protection, and preventing unauthorized access to data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fusebit.io/blog/fusetunnel-fast-scalable-and-free-tunnel/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=post&amp;amp;utm_content=cmore"&gt;Read more about Fusetunnel and fork the open-source repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>npm</category>
      <category>news</category>
    </item>
  </channel>
</rss>
