SShortSingh.
Back to feed

Five Guardrails for Calling LLM APIs Reliably in Production Web Apps

0
·2 views

A prototype LLM integration can fail in production through stalled endpoints that exhaust worker pools, malformed JSON wrapped in code fences, or runaway retry loops that inflate costs. The article recommends five safeguards for every model call: strict JSON schema enforcement, separate connect and read timeouts, jittered backoff with model fallback, deterministic prompt caching, and per-tenant token budget caps. It notes that LLM latency is far more variable than typical REST APIs, with p99 response times often reaching 18 to 35 seconds. The author's team routes all model requests through a hardened gateway service rather than letting controllers call provider SDKs directly.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Palo Alto PAN-OS flaw CVE-2026-0321 allows unauthenticated denial-of-service via dataplane traffic

Palo Alto Networks released a batch of security advisories in mid-October 2026, which CERT-FR grouped under advisory CERTFR-2026-AVI-1326. Most issues in the batch require local or administrative access, but CVE-2026-0321 stands apart because an unauthenticated attacker with network reach can send crafted traffic to a dataplane interface. Repeated exploitation can trigger a denial-of-service state that pushes the device into maintenance mode. The flaw is rated MEDIUM at 6.6 under CVSS 4.0, reflecting its availability-only impact rather than the ease of exploitation. Analysts recommend handling it on a separate, shorter timeline from the rest of the batch, since its effect is on traffic rather than credentials.

0
ProgrammingDEV Community ·

Why PostgreSQL VACUUM Monitoring Matters for Preventing Table Bloat

Table bloat in PostgreSQL can degrade performance for weeks before it is noticed, since symptoms like growing disk usage and slower queries appear indirectly. The cause lies in MVCC, where updates and deletes leave dead row versions that only VACUUM can reclaim, and only once no running transaction still needs them. Autovacuum may be enabled yet still fall behind, because its default trigger thresholds scale poorly on very large tables. Long-running transactions, idle sessions, and replication slots can also hold back cleanup, while cost-limited workers may never catch up on write-heavy tables. Effective monitoring of dead tuples and vacuum activity is therefore needed to catch these problems early.

0
ProgrammingDEV Community ·

Only 53 of 1,045 Hours of Sleep Audio Were Usable for Training a Sleep-Phase Model

A developer team recorded about 1,045 hours of overnight bedroom audio to train a sleep-phase model, but only roughly 53 hours met the criteria for training. The main obstacle was not capturing audio, which they described as a solved problem, but obtaining reliable labels that mark sleep stages. Their labels came from wearable devices, which only worked on nights when the phone and wearable recordings overlapped cleanly, and small clock drift or early device failures removed usable hours. They concluded that defining what counts as a valid night, and discarding incomplete recordings, was more important than collecting more data. Their practices included logging each recording's completeness, aligning audio to labels before labelling, and tracking where each label came from.

0
ProgrammingDEV Community ·

Tool-cost CI check for MCP servers catches schema growth hidden by token totals

A developer guide describes a reproducible CI check for MCP tool definitions that measures total tokens, descriptions and input schemas separately. It uses an observed remote change to textokit's endpoint, where a 20-tool list lost about 32% of its counted tokens overall, mostly from shorter descriptions. The article provides a full fetch script that verifies canonical digests of the public tool lists before comparing them. Commands use pinned versions of the aimarket-histor CLI and tiktoken, and the author notes this is their own reproducibility check rather than external adoption. The check exits with code 0 when the increase stays within a configured threshold of 10%.