A weird issue: speed dropped
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Here is my code:
import express from "express";
import postgres from "postgres";
const sql = postgres('postgres://test:test@127.0.0.1:5432/test')
const port = 3000;
const app = express();
app.get("/", async (req, res) => {
for (let i = 1; i <= 20; i++) {
const xs = await sql`select * from posts where id=1`
}
res.send(`ok`);
});
app.listen(port, () => {
console.log(`Listening on port ${port}...`);
});
I run the following ab test:
ab -n 2000 -c 5 http://localhost:3000 ( number:2000, concurrency: 5 requests at a time)
The result is stable at around 900/sec, whatever times repeat the command.
Then I run:
ab -n 2000 -c 10 http://localhost:3000 (change 5 to 10)
The result is still around 900/sec
Then issue came. When I run
ab -n 2000 -c 5 http://localhost:3000 (change 10 back to 5)
After repeat this command several times, the results significantly dropped to 150/sec, and even keep dropping.
If I restart the express server, and run the above command, it become stable at 900/sec again.
This issue is that, if I set -c 10 and then set -c 5, the reqeusts/sec will drop significantly.
I have tested both ts-node and bun, both express and bun native serve, same issue occured.
Contributor guide
No contributing guide indexed for this repository
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 by reproducing the shown Express/Postgres.js example with ApacheBench, especially the sequence changing concurrency from 5 to 10 and back to 5. Compare the behavior across the tested runtimes and servers, then determine what causes throughput to keep falling after the concurrency change; done means the cause is established and the regression can be prevented or explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, express, javascript, nodejs, postgres
- Domain
- backend, database, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100