SShortSingh.
Back to feed

Async-First FastAPI Service: Architecture and Production-Ready Patterns

0
·5 views

A DEV Community guide explains how to build a high-throughput Python API using FastAPI with async libraries such as asyncpg, aioredis, and httpx. It presents a production-oriented architecture diagram covering the gateway, auth and rate-limiting services, Redis caching, PostgreSQL, and Kafka. The article covers dependency injection, centralized exception handling, and connection pooling for the database and cache. It also describes using background tasks for fire-and-forget work and graceful startup and shutdown hooks. The author provides a reusable codebase intended for CI/CD pipelines and deployment to Kubernetes, ECS, or other container runtimes.

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 ·

GenAnywhere Structures GLB Scene for Real-Time Container Terminal Twin

The article describes how GenAnywhere organizes a GLB base scene to support a real-time digital twin of a container terminal. It recommends importing the scene through a script rather than manual edits, since hand-tagged objects are lost when the scene is regenerated. Each regeneration is checked for scale, using a known span compared against the as-built value, with a 5 percent error considered acceptable for visualization but not for reach calculations. Vertical accuracy is checked by comparing terrain elevation at the gate against a surveyed spot elevation, as satellite relief suffices only for screening. A completeness check counts cranes and blocks against the terminal operating system asset register to catch missing or duplicated objects.

0
ProgrammingDEV Community ·

Dev and staging environments sit idle most of the week, and scheduled shutdowns can cut their cost

A week contains 168 hours, but a team working 12 hours a day for five days uses only about 60 of them. As a result, a non-production environment running around the clock is idle for roughly 64 percent of its billed time. Stopping compute in the evening is a common default, though storage such as disks, snapshots and elastic IPs keeps billing while compute is halted. Some managed databases restart automatically after a set period, so teams should check any maximum stop duration. The article suggests an override mechanism so that someone needing an environment late can re-enable it without the schedule being permanently disabled.

0
ProgrammingDEV Community ·

How TOTP two-factor codes work and why your code may be rejected

TOTP, or time-based one-time passwords defined in RFC 6238, generates the six-digit codes used by apps like Google Authenticator. A shared secret, typically delivered through a QR code during enrollment, is combined with the current time divided into 30-second intervals and processed with HMAC-SHA1 to produce the code. Because the calculation depends only on the secret and the clock, the same code appears on any device without a network connection. Codes are commonly rejected because of clock drift beyond the server's tolerance, mismatched parameters such as hash algorithm or digit count, or typing errors in a manually entered key. The author also released Code2FA, an open-source browser tool with a clock-checking feature that computes codes locally.

0
ProgrammingDEV Community ·

Cabinet Weight Shapes Crew Size and Install Plan for Outdoor LED Walls

An outdoor LED wall's per-cabinet weight often matters more to site crews than pixel pitch or brightness, since it determines crew size, lifting equipment, and install duration. The QAF5 cabinet weighs 15 kg, measures 960 × 960 × 100 mm, and is built from eighteen smaller modules, so a single module failure affects only a small area. A typical 6 × 4 m wall uses 24 cabinets, bringing the total load to roughly 550 kg once the steel subframe is included, which can be decisive for older buildings. The lighter weight allows a two-person crew to install a wall in about a day without a crane below roughly eight metres, while front-access service lets the wall sit close to the structure. The article also stresses specifying coatings, isolation washers, and corrosion protection for aluminium components, especially near salt water.