Event Driven Machines

Serverless is great because is has good ergonomics - when an event is received, a “not-server” boots quickly, code is run, and then everything is torn down. We’re billed only on usage. It turns out that Fly.io shares many of the same ergonomics as s

Chris Fidao
6 min readadvanced
--
View Original

Overview

The article discusses the concept of Event Driven Machines on Fly.io, highlighting how to efficiently utilize fast-booting VMs to process events in a serverless-like manner. It introduces a project called Lambdo, which leverages these machines to handle events by spinning up VMs that execute code based on incoming JSON objects.

What You'll Learn

1

How to trigger Fly Machines based on non-HTTP events

2

Why using SQS for event handling can simplify server management

3

How to package and run your existing code in Fly Machines

4

When to use Lambdo for processing events efficiently

Prerequisites & Requirements

  • Basic understanding of event-driven architecture and serverless concepts
  • Familiarity with AWS SQS(optional)

Key Questions Answered

How can Fly.io's fast-booting VMs be utilized for event processing?
Fly.io's fast-booting VMs can be utilized by spinning up machines that execute code in response to events. This approach allows for efficient processing of events by creating a new VM for each event, ensuring that resources are only used when necessary.
What is the role of SQS in the event-driven architecture described?
SQS serves as the event queue where JSON objects representing events are sent. The Lambdo project polls this queue for messages, collects the events, and triggers Fly Machines to process them, thereby simplifying the server management aspect.
What are the benefits of using Lambdo for event-driven processing?
Lambdo allows developers to respond to events by spinning up Fly Machines, providing flexibility in choosing base images and server types for each event. This approach combines the benefits of serverless architecture with the control of traditional VMs.
What are the key steps in setting up event-driven machines on Fly.io?
The key steps include listening for events via SQS, spinning up Fly Machines to run code with event context, and ensuring that the code is event-aware. This setup allows for efficient processing of events with minimal resource usage.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Utilize Fly.io's fast-booting VMs to create a responsive event-driven architecture.
By leveraging the quick startup times of Fly Machines, developers can efficiently handle events without the overhead of maintaining persistent servers, making it ideal for applications with variable workloads.
2
Implement SQS for event queuing to streamline event handling.
Using SQS allows for decoupling of event producers and consumers, enabling a more scalable and manageable architecture. This is particularly useful in microservices environments where services need to communicate asynchronously.
3
Consider using Lambdo's base images for rapid deployment of event handlers.
By using pre-defined runtimes like Node and PHP, developers can quickly set up event handlers without worrying about the underlying infrastructure, allowing for faster iteration and deployment.

Common Pitfalls

1
Failing to properly handle event data can lead to errors in processing.
It's crucial to ensure that the JSON structure of events matches what your code expects. Implementing robust error handling and validation can help mitigate issues during event processing.

Related Concepts

Event-driven Architecture
Serverless Computing
Microservices
AWS Sqs