Elixirの並行処理は「プロセス」という軽量な実行単位で行います。OSのプロセスとは別物で、数百万個を同時に動かせます。
# プロセスを生成してメッセージを送受信
pid = spawn(fn ->
receive do
{:hello, name} -> IO.puts("Hello, #{name}!")
end
end)
send(pid, {:hello, "Elixir"})
# => Hello, Elixir!
🛡️ GenServer(汎用サーバープロセス)
OTP(Open Telecom Platform)の中心的なビヘイビアです。状態管理・リクエスト処理を構造化して記述できます。Supervisorツリーで監視し自動再起動もできます。