Investigate: Improve the performance of package metadata generation
Context
Over the past several milestones, the Package group has tuned the performance of the npm registry. However, the response times can still be slow for metadata requests, which will grab every version of a given package.
Problem to solve
The main problem is that we need to sync things like:
- Metadata endpoint hit but no generated response exists. What do we do? enqueue a job + generate the response on the fly
- Package updated (new version or tag added/removed), the versionless package is now stalled and should be destroyed + a new generation job should be enqueued.
Proposal
- When an npm package is added/removed, npm tag added/removed enqueue a job that will generate the JSON response for that package and store in a versionless package (package without a version).
- When the metadata endpoints are hit, look for the versionless package and serve the generated response.
This is basically trying to offload the metadata response generated from the endpoints and have it in a background job. This is a great solution for packages heavily pinged with not that many updates.
Further details
This solution, even though it's a heavier one, presents an opportunity to think about metadata endpoints globally. Several other package types have the same need/endpoint so this logic of using a versionless package to "cache" the metadata document could be useful across all package types. (Helm, NuGet)