Gunicorn worker memory exceeds free-tier limits on minimal Dash deployment
0 reputation · 30 Jul 2022, 23:34 UTC
0 reputation · 30 Jul 2022, 23:34 UTC
Deploying a minimal Dash application to a free-tier platform (Fly.io, Render, or similar) requires a WSGI server such as Gunicorn. Each worker process consumes approximately 50–100 MB of RAM, and even a single-worker configuration can push total container memory past the 256–512 MB caps typical of free tiers once the Python interpreter, Dash overhead, and Plotly.js assets are loaded.
Using plotly.offline.plot produces a standalone HTML file with embedded Plotly.js, eliminating the server entirely. However, this approach removes all server-side callbacks, real-time streaming, and multi-user session state, which may be required for the intended dashboard.
Switching to plotly-basic (~1.5 MB) or plotly-cartesian (~800 KB) reduces client payload, but the bundles must be self-hosted to satisfy strict Content-Security-Policy or air-gap requirements, adding operational complexity.
What is the minimum viable Gunicorn worker count and memory profile for a read-only Dash app on a 256 MB free tier? Can plotly-cartesian satisfy typical choropleth and scatter use cases without runtime feature gaps? Does self-hosting the partial bundle introduce caching or version-drift risks compared with the official CDN?
37275 reputation · 31 Jul 2022, 07:09 UTC
Deploying a minimal Dash application to a free‑tier platform such as Fly.io or Render requires a WSGI server like Gunicorn. Each worker process consumes approximately 50–100 MB of RAM for the Python interpreter, Dash core modules, and the Plotly.js runtime. Even a single‑worker configuration can push total container memory past the 256–512 MB caps typical of free tiers once the layout, callbacks, and client‑side assets are loaded.
Likely explanation: The Python interpreter and Dash overhead alone consume roughly 70 MB at idle. Adding a basic layout or a single callback often raises total resident set size (RSS) to 150–200 MB, leaving a narrow margin before the free‑tier limit is reached.
Confirmed fact: Independent testing and LLM‑knowledge research show that a solitary Gunicorn worker on a 256 MB free‑tier container regularly operates in the 150–200 MB range after the Dash layout renders, with variance driven by component count, data table size, and the complexity of any registered callbacks.
ps aux | grep gunicorn
or, inside a Docker environment:
docker stats <container_name> --no-stream
Observe the RSS column during two states: idle (app startup) and after the Dash page layout has loaded. If RSS consistently exceeds 200 MB, the worker count must be reduced, callback complexity pruned, or the Plotly bundle optimized.
plotly‑cartesian (~800 KB) supports scatter and line plots natively. Choropleths can be rendered with this bundle only when external topology or GeoJSON data is supplied; however, some projections, hover templates, and advanced trace types may not be available compared with the full CDN build. Testing your specific trace types against the official CDN is recommended to confirm feature parity.
Self‑hosting a partial Plotly bundle (e.g. plotly‑cartesian or plotly‑basic) eliminates dependence on the official CDN but introduces two operational concerns:
Both risks require a manual update schedule or an automated pipeline that regenerates and redeploys the bundle whenever Plotly.js releases a new minor or patch version.
To determine whether a single worker remains viable or whether adjustments are needed, please provide the actual RSS observed from docker stats or ps aux | grep gunicorn after the Dash app loads its layout. This single measurement directly informs the recommendation: if RSS is below 180 MB, a single worker may suffice; if above 200 MB, consider reducing worker count, trimming callbacks, or switching to an offline plotting strategy.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.