Skip to content

Render Deployment Setup


Service Configuration

Setting Value
Service type Web Service
Plan Starter (512 MB RAM, shared CPU)
Region Singapore
Runtime Python 3
Build command pip install -r requirements.txt
Start command Defined in Procfile
Auto-deploy On push to main

Render Services Used

Service Plan Purpose
Web Service Starter Flask + Gunicorn app server
PostgreSQL Managed Primary database
Redis Free tier Celery broker + result backend

Deploying

Automatic (GitHub Actions)

Push to main → Render auto-deploys.

Manual Deploy

In the Render dashboard: Manual Deploy → Deploy latest commit

Or via Render CLI: bash render deploy --service <service-id>


Environment Variables in Render

  1. Go to Render Dashboard → Web Service → Environment
  2. Add each variable from render.env as a Key-Value pair
  3. Mark sensitive variables as Secret (they won't be visible after saving)
  4. Click Save Changes — Render will redeploy automatically

Do not use Render's render.env sync

Render has a feature to sync env files from a repository. Do NOT use this — it would expose secrets in the Git history.


Health Checks

Render performs HTTP health checks on the root path (/). The Flask app serves a 200 response on / by default.

  • If health check fails 3 times → Render marks service as unhealthy and stops routing traffic
  • Gunicorn's --graceful-timeout=30 ensures in-flight requests complete before a health-check-triggered restart

Database Connection

Render provides two DB URLs:

  • External URL — standard PostgreSQL connection (SSL required)
  • Internal URL — Render-internal network, faster, no SSL overhead

Set USE_INTERNAL_DB=true in environment variables to use the internal URL. This reduces DB query latency by ~10–30ms per request.


Deployment Gotchas

Issue Cause Fix
OOM crash on deploy Flask app loads all models — brief RAM spike Lazy-load heavy libraries
Slow first request Worker cold start Acceptable; use --preload only if RAM allows
DB connection errors after deploy Pool not reset pool_pre_ping=True fixes stale connections
Wasabi ReadTimeoutError S3 slow response read_timeout=60 in boto3 config handles this

TL;DR

Render Web Service, Starter plan, Singapore region. Push to main → auto-deploy. Environment variables set in Render dashboard as secrets. PostgreSQL and Redis also on Render. Use USE_INTERNAL_DB=true for faster DB connections.