Skip to content

Redis

OpenGateLLM uses Redis as an in-memory data store. It has two main purposes:

  • Rate limiting: Tracks API usage limits (RPM, RPD, TPM, TPD)
  • Load support: Stores one ZSET per provider with a qos_limit for Quality of Service. Each active request is a member, so the member count supplies the load used for atomic admission, provider selection, and health saturation. The load of a provider without a limit is not recorded: nothing reads it.

For a provider with a qos_limit, load tracking is always active, even when admission caps are disabled. An admitted request refreshes its member with a heartbeat while the provider call runs and removes it immediately on release. If a worker stops, the heartbeat expires and the next admission purges the member.

To configure the Redis dependency, you need to add the connection information in the dependencies section of your config.yml file.
Check Redis section in configuration file documentation for more information.

Example:

dependencies:
[...]
redis:
url: redis://:${REDIS_PASSWORD:-changeme}@${REDIS_HOST:-localhost}:${REDIS_PORT:-6379}

The Redis dependency accepts all parameters from the from_url() method of redis.asyncio.connection.ConnectionPool class. Only url parameter is required.

The Redis server must use maxmemory-policy noeviction. Evicting a QoS ZSET would erase active load and could cause over-admission.

maxmemory-policy noeviction

When the Redis user of the API is restricted by an ACL, it must be allowed to run:

  • for the Quality of Service: TIME, EVALSHA, SCRIPT LOAD, ZADD, ZREM, ZCOUNT, ZCARD, ZREMRANGEBYSCORE, on the ogl_qos:* keys;
  • for the rate limiting: EVALSHA, SCRIPT LOAD and the read and write commands of its Lua scripts, on the LIMITS:* keys.

EVAL is not needed. For example:

user app_user on >password ~* -@all +@read +@write +@connection +time +evalsha +script|load

At startup, the API runs every command the Quality of Service needs once, and logs an error naming the one Redis denies. It still starts: it serves the requests without enforcing the provider limits, and logs that error again on every request that needs them.

Configuration file documentation