master-wiki/void/Readwise/Implementing an Actor Model in Golang.md

1.9 KiB

Implementing an Actor Model in Golang

rw-book-cover

Metadata

[!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)

An actor has a task queue and goroutine that listens to the task queue and execute task. View Highlight)

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)

... Tasks are submitted to ActorSystem using the SubmitTask method. A taskAssigner assigns each of the task to one of the Actors. Each Actor also has a small queue, in which it buffers the tasks and executes one by one.