sean.mccauliff

sean.mccauliff

Hi I’m completely new to Elixir and Erlang. I was reading the documentation at https://elixir-lang.org/getting-started/introduction.html and was wondering about some details around processes which is the most interesting feature of Elixir (to me).

What are the patterns around dealing with busy processes? If calls to send can never block how can a sender detect if a process is busy? Is there a way to rate limit sender? What happens if the receiver never calls receive does memory just fill up?

Thanks

Showing Posts 1 to 8

cmkarlsson

cmkarlsson

Generally you can’t or don’t. You use other mechanisms to handle overload([2]).

Yes. The mailbox of the process fills up and eventually you run out of memory.

Two links which explains a bit about erlang/elixir scheduling and how to handle overload of unbounded mailboxes.

[1] JLOUIS Ramblings: How Erlang does scheduling
[2] Handling Overload

tty

tty

Typically a process that is expected to receive heavy messages does not perform any work, instead it would spawn Tasks to handle each as it comes in. The current default limit for processes is 262144, and this is configurable. Use processes.

You would limit rates if and only if you are trying to access some critical resource, in which case put a buffer (bit-bucket / queue) in between. Usually this means using ets or mnesia or RabbitMQ as a holding area for messages.

outlog

outlog

what problem are you solving?

usually you would use a genserver - and the call would have timeout 5 secs by default..

also look at GenStage for back pressure/rate limiting etc..

but all depends on the actual problem that is being solved..

OvermindDL1

OvermindDL1

Plus if a process’s mailbox is pretty full then it ‘slows’ down sending to it more and more the more full it is, so a process sending a message to it will be ‘back-pressured’. This doesn’t help if it’s a new process sending a new message every time but it helps throttle the system under most loads.

But ‘OTP’ is the main pattern used to manage processes, and there is a lot built up on it. :slight_smile:

Qqwy

Qqwy

TypeCheck Core Team

It’s also important to note that:

  1. Even if this (e.g. a process in an infinite loop) happens, it will not immediately bring down your system, because of the pre-emptive scheduling of the BEAM VM.

  2. You can easily see that a process is broken by using tools such as :observer whenever you are awake and looking at your system again, then figure out what is going on, fix it and hot-upgrade the system without causing any downtime.

I can really recommend the talk Solid Ground by Sasa Juric, where he gives more info, and live creates, introspects and fixes a ‘broken’ process!

sean.mccauliff

sean.mccauliff OP

Thanks for all the replies. You have given me much to think about.

idi527

idi527

Not anymore, I think. It’s been removed in either v20 or v21.

Some more (quite enlightening) discussion about it.

OvermindDL1

OvermindDL1

Interesting! I did not know about that! Thanks! :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews