Skip to content

Memory Optimization for SSR#186

Open
Uttkarsh-Srivastava wants to merge 3 commits into
feature/fix-memory-usagefrom
feature/fix-memory-usage-v2
Open

Memory Optimization for SSR#186
Uttkarsh-Srivastava wants to merge 3 commits into
feature/fix-memory-usagefrom
feature/fix-memory-usage-v2

Conversation

@Uttkarsh-Srivastava
Copy link
Copy Markdown
Collaborator

Summary

  • Cache ChunkExtractor in production - Reuse single instance instead of reading/parsing loadable-stats.json on every request
  • Cache routes array - Validate and cache routes once at module load instead of per-request
  • Add explicit bodyParser limits - Set explicit 100kb limit for json and raw parsers (best practice)

Files Changed

File Change
src/server/renderer/handler.js ChunkExtractor & routes caching
src/server/expressServer.js Explicit bodyParser limits

Why

In production, loadable-stats.json and routes don't change after build. Caching eliminates:

  • Repeated JSON file reads and parsing per request
  • Redundant route validation per request
  • Multiple getRoutes() calls per request

@deputydev-agent
Copy link
Copy Markdown

DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants