# Hammer

> A rate-limiter for Elixir with pluggable storage backends

Source: https://talira.ai/catalog/hammer-s95wpxry
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [security / rate limiting](https://talira.ai/categories/security/rate-limiting), [languages / elixir](https://talira.ai/categories/languages/elixir)
- Licence: MIT[^5][^6]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^1]
- Plugins: yes[^1]
- Backed by: [ExHammer](https://talira.ai/orgs/exhammer.md)

Hammer is a rate limiter for [Elixir](https://talira.ai/catalog/elixir-edq5dfnt.md): you define a module with `use Hammer, backend: ...` and call `hit(key, scale, limit)`, which allows or denies an action and says how long to wait, per user, API key or any key you compose. It ships ETS (the default) and Atomic backends that count in the node's memory, and the ExHammer project publishes a [Redis](https://talira.ai/catalog/redis-v917j45s.md) backend (`hammer_backend_redis`) and a Mnesia backend (`hammer_backend_mnesia`, labelled beta) as separate packages, so several nodes can share one set of counters. Its docs also show a distributed, eventually consistent setup that keeps ETS counters on each node and broadcasts every hit over Phoenix.PubSub, the pattern hex.pm's own rate limiter uses. It supports fixed window, fixed window per key, leaky bucket, token bucket and (on ETS) sliding window algorithms, and works as a plug in [Phoenix](https://talira.ai/catalog/phoenix-pr0aa2gd.md). Version 7 (February 2025) replaced the older `Hammer.check_rate` API.

## Links

- Website: https://hexdocs.pm/hammer/
- GitHub: https://github.com/ExHammer/hammer
- Docs: https://hexdocs.pm/hammer/

## Problems it solves

- throttle each customer's API token separately in a Phoenix API
- each BEAM node keeps its own request counts, so our effective limit grows with every node we add
- share request counters across all the nodes of an Elixir cluster
- limit how many files a user can upload per minute in an Elixir app
- return a retry-after time when a client goes over its request limit in Elixir
- keep rate limit counters in Redis so every BEAM node sees the same count
- cluster-wide request throttling in Elixir without running Redis
- allow short bursts but cap the average request rate with a token bucket in Elixir
- enforce one SMS per minute and six per hour for the same user in one atomic check
- throttle login attempts per IP address in a Phoenix endpoint
- upgrade old Hammer.check_rate code to the current rate limiter API

## Features

- hit/3 returns {:allow, count} or {:deny, retry_after}
- ETS backend (default) and Atomic backend built in
- Redis backend (hammer_backend_redis, Hammer.Redis) for counters shared by every node
- Mnesia backend (hammer_backend_mnesia, beta)
- distributed ETS guide: local counters plus Phoenix.PubSub broadcasts of each hit
- fixed window, fixed window per key, leaky bucket and token bucket algorithms; sliding window on ETS
- custom increments per hit
- Redis backend: hit_many/1 checks several limits in one atomic round trip
- Redis backend: SSL connections and Redis Cluster hash tags
- used as a function plug in Phoenix controllers or endpoints
- Igniter installer (mix igniter.install hammer) that generates a rate limit module

## Limitations

- Doesn't share counts between nodes with its built-in backends alone: Atomic is single-node, and ETS needs PubSub broadcasts or the Redis or Mnesia backend[^1][^2]
- Doesn't keep distributed ETS counters exactly in sync: the PubSub setup is eventually consistent and new nodes start with empty counters[^2]
- Doesn't have a stable Mnesia backend yet: hammer_backend_mnesia is labelled beta[^3]
- Doesn't support Redis versions before 7.0 in its Redis backend: on older servers counter keys never expire[^4]

## Capabilities

- Takes plugins: plan not known

## Trust

Overall: 0.32 out of 1.
Signals: backing 0.30, extensibility 0.20.

- backed by ExHammer
- has a plugin system

Warnings:

- GitHub activity not fetched yet

## Related

- Works with [Phoenix](https://talira.ai/catalog/phoenix-pr0aa2gd.md)

## Sources

[^1]: https://github.com/ExHammer/hammer/blob/master/README.md (checked 20 Nov 2026)
[^2]: https://hexdocs.pm/hammer/distributed-ets.html (checked 20 Nov 2026)
[^3]: https://github.com/ExHammer/hammer-backend-mnesia (checked 20 Nov 2026)
[^4]: https://github.com/ExHammer/hammer-backend-redis (checked 20 Nov 2026)
[^5]: https://github.com/ExHammer/hammer/blob/master/LICENSE.md (checked 20 Nov 2026)
[^6]: https://hex.pm/packages/hammer (checked 20 Nov 2026)
