Skip to content

[Performance] Cold start delay on first API request #12

Description

@niat-web

Performance Issue

What happened:
When the app has not been used for a while,
the first API request (login or loading todos)
takes 3-5 seconds longer than normal.

Root cause:
Google Cloud Run is set to min-instances=0.
This means the container shuts down when idle.
When a request comes in, Cloud Run must
start the container first (called "cold start").
This adds 3-5 seconds to the first request.

Expected behavior:
API should always respond within 500ms.

Solutions:

Option 1 (Recommended for production):
Set min-instances=1 in Cloud Run.
Command:
gcloud run services update todo-backend
--region=asia-south1 --min-instances=1
Cost: approximately $5-10/month

Option 2 (Free solution):
Add a warmup ping from frontend.
When frontend loads, immediately call /health
to wake up the backend before user tries to login.

Acceptance Criteria:

  • First API request responds within 1 second
  • No noticeable delay for users

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendRelated to FastAPI backendlow-prioityNice to have but not urgentperformancerelated to app performance and speed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions