# Implementing an Actor Model in Golang

![rw-book-cover](https://miro.medium.com/v2/da:true/resize:fit:1200/0*smZOmMQjuS_5l1Af)

## Metadata
- Author: [[Gaurav Sharma]]
- Full Title: Implementing an Actor Model in Golang
- Category: #articles
- Document Tags: [[dev]] [[dev/design-patterns]] [[dev/go]] 
- URL: https://betterprogramming.pub/implementing-the-actor-model-in-golang-3579c2227b5e
- Archive: https://web-archive.alecodes.page/bookmarks?bf=1&search=&title=Implementing%20an%20Actor%20Model%20in%20Golang
> [!tldr]
> The article explains how to implement an actor model in Golang to handle concurrent tasks efficiently. It describes the roles of actors, task assigners, and the actor system, highlighting their interactions and task processing. The author also shares insights from a simulated web server benchmark that demonstrates how the system adapts to varying task latencies.

## Highlights
The actor model is one such programming construct that models a large number of independent jobs, being processed in any order with no need for a lock synchronisation. [View Highlight](https://read.readwise.io/read/01j96c65ze39pyrcsvp8fpg6xp))

An actor has a task queue and goroutine that listens to the task queue and execute task. [View Highlight](https://read.readwise.io/read/01j96c7xjz9y9snbaawa8qa6hn))

The task is executed in an actor. It is an implementation of a given interface with *Execute method*. Anything which can be executed by making Execute call. Task is a business implementation of the work we need to do. [View Highlight](https://read.readwise.io/read/01j96c958cxjr5855jy9qcshx1))

![](https://miro.medium.com/v2/resize:fit:700/1*YGV-7SgbyBUKIUnruMI5Sg.png) ... `Task`s are submitted to `ActorSystem` using the `SubmitTask` method. A `taskAssigner` assigns each of the task to one of the `Actor`s. Each `Actor` also has a small queue, in which it buffers the tasks and executes one by one.

