Skip to content

A weird issue: speed dropped  #747

Description

@stan023

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions