-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
I was simply asking why the Go/Fiber framework appears slower than Node/Express in tests involving multiple queries, if it's single query test is dramatically faster. How come ?
From what I observed, it seems Fiber doesn’t yet implement true parallel query execution—each query is handled sequentially within a goroutine. Meanwhile, Express benefits from Node.js’s event-driven, non-blocking architecture, allowing it to handle multiple queries asynchronously by default.
So the term “multiple queries” in this benchmark can be a bit misleading. I'm not checking for other go framework, they may have same issue.
Reference:
Fiber: server.go#L243-L253
Express: postgresql-app.js#L84-L94
I suggest for this changes
func queriesHandler(c *fiber.Ctx) error {
n := QueriesCount(c)
worlds := AcquireWorlds()[:n]
var wg sync.WaitGroup
wg.Add(n)
for i := 0; i < n; i++ {
go func(i int) {
defer wg.Done()
w := &worlds[i]
db.QueryRow(context.Background(), worldselectsql, RandomWorld()).Scan(&w.ID, &w.RandomNumber)
}(i)
}
wg.Wait()
c.JSON(&worlds)
ReleaseWorlds(worlds)
return nil
}
Metadata
Metadata
Assignees
Labels
No labels