Pattern Actor in AWS environment

Hi everyone, In this article, I’d like to show you how to use the Actor pattern in an AWS environment. It’s possible that you’re already using the Actor Model without realizing that this approach actually has a name—the Actor. What is the Actor? I’m absolutely sure I couldn’t explain it better than the person who invented and formalized the Actor Model, which is why I highly recommend watching this video. Let me just add a quick recap and show you how to implement the Actor Model in AWS. The Actor Model is a conceptual model used in computer science to handle concurrent computation. In this model, an actor is a computational entity that, in response to receiving a message, can: Perform a task (e.g., process data or make a decision), Send messages to other actors, Create new actors, and Update its internal state. Each actor operates independently and communicates only by message passing, which helps avoid issues related to shared memory and makes systems easier to scale and reason about. Let me rephrase it use simply words. Actor Lightweight and it is easy to create thousand of them Has own state Has own mailbox (queue) Can communicate with each other only through messages Messages are processed in FIFO order Process only one message at a time Decoupled In AWS, you can implement the Actor pattern using services like: AWS Lambda (as individual actors) Amazon SQS or SNS (for message passing) Step Functions or EventBridge (for orchestration) DynamoDb (as a storage/state) It might seem like the Actor Model is simply a combination of a queue service, a Lambda function triggered by that queue, and a DynamoDB table — and you'd be mostly right. However, there are some subtle nuances, and I’d like to walk you through them. Requirements A typical use case well-suited for the Actor Model is a shopping cart in an e-commerce application. You'll easily come across this example in many articles, which is why I'll provide some slightly different ones instead. Let's imagine a fintech application where a user can deposit money into their own account or transfer it to another account. In the fintech world, these operations are referred to as transactions, and they typically fall into two categories: deposit and transfer. Another example is a store where products can arrive and depart at any time. To prevent the inventory from dropping below zero, we must ensure that all arrivals are processed before any departures.

Apr 15, 2025 - 23:54
 0
Pattern Actor in AWS environment

Hi everyone,
In this article, I’d like to show you how to use the Actor pattern in an AWS environment. It’s possible that you’re already using the Actor Model without realizing that this approach actually has a name—the Actor.

What is the Actor?

I’m absolutely sure I couldn’t explain it better than the person who invented and formalized the Actor Model, which is why I highly recommend watching this video.

Let me just add a quick recap and show you how to implement the Actor Model in AWS.

The Actor Model is a conceptual model used in computer science to handle concurrent computation. In this model, an actor is a computational entity that, in response to receiving a message, can:

  • Perform a task (e.g., process data or make a decision),

  • Send messages to other actors,

  • Create new actors, and

  • Update its internal state.

Each actor operates independently and communicates only by message passing, which helps avoid issues related to shared memory and makes systems easier to scale and reason about. Let me rephrase it use simply words.

Actor

  1. Lightweight and it is easy to create thousand of them
  2. Has own state
  3. Has own mailbox (queue)
  4. Can communicate with each other only through messages
  5. Messages are processed in FIFO order
  6. Process only one message at a time
  7. Decoupled

In AWS, you can implement the Actor pattern using services like:

  • AWS Lambda (as individual actors)
  • Amazon SQS or SNS (for message passing)
  • Step Functions or EventBridge (for orchestration)
  • DynamoDb (as a storage/state)

It might seem like the Actor Model is simply a combination of a queue service, a Lambda function triggered by that queue, and a DynamoDB table — and you'd be mostly right. However, there are some subtle nuances, and I’d like to walk you through them.

Requirements

A typical use case well-suited for the Actor Model is a shopping cart in an e-commerce application. You'll easily come across this example in many articles, which is why I'll provide some slightly different ones instead.

Let's imagine a fintech application where a user can deposit money into their own account or transfer it to another account. In the fintech world, these operations are referred to as transactions, and they typically fall into two categories: deposit and transfer.

Another example is a store where products can arrive and depart at any time. To prevent the inventory from dropping below zero, we must ensure that all arrivals are processed before any departures.