# Elixir Otp Concurrency

> Use this skill when building resilient, fault-tolerant concurrent services using Elixir GenServer, Supervisors, and message passing.

- Skill: `nextboxis/elixir-otp-concurrency` (Agent Skill)
- Install (CLI): `npx get-skill add nextboxis/elixir-otp-concurrency`
- Raw SKILL.md: https://api.skillmd.com/api/skills/nextboxis/elixir-otp-concurrency/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: nextboxis (https://skillmd.com/u/nextboxis)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/nextboxis/elixir-otp-concurrency

---

# Elixir OTP Concurrency & GenServer

## When to use
Use this skill when you need to building resilient, fault-tolerant concurrent services using Elixir GenServer, Supervisors, and message passing.

## Prerequisites
- Working knowledge of relevant programming language or database fundamentals.
- Access to testing environment or local runtime instance.

## Step-by-step workflow
1. **Analyze operational requirements**: Review performance boundaries, data integrity constraints, and query patterns.
2. **Design schema / interface**: Define explicit data contracts, types, or indexes supporting planned operations.
3. **Implement core routines**: Construct declarative, type-safe, or parameterized queries and functions.
4. **Validate performance**: Verify execution metrics using profilers, EXPLAIN plans, or benchmark test suites.
5. **Implement defensive controls**: Enforce timeout boundaries, connection pooling limits, and transaction safety.

## Commands / code examples
```elixir
defmodule RateLimiter do
  use GenServer

  # Client API
  def start_link(initial_limit) do
    GenServer.start_link(__MODULE__, initial_limit, name: __MODULE__)
  end

  def allow_request?() do
    GenServer.call(__MODULE__, :check_request)
  end

  # Server Callbacks
  @impl true
  def init(limit) do
    {:ok, %{limit: limit, current: 0}}
  end

  @impl true
  def handle_call(:check_request, _from, %{limit: limit, current: cur} = state) do
    if cur < limit do
      {:reply, true, %{state | current: cur + 1}}
    else
      {:reply, false, state}
    end
  end
end
```

## Common mistakes & pitfalls
- Overlooking indexing strategies on foreign keys and frequently queried filter columns.
- Running unparameterized dynamic queries, creating severe SQL injection vulnerabilities.
- Holding open long-running database transactions during slow external network calls.

## Verification checklist
- [ ] Schema contracts and type signatures are strictly enforced.
- [ ] Queries are fully parameterized against injection vulnerabilities.
- [ ] Profiling or execution plans show optimal resource consumption.
- [ ] Error handling safely releases locks and rolls back aborted transactions.

## Related skills
- postgresql-query-optimization-explain
- sql-anti-patterns-remediation
- acid-transactions-isolation-levels
- secure-code-review-static-analysis-sast

