Automattic / Automattic/mongoose
Slow creation of documents with 100+ fields
- Dominant language
- JavaScript
- Stars
- 27.5k
- Forks
- 4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 35
Description
**Question**
We store mongoose documents objects in Redis as JSON.
We transform that objects to documents like this:
```
// const redisResponse = response from Redis
const docs = {};
for (let item in redisResponse) {
let doc = new myModel(JSON.parse(item));
docs[doc.id] = doc;
}
```
In `item` we have approximately 100 fields included embedded object.
The problem is that when we have 500 objects it takes 3 seconds to build all documents from that cached objects.
We have give to our NodeJs instance 500m (millicpu) CPU and 2048Mi RAM.
Contributor guide
Research direction
No repository files or tests are named. Reproduce the provided loop with 500 Redis-returned JSON objects containing about 100 fields, using the stated 500m CPU and 2048MiB memory, then profile document construction. Done would require an identified cause and a confirmed improvement or a clear explanation of the expected performance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js, redis
- Domain
- backend, databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100