loopbackio / loopbackio/loopback-next
Performance issues with lb4 services
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
Using @service or @inject to inject services can lead to performance issues when calling api (although not using them).
i used [autocannon](https://www.npmjs.com/package/autocannon) for benchmarking
Full command: `autocannon -t12 -c1000 -d30 http://localhost:3000/ping`
I tried to inject services into the controller (ping.controller). The more services I import and the larger the project, the more req in seconds decreases
### Logs
_No response_
### Additional information
I ran the project on 8 CPUs and tried it multiple times. These are the average results I got.
- Without Injection
I ran the autocannon test and got around 680k requests in 30 seconds.
- With `@service` (around 37 `@service` with the same service file)
I got around 420k requests in 30 seconds.
- With `@inject` (around 37 `@inject` with the same service file)
I got around 600k requests in 30 seconds.
### Reproduction
https://github.com/u3ih/loopback-benchmarking
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked u3ih/loopback-benchmarking reproduction and its ping.controller setup, then run the stated autocannon command to compare no injection, @service, and @inject. Done means the cause of the request-rate difference is identified and the reported performance regression is addressed or clearly characterized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100