MindForge
MindForge
DashboardHelp & Support
Dashboard
MindForge

Production Debugging: Fix Real Bugs in a Live-Looking App

Course progress

0%
0 of 68 modules complete

Django

Performance0/3
  • Debugging slow pages: measure first
  • Lab: The order list page is slow for repeat customers
  • Lab: The staff dashboard hits the database too often
Data model and money0/4
  • Debugging wrong data: trace the value, not the screen
  • Lab: Invoices vanish when a customer is deleted
  • Lab: Order totals are one cent off
  • Lab: Evening orders land on tomorrow's report
Concurrency0/3
  • Debugging races: make the bug happen on purpose
  • Lab: A burst of signups crashes with IntegrityError
  • Lab: The last unit is sold twice
Migrations0/3
  • Debugging migrations: the graph and the data
  • Lab: The release is blocked by conflicting migrations
  • Lab: A migration that only fails on production data
Configuration and deployment0/2
  • Debugging configuration: what differs between here and there
  • Lab: Production has no styles or scripts
Calls to other services0/2
  • Debugging calls to other services: design for the failure
  • Lab: Checkout hangs when the payments provider is slow

FastAPI

Migrations (Alembic)0/3
  • Debugging Alembic: the revision graph and the data it meets
  • Lab: The release is blocked by multiple Alembic heads
  • Lab: A migration works in staging and crashes on production
Performance (SQLAlchemy)0/2
  • Measure first: counting statements in async SQLAlchemy
  • Lab: The order list is slow for repeat customers
Async and concurrency0/3
  • Debugging async code: the loop and the races between awaits
  • Lab: The whole API freezes whenever somebody logs in
  • Lab: Store credit goes missing under load
Service calls and errors0/3
  • Debugging outbound calls and the errors you report
  • Lab: Paying hangs when the payments provider is slow
  • Lab: Customers cannot pay but the dashboards show no errors
Data model and validation0/2
  • Debugging validation models: absent is not the same as null
  • Lab: Saving one profile field erases the others
Configuration and security0/4
  • Debugging deployment settings and authorization
  • Lab: The API docs are blank behind the gateway
  • Lab: Any customer can read any order
  • Expert lab: Double charges, then a frozen API, then a kill switch that does nothing

React

React hooks0/4
  • Debugging hooks: dependencies, closures and identity
  • Lab: The updated badge never gets past 1
  • Lab: Changing the status filter does not reload orders
  • Lab: The Reports page hammers the API
Async and races0/3
  • Debugging async UI: ordering and failure paths
  • Lab: Customer search shows results for an older query
  • Lab: An order stays flagged after the server refused it
State and identity0/3
  • Debugging state: who owns it and which component it belongs to
  • Lab: Deleting a note makes the next note show the wrong text
  • Lab: The customer editor shows the previous customer
Performance0/3
  • Debugging React performance: measure renders and leaks
  • Lab: Typing in the quick filter makes every page re-render
  • Lab: Memory and CPU grow every time Orders is opened
API and configuration0/4
  • Debugging the edges: API results, dates and build-time config
  • Lab: The UI says Saved while the server was down
  • Lab: Revenue report shows the previous day for US users
  • Lab: The staging build still calls its own host

Fullstack

Sessions, cookies and CORS0/5
  • Where the browser and the API disagree: sessions, cookies and CORS
  • Lab: Staging console cannot sign in - the form just says "Failed to fetch
  • Lab: Sign-in succeeds, then Orders and Profile say "Sign in to continue
  • Lab: Saving anything fails with "The request could not be verified
  • Lab: Saving the profile fails with "The request could not be verified
The API contract0/4
  • Contracts across the wire: error bodies, query strings and paging
  • Lab: Error messages are gone - not-found and forbidden failures show "Request failed"
  • Lab: Searching for "R&D Kit" lists everything containing an R
  • Lab: Our newest orders are missing from the order history
