Skip to content

Instantly share code, notes, and snippets.

@cr0t
Created August 25, 2022 12:33
Show Gist options
  • Save cr0t/0a176167225039b6f6943a4760b912e6 to your computer and use it in GitHub Desktop.
Save cr0t/0a176167225039b6f6943a4760b912e6 to your computer and use it in GitHub Desktop.
# Origin: https://blog.sequin.io/how-we-used-elixirs-observer-to-hunt-down-bottlenecks/
defmodule Overload do
# Define a CPU-intenstive work function, which can call itself
# recursively (forever)
def recursive do
:public_key.generate_key({:rsa, 4096, 65537})
recursive()
end
end
# Spawn twice number processes as much your machine has
for _ <- 1..(System.schedulers_online() * 2) do
spawn_link(fn -> Overload.recursive() end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment