-Each instance writes updates to redis -
- - -### Stage 2. A single instance flushes the redis queue to the DB - -A single instance will acquire a lock on the DB and flush all elements in the redis queue to the DB. - -- 1 instance will attempt to acquire the lock for the DB update job -- The status of the lock is stored in redis -- If the instance acquires the lock to write to DB - - It will read all updates from redis - - Aggregate all updates into 1 transaction - - Write updates to DB - - Release the lock -- Note: Only 1 instance can acquire the lock at a time, this limits the number of instances that can write to the DB at once - - --A single instance flushes the redis queue to the DB -
- - -## Usage - -### Required components - -- Redis -- Postgres - -### Setup on LiteLLM config - -You can enable using the redis buffer by setting `use_redis_transaction_buffer: true` in the `general_settings` section of your `proxy_config.yaml` file. - -Note: This setup requires litellm to be connected to a redis instance. - -```yaml showLineNumbers title="litellm proxy_config.yaml" -general_settings: - use_redis_transaction_buffer: true - -litellm_settings: - cache: True - cache_params: - type: redis - supported_call_types: [] # Optional: Set cache for proxy, but not on the actual llm api call -``` - -## Monitoring - -LiteLLM emits the following prometheus metrics to monitor the health/status of the in memory buffer and redis buffer. - - -| Metric Name | Description | Storage Type | -|-----------------------------------------------------|-----------------------------------------------------------------------------|--------------| -| `litellm_pod_lock_manager_size` | Indicates which pod has the lock to write updates to the database. | Redis | -| `litellm_in_memory_daily_spend_update_queue_size` | Number of items in the in-memory daily spend update queue. These are the aggregate spend logs for each user. | In-Memory | -| `litellm_redis_daily_spend_update_queue_size` | Number of items in the Redis daily spend update queue. These are the aggregate spend logs for each user. | Redis | -| `litellm_in_memory_spend_update_queue_size` | In-memory aggregate spend values for keys, users, teams, team members, etc.| In-Memory | -| `litellm_redis_spend_update_queue_size` | Redis aggregate spend values for keys, users, teams, etc. | Redis | - - -## Troubleshooting: Redis Connection Errors - -You may see errors like: - -``` -LiteLLM Redis Caching: async async_increment() - Got exception from REDIS No connection available., Writing value=21 -LiteLLM Redis Caching: async set_cache_pipeline() - Got exception from REDIS No connection available., Writing value=None -``` - -This means all available Redis connections are in use, and LiteLLM cannot obtain a new connection from the pool. This can happen under high load or with many concurrent proxy requests. - -**Solution:** - -- Increase the `max_connections` parameter in your Redis config section in `proxy_config.yaml` to allow more simultaneous connections. For example: - -```yaml -litellm_settings: - cache: True - cache_params: - type: redis - max_connections: 100 # Increase as needed for your traffic -``` - -Adjust this value based on your expected concurrency and Redis server capacity. - diff --git a/docs/proxy/db_info.md b/docs/proxy/db_info.md index 5ef9fa550..46d1ffbfa 100644 --- a/docs/proxy/db_info.md +++ b/docs/proxy/db_info.md @@ -47,27 +47,12 @@ You can see the full DB Schema [here](https://github.com/BerriAI/litellm/blob/ma | Table Name | Description | Row Insert Frequency | |------------|-------------|---------------------| | LiteLLM_SpendLogs | Detailed logs of all API requests. Records token usage, spend, and timing information. Tracks which models and keys were used. | **Medium - this is a batch process that runs on an interval.** | +| LiteLLM_DailyUserSpend and siblings (DailyTeamSpend, DailyOrgSpend, DailyTagSpend, DailyEndUserSpend, DailyAgentSpend) | Pre-aggregated daily spend rollups per user, team, org, tag, end user, and agent; the Admin UI Usage views read these aggregates rather than scanning SpendLogs. | Low - one row per entity per day, updated in batches | | LiteLLM_AuditLog | Tracks changes to system configuration. Records who made changes and what was modified. Maintains history of updates to teams, users, and models. | **Off by default**, **High - Runs on every change to an entity** | ## Disable `LiteLLM_SpendLogs` -You can disable spend_logs and error_logs by setting `disable_spend_logs` and `disable_error_logs` to `True` on the `general_settings` section of your proxy_config.yaml file. - -```yaml -general_settings: - disable_spend_logs: True # Disable writing spend logs to DB - disable_error_logs: True # Only disable writing error logs to DB, regular spend logs will still be written unless `disable_spend_logs: True` -``` - -### What is the impact of disabling these logs? - -When disabling spend logs (`disable_spend_logs: True`): -- You **will not** be able to view Usage on the LiteLLM UI -- You **will** continue seeing cost metrics on s3, Prometheus, Langfuse (any other Logging integration you are using) - -When disabling error logs (`disable_error_logs: True`): -- You **will not** be able to view Errors on the LiteLLM UI -- You **will** continue seeing error logs in your application logs and any other logging integrations you are using +Set `disable_spend_logs: True` or `disable_error_logs: True` under `general_settings` to stop writing those tables. With spend logs disabled you lose per-request log detail in the UI but keep cost metrics in your logging integrations (s3, Prometheus, Langfuse); with error logs disabled you lose the Errors view in the UI but keep errors in application logs and other logging integrations. See [keeping error logs out of the database](./prod.md#keep-error-logs-out-of-the-database) in the production checklist. ## Migrating Databases diff --git a/docs/proxy/db_read_replica.md b/docs/proxy/db_read_replica.md index 9a258afef..6a9ce66b7 100644 --- a/docs/proxy/db_read_replica.md +++ b/docs/proxy/db_read_replica.md @@ -58,11 +58,11 @@ worst it degrades to single-database performance. ## RDS IAM authentication When `IAM_TOKEN_DB_AUTH=True`, both the writer and the reader refresh their -IAM tokens independently on the same ~12-minute cadence. The reader does not -need parallel `DATABASE_HOST_READ_REPLICA` / `DATABASE_USER_READ_REPLICA` -env vars β host, port, user, and database name are parsed once from -`DATABASE_URL_READ_REPLICA` at startup, and only the IAM token rotates after -that. +IAM tokens independently on the same ~12-minute cadence. You can supply the +reader either as a single `DATABASE_URL_READ_REPLICA` or assembled from the +component vars (`DATABASE_HOST_READ_REPLICA`, `DATABASE_USER_READ_REPLICA`, +and friends); the token-refresh path re-parses the resulting reader URL, +so only the IAM token rotates after startup. This pairs naturally with Aurora's reader endpoint, which resolves to the reader instances in the cluster. diff --git a/docs/proxy/deploy.md b/docs/proxy/deploy.md index d0634a563..be5a5a4af 100644 --- a/docs/proxy/deploy.md +++ b/docs/proxy/deploy.md @@ -1,189 +1,204 @@ +--- +title: Production Deployment +description: Production deployment guide for LiteLLM on AWS, GCP, Azure, or any Kubernetes cluster, with Helm charts and official Terraform modules. +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Image from '@theme/IdealImage'; +import { CloudArchitectureSelector } from '@site/src/components/CloudArchitecture'; -# Docker, Helm, Terraform - -:::info No Limits on LiteLLM OSS -There are **no limits** on the number of users, keys, or teams you can create on LiteLLM OSS. -::: +# Production Deployment -You can find the Dockerfile to build litellm proxy [here](https://github.com/BerriAI/litellm/blob/main/Dockerfile) +Production deployment guide for AWS, Google Cloud, Azure, or any Kubernetes cluster. For a first deployment on a single machine, start with the [Quickstart](./docker_quick_start.md); this page picks up where it ends. -Official images are published to `ghcr.io/berriai` (`litellm`, `litellm-database` which bundles prisma for use with Postgres, and `litellm-non_root`) and mirrored at `docker.litellm.ai/berriai`. The snippets below use the `docker.litellm.ai` mirror. +There are two supported paths. If you run Kubernetes, [deploy with Helm](#deploy-with-helm) on EKS, GKE, or AKS; the install is the same on every cloud, only the data stores and ingress differ. If you do not run Kubernetes, AWS and GCP have [official Terraform modules](#deploy-with-terraform-aws-and-gcp) that stand up the entire stack; Azure has no Terraform module, so AKS with Helm is the supported path there. -> Note: for production sizing, see [machine specifications](./prod.md#2-recommended-machine-specifications). +## Architecture -## Quick Start - -:::info -Facing issues with pulling the docker image? Email us at support@berri.ai. -::: - -