Data and state0/4
  • Values that change meaning on the way: time zones, money and stale writes
  • Lab: The order I placed this evening is dated tomorrow
  • Lab: Every order in the history shows a total of under a dollar
  • Lab: Saving my profile on my laptop erased the phone number I just changed on my phone

FastAPI

Latency and slow APIs0/4
  • Debugging a slow API: blocked loops, sequential awaits and throwaway clients
  • Lab: The API stalls while shoppers search
  • Lab: The storefront takes the sum of its dependencies
  • Lab: A new connection for every charge
Debugging slow pages: measure first
Course contents

Production Debugging: Fix Real Bugs in a Live-Looking App

Course progress

0%
0 of 68 modules complete

Django

Performance0/3
  • Debugging slow pages: measure first
  • Lab: The order list page is slow for repeat customers
  • Lab: The staff dashboard hits the database too often
Data model and money0/4
  • Debugging wrong data: trace the value, not the screen
  • Lab: Invoices vanish when a customer is deleted
  • Lab: Order totals are one cent off
  • Lab: Evening orders land on tomorrow's report
Concurrency0/3
  • Debugging races: make the bug happen on purpose
  • Lab: A burst of signups crashes with IntegrityError
  • Lab: The last unit is sold twice
Migrations0/3
  • Debugging migrations: the graph and the data
  • Lab: The release is blocked by conflicting migrations
  • Lab: A migration that only fails on production data
Configuration and deployment0/2
  • Debugging configuration: what differs between here and there
  • Lab: Production has no styles or scripts
Calls to other services0/2
  • Debugging calls to other services: design for the failure
  • Lab: Checkout hangs when the payments provider is slow

FastAPI

Migrations (Alembic)0/3
  • Debugging Alembic: the revision graph and the data it meets
  • Lab: The release is blocked by multiple Alembic heads
  • Lab: A migration works in staging and crashes on production
Performance (SQLAlchemy)0/2
  • Measure first: counting statements in async SQLAlchemy
  • Lab: The order list is slow for repeat customers
Async and concurrency0/3
  • Debugging async code: the loop and the races between awaits
  • Lab: The whole API freezes whenever somebody logs in
  • Lab: Store credit goes missing under load
Service calls and errors0/3
  • Debugging outbound calls and the errors you report
  • Lab: Paying hangs when the payments provider is slow
  • Lab: Customers cannot pay but the dashboards show no errors
Data model and validation0/2
  • Debugging validation models: absent is not the same as null
  • Lab: Saving one profile field erases the others
Configuration and security0/4
  • Debugging deployment settings and authorization
  • Lab: The API docs are blank behind the gateway
  • Lab: Any customer can read any order
  • Expert lab: Double charges, then a frozen API, then a kill switch that does nothing

React

React hooks0/4
  • Debugging hooks: dependencies, closures and identity
  • Lab: The updated badge never gets past 1
  • Lab: Changing the status filter does not reload orders
  • Lab: The Reports page hammers the API
Async and races0/3
  • Debugging async UI: ordering and failure paths
  • Lab: Customer search shows results for an older query
  • Lab: An order stays flagged after the server refused it
State and identity0/3
  • Debugging state: who owns it and which component it belongs to
  • Lab: Deleting a note makes the next note show the wrong text
  • Lab: The customer editor shows the previous customer
Performance0/3
  • Debugging React performance: measure renders and leaks
  • Lab: Typing in the quick filter makes every page re-render
  • Lab: Memory and CPU grow every time Orders is opened
API and configuration0/4
  • Debugging the edges: API results, dates and build-time config
  • Lab: The UI says Saved while the server was down
  • Lab: Revenue report shows the previous day for US users
  • Lab: The staging build still calls its own host

Fullstack

Sessions, cookies and CORS0/5
  • Where the browser and the API disagree: sessions, cookies and CORS
  • Lab: Staging console cannot sign in - the form just says "Failed to fetch
  • Lab: Sign-in succeeds, then Orders and Profile say "Sign in to continue
  • Lab: Saving anything fails with "The request could not be verified
  • Lab: Saving the profile fails with "The request could not be verified
The API contract0/4
  • Contracts across the wire: error bodies, query strings and paging
  • Lab: Error messages are gone - not-found and forbidden failures show "Request failed"
  • Lab: Searching for "R&D Kit" lists everything containing an R
  • Lab: Our newest orders are missing from the order history
Data and state0/4
  • Values that change meaning on the way: time zones, money and stale writes
  • Lab: The order I placed this evening is dated tomorrow
  • Lab: Every order in the history shows a total of under a dollar
  • Lab: Saving my profile on my laptop erased the phone number I just changed on my phone

FastAPI

Latency and slow APIs0/4
  • Debugging a slow API: blocked loops, sequential awaits and throwaway clients
  • Lab: The API stalls while shoppers search
  • Lab: The storefront takes the sum of its dependencies
  • Lab: A new connection for every charge
Browsing without an account — progress is saved in this browser only.Sign in to save it

Debugging slow pages: measure first

Reading20 min

"The page is slow" is a symptom, not a diagnosis. Performance bugs are the ones where guessing costs the most: you can spend a day adding caches and indexes to code that only needed one line of queryset. The skill this section trains is turning a vague complaint into a number you can watch go down.

Turn the complaint into a measurement

A useful performance investigation starts with three questions. What exactly is slow (one page, one endpoint, one customer)? How slow, compared with what? And what changed? A ticket rarely answers them, so your first job is to reproduce the slowness yourself with data that looks like the reporter's. A customer with two orders and a customer with two hundred can behave completely differently.

Once you can reproduce it, pick something to measure that will still be meaningful after you change the code. Wall-clock time on your laptop is noisy. The number of database statements a request runs is exact, repeatable, and usually what the slowness is made of.

Sign in to try this knowledge check.

Count queries, not milliseconds

Django will tell you every statement it runs: the debug toolbar, the django.db.backends logger, connection.queries, or CaptureQueriesContext in a test. Load the page once with a small amount of data and once with a lot, and compare the counts. If the count grows with the amount of data, the code is doing work per row that could be done once for all rows. That shape has a name, N+1, and it is the most common cause of pages that get slower as customers get older.

Python
from django.db import connection
from django.test.utils import CaptureQueriesContext

with CaptureQueriesContext(connection) as ctx:
    client.get("/orders/")
print(len(ctx), "queries")
for q in ctx.captured_queries[:5]:
    print(q["sql"][:120])

A count that does not grow is a good sign; a count that does is a defect, whatever the timings say. It also gives you the assertion for the regression test you will write at the end.

Sign in to try this knowledge check.

Laziness is where the cost hides

Django querysets are lazy: nothing hits the database until something evaluates them, and the results are cached on the queryset only after a full evaluation. Related objects are lazy too: order.customer runs a query the first time you touch it, for every order. In templates this is invisible, because {{ order.customer.name }} looks like reading an attribute. The same laziness bites in a subtler way when you call count(), exists() and then iterate: each is its own query on an unevaluated queryset.

Read code with this question in mind: at which line does each queryset actually run, and how many times? The fixes are usually small (select_related, prefetch_related, evaluating once), but you only find the right line by tracing evaluation, not by reading the model definitions.

Sign in to try this knowledge check.

In the labs that follow, the ticket gives you a symptom and a customer-shaped hint. The workflow is always the same: reproduce, count, find the line that evaluates, fix it there, and write a test that fails on the old code because the count is higher than it should be.

NextLab: The order list page is slow for repeat customers

Course progress

0%
0 of 68 modules complete

On this page

  • Turn the complaint into a measurement
  • Count queries, not milliseconds
  • Laziness is where the cost hides