#Backend
6 posts
When Your Python Server Is Slow — Finding the Bottleneck in 5 Minutes with py-spy
Using py-spy, the sampling profiler that attaches to a running Python process with no code changes or restarts: dump to identify a hung process, top for live bottleneck watching, record and flame graphs, --idle for off-CPU waits, reading the GIL numbers, and running it in containers.
How a CDN Makes Things Fast — From Cache Hits to Dynamic Content
CDN mechanics from the practitioner's side: the edge structure that shrinks distance (RTT), the Cache-Control headers and cache keys that decide hit rate, invalidation and deploy strategy, how CDNs help even uncacheable dynamic traffic (TLS termination, connection reuse), and the common mistakes that eat hit rate.
Why Redis Is Fast — Memory, a Single Thread, and Data Structures
The structural reasons Redis handles hundreds of thousands of requests per second: memory access with no disk in the path, a lock-free single-threaded event loop, and purpose-built data structures — plus the single-thread trap (one slow command stalls everything) and the cases where Redis gets slow.
What a Database Index Actually Does — B-trees, Lookup Cost, and the Price of Writes
How indexes make lookups fast, from the B-tree up: the cost gap versus full scans, composite indexes and column order, why indexes are not free (write cost, storage), and the working rules for what to index and what to leave alone.
When a REST API Is Slow — the Order for Finding the Bottleneck
Finding API bottlenecks by procedure instead of instinct: instrumenting to split the request into segments, the four usual suspects (database, serialization, external calls, N+1), the priority order of fixes like caching and pagination, and why p99 matters more than p50.
Go Practice #1 First HTTP Server
The smallest server, started with the single net/http package. ListenAndServe, HandleFunc, ResponseWriter, and graceful shutdown.