-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
GiveCalc takes 30+ seconds to load on first visit due to Cloud Run cold start. The container spins down after inactivity and takes a long time to restart.
Root cause
The Docker container loads policyengine-us which is a large package. Cold start includes:
- Container startup
- Python interpreter initialization
- Loading policyengine-us into memory
Potential solutions
Option 1: Keep one instance warm (recommended)
Set min-instances: 1 in Cloud Run deployment.
- Cost: ~$15-30/month
- Eliminates cold start entirely
Option 2: Scheduled pings
Set up Cloud Scheduler to ping the API every 5-10 minutes to keep it warm.
- Cost: Nearly free
- May still have occasional cold starts
Option 3: Optimize container
- Use a slimmer base image
- Lazy load policyengine-us modules
- Pre-compile Python bytecode
Option 4: Better UX during loading
- Show informative loading message ("Starting tax engine...")
- Cache states list in frontend to show UI faster
Recommended action
Set min-instances: 1 - the simplest and most reliable fix. Update in .github/workflows/deploy.yml:
gcloud run deploy givecalc \
--min-instances 1 \
...Or via console: Cloud Run > givecalc > Edit > Minimum instances = 1
Metadata
Metadata
Assignees
Labels
No labels