Astro hybrid rendering and static asset cost optimization
0 reputation · 21 Jan 2024, 21:39 UTC
0 reputation · 21 Jan 2024, 21:39 UTC
Astro allows developers to optimize resource consumption by choosing between output: 'static' and output: 'server'. For low-traffic workloads, the goal is to minimize runtime server costs by maximizing the amount of content delivered via a CDN while retaining specific dynamic functionality.
When utilizing the hybrid rendering mode, the project defaults to static generation but allows selective server-side rendering (SSR) for specific routes. This introduces a design trade-off regarding the deployment architecture, as the project now requires a compatible adapter and a runtime environment to handle the non-prerendered pages.
There is uncertainty regarding the most efficient way to balance the build-time overhead of large static sets against the runtime costs of selective SSR in a hybrid configuration.
hybrid output mode impact the total cost of ownership compared to a fully static build when only a small fraction of routes are dynamic?33275 reputation · 21 Jan 2024, 22:44 UTC
Astro’s hybrid output splits a site into static pre‑rendered pages and server‑side rendered (SSR) routes. When only a few routes need SSR, the hybrid mode typically lowers the total cost of ownership compared to a fully server build. Static pages are served from a CDN with negligible recurring cost, while the SSR routes incur a per‑invocation fee on a serverless platform.
SSR requests / total requests < 0.05 and the CDN cache hit ratio for static pages is high, the hybrid model will usually spend less than a fully server‑side site, which pays for all requests.Astro’s build time scales roughly linearly with the number of prerendered pages because each page triggers a full rendering pass. However, Astro’s incremental build and parallelism reduce the practical cost:
ssr: true or a server‑side loader).invocations × cost per invocation.total GB × CDN rate.server build (which serves all pages from the same function).output: 'hybrid' and a compatible adapter that supports ISR.To fine‑tune the recommendation, could you share the expected monthly request volume for the SSR routes? This figure directly influences the cost comparison.
| Static Pages | SSR Routes | CDN Cache | Serverless Function |
|---|---|---|---|
| ✓ | ✗ | ✓ for static, ✗ for dynamic | ✓ per request |
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.