Building and Scaling LLM Applications at Discord
discord · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.5 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Consumer-scale LLM application development
Discord needed a repeatable way to identify, prototype, evaluate, and scale LLM-powered features for a large consumer platform while balancing quality, latency, safety, language support, throughput, cost, privacy, and infrastructure effort.
Constraints:
- generative AI should only be used where it is a good fit, not added for novelty
- user-facing Discord features must balance quality with low latency
- prompt changes become hard to evaluate after many iterations
- LLM outputs may be unsafe, harmful, hallucinated, or structurally inconsistent
- full-scale launch costs depend on token throughput and model choices
- commercial APIs reduce infrastructure burden while self-hosting may help cost and privacy but adds engineering overhead
Architecture
Discord describes a staged LLM development process: identify use cases suited to generative AI, define product requirements, prototype with advanced commercial models such as GPT-4, evaluate prompts using traditional metrics plus AI-assisted critic prompts, limited-release the feature through A/B tests, and deploy at scale behind a production architecture. The production architecture prepares inputs into tested prompts, sends them to an LLM inference server, hydrates the output, runs content-safety checks with Legal/Safety partners and trust-and-safety models, and returns results to users. For production model serving, Discord weighs commercial APIs against self-hosted Llama/Mistral-style models, Triton/vLLM servers, GPUs, batching, token-length patterns, and fine-tuning needs.
Diagram confidence: reconstructed (reconstructed from prose).
flowchart LR use-case-filter[Use case filter] --> product-requirements-checklist[Product requirements checklist] product-requirements-checklist --> prototype-llm[Prototype LLM] prototype-llm --> prompt-evaluator[Prompt evaluator] prompt-evaluator --> a-b-learning-loop[A/B learning loop] a-b-learning-loop --> production-api-gateway[Production API gateway] a-b-learning-loop --> metrics-and-cost-monitor[Metrics and cost monitor] production-api-gateway --> prompt-preparation[Prompt preparation] prompt-preparation --> llm-inference-server[LLM inference server] llm-inference-server --> content-safety-service[Content safety service] content-safety-service --> production-api-gateway content-safety-service --> legal-and-safety-partners[Legal and Safety partners] llm-inference-server --> self-hosted-inference-stack[Self-hosted inference stack]
Components
| Component | Role | Interacts with |
|---|---|---|
Use case filter |
Checks whether generative AI is appropriate for unstructured-content analysis, massive scaling, or tasks that resist rules/traditional ML. | Product requirements checklist |
Product requirements checklist |
Defines latency, task complexity, prompt length, quality, safety, language support, and estimated QPS before prototyping. | Use case filter, Prototype LLM |
Prototype LLM |
Advanced commercial model, such as GPT-4, used to validate whether the idea is tractable before infrastructure investment. | Product requirements checklist, Prompt evaluator |
Prompt evaluator |
Traditional metrics plus AI-assisted evaluation using a critic prompt on a stronger model. | Prototype LLM, A/B learning loop |
A/B learning loop |
Limited release process that collects user satisfaction, engagement, hallucinations, latency, throughput, errors, and cost data. | Prompt evaluator, Production API gateway, Metrics and cost monitor |
Production API gateway |
Gateway that receives user requests, requests LLM inference, hydrates outputs, and routes through content safety before response. | A/B learning loop, Prompt preparation, Content safety service |
Prompt preparation |
Transforms inputs into tested and evaluated prompts for the inference server. | Production API gateway, LLM inference server |
LLM inference server |
Commercial API or self-hosted model server that produces generated outputs from prepared prompts. | Prompt preparation, Content safety service, Self-hosted inference stack |
Content safety service |
Trust-and-safety layer that scans generated content before it reaches users. | Production API gateway, LLM inference server, Legal and Safety partners |
Legal and Safety partners |
Cross-functional teams that define mitigations, privacy principles, and safety requirements. | Content safety service |
Metrics and cost monitor |
Tracks satisfaction, engagement, incorrect answers, hallucinations, latency, tokens per second, error rates, and token spend forecasts. | A/B learning loop |
Self-hosted inference stack |
Optional Llama/Mistral-style stack with Triton or vLLM, GPUs, batching, queues, and task-specific tuning. | LLM inference server |
Data flow
A candidate use case is filtered through Discord's suitability criteria and requirements checklist. The team prototypes with a strong commercial LLM, iterates on the prompt, and sends outputs to a separate critic prompt on a best-in-class model for yes/no or rating-style evaluation. Once quality is sufficient, the feature ships as a limited A/B test, collecting user satisfaction, hallucination/problem reports, latency, tokens per second, error rates, and cost forecasts. At scale, a user request passes through an API gateway and prompt-preparation layer to an LLM inference server, returns an LLM output, is hydrated and scanned by content-safety services, and only then reaches the user. If commercial APIs are unsuitable, a self-hosted inference stack with load balancing, queues, batch scheduling, GPUs, and model servers becomes the serving path.
4 supporting quotes
Why this architecture
Discord starts with commercial frontier models because they provide the fastest tractability test: if GPT-4 cannot solve the prototype well enough, the problem may not be addressable with current generative AI. AI-assisted evaluation turns subjective prompt iteration into a measured loop, and A/B tests provide real in-situ user and system data before full launch. The production gateway plus content-safety layer reflects Discord's consumer-platform need for privacy, safety, and quality. Self-hosting is treated as an optimization path for cost or privacy only when the team accepts the infrastructure and performance tradeoffs.
4 supporting quotes
Models used: GPT-4 · ChatGPT · OpenAI GPT APIs · Llama · Mistral · trust and safety ML models
Scale
- Discord serves hundreds of millions of users according to the ZenML summary.“Discord, the popular communication platform serving hundreds of millions of users”summary, stated
- The requirements process includes estimated QPS as a full-scale throughput input.“Estimated QPS: What throughput does our system eventually need to handle?”article, stated
- AI-assisted evaluation uses two separate prompts: a task prompt and a critic prompt.“AI-assisted evaluation consists of 2 separate prompts: one for your task and another to evaluate your results.”article, stated
- Limited releases measure tokens per second to forecast full launch cost.“We look at how many tokens per second we're using in our initial limited release to predict the costs of a complete launch”article, stated
Alternatives considered (roads not taken)
Use generative AI for any product engagement opportunity
Rejected because: Discord explicitly filters for problems where an LLM is the right tool rather than applying AI when other tools fit better.
Invest in ML infrastructure before proving the idea
Rejected because: Discord first validates with commercial LLMs so engineering can focus on product iteration if the model can solve the problem.
Commercial LLM APIs for full-scale production
Rejected because: They offer quality without setup burden, but cost can scale quickly and privacy may favor in-house processing.
Self-hosted open-source or fine-tuned models
Rejected because: Self-hosting can reduce costs or improve privacy, but it adds development time, maintenance overhead, GPUs, server tuning, and possible performance implications.
Always choose the largest model
Rejected because: For self-hosted paths Discord recommends starting smaller and moving up only if quality requires it.
Patterns
eval-driven-development (quality)
Discord uses AI-assisted evaluation, traditional metrics, limited-release A/B tests, user feedback, system health metrics, and cost metrics to decide whether to iterate or deploy.
llm-as-judge (evaluation)
A stronger critic model such as GPT-4 automatically evaluates the inference model's output against criteria.
model-routing (model-ops)
Discord chooses among commercial APIs, smaller models, larger models, open-source models, and fine-tuned/self-hosted options based on quality, latency, privacy, and cost.
guardrails-io-filtering (safety)
Generated content is scanned by content safety filters and trust-and-safety models before reaching users.
safety-policy-enforcement (governance)
Discord includes safety, prompt hacking, privacy, data minimization, Legal, and Safety partners in the product architecture.
structured-output-contract (integration)
Discord treats consistently structured LLM output as necessary for minimizing parsing errors and using outputs robustly in services.
canary-rollout (release)
Discord uses limited releases and A/B tests to observe real behavior before full deployment.
Tradeoffs
Prototype strategy
Chose advanced commercial LLMs over building ML infrastructure first.
Rationale: Frontier APIs quickly reveal whether the idea is tractable and let engineers iterate on the product before maintaining infrastructure.
Latency-quality balance
Chose explicit requirements tradeoff between bigger models, compute, and smaller models over assuming the highest-quality model is always acceptable.
Rationale: Bigger models can deliver better outcomes but run more slowly, forcing a choice among compute cost, latency, and quality.
Evaluation design
Chose GPT-4 critic prompts with simple ratings over manual review of every prompt output.
Rationale: Simple yes/no or scaled critic outputs make prompt iteration automatable while still using a stronger model's judgment.
Serving model
Chose commercial APIs when quality and speed to launch matter over self-hosting by default.
Rationale: Commercial APIs avoid setup burden and provide top models, while self-hosting is reserved for privacy, cost, or custom quality reasons.
Model size for self-hosting
Chose start with smaller models and scale up only for quality over defaulting to larger models.
Rationale: Smaller models reduce serving burden when they satisfy quality requirements.
Gotchas (what bit them)
Generative AI can be misapplied when a simpler tool fits better.
Root cause: AI excitement can obscure whether the problem actually needs an LLM.
Resolution: Filter use cases for unstructured content, massive scale, or problems difficult for rules and traditional ML.
Prompt iteration becomes ambiguous after many wording changes.
Root cause: Manual inspection alone makes it hard to tell whether prompt adjustments improve results.
Resolution: Use metrics and AI-assisted evaluation to guide prompt changes.
LLM features can pass prototype quality but fail in real user experience.
Root cause: Real users expose hallucinations, incorrect answers, engagement issues, latency, structured-output failures, and cost behavior.
Resolution: Run limited A/B releases and iterate from satisfaction, system health, and cost metrics before full deployment.
Structured output inconsistency breaks downstream service use.
Root cause: LLMs sometimes fail to emit a consistently parseable format.
Resolution: Track system health and plan post-hoc processing needed to productionize the capability.
Self-hosting shifts cost savings into engineering and performance complexity.
Root cause: Dedicated model servers, GPUs, batching, token-length tuning, and maintenance become the team's responsibility.
Resolution: Start with commercial models for validation, then self-host only when privacy or cost justifies the overhead.
Evaluation
Discord evaluates LLM features with AI-assisted critic prompts, traditional metrics, yes/no or rating-based outputs, limited-release A/B tests, user satisfaction and engagement, incorrect-answer and hallucination reports, latency, throughput in tokens per second, error rates, cost forecasting, and structured-output robustness checks.
Metrics: critic yes/no judgments · critic rating scores · user satisfaction · direct user feedback · user engagement · incorrect answers · hallucination reports · response latency · tokens per second · error rates · token consumption and forecast cost · structured-output parsing errors
4 supporting quotes
Outcomes
- Discord published a repeatable staged process for LLM feature development
- the process starts with use-case filtering and product requirements before prototyping
- AI-assisted evaluation provides a faster loop for prompt quality decisions
- limited A/B releases gate full-scale deployment
- the production architecture includes prompt preparation, inference serving, output hydration, and content safety
- self-hosting guidance covers Llama, Mistral, Triton, vLLM, GPUs, batching, and token-length tuning
- the article provides a framework rather than concrete launched-feature metrics
The case is a methodology article for a large consumer platform. The concrete operating concerns are hundreds of millions of users, estimated QPS, tokens-per-second cost forecasting, safety review before user exposure, and potential self-hosted inference infrastructure.