You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a bit unsure what I can provide here. How are you running your 100 requests against express? Node is single threaded, so it doesn't seem completely unreasonable that this may be handled like this.
If you add some kind of setTimeout in each request handler (and some random wait time), then you'll likely start to see some variability in responses.
If you only have a maximum pool size of 8, you're very likely to see a linear progression like this.
I imagine what is going on is something like:
A request comes in, it is handled, a request to the DB server is dispatched (meanwhile other requests are coming in/being queued)
next request is handled, a request is dispatched to the DB...
repeat for next 6 requests (making 8 requests in total)
another request comes in, the pool is depleted so the query is queued... repeat
whilst this happens, some db queries are fulfilled and need to be picked up by the event loop
node resolves all the elements in the event loop (incoming requests)
Other queries queued
response streams initialised / started / etc.
then all responses are sent out
Part of this is going to be limited by how many open sockets node can have at a time too, possibly. You'll need to do some pretty deep debugging to truly understand what is going on, but if the requests are also triggered in the same node thread, this linear queueing is going to be even more expected.
I am quickly calling an Express handler 100 times. In this handler I do a simple SELECT 1 query against a pool.
Expected behaviour:
A degree of overlap between the queries and the result arrivals
Actual behaviour:
All query responses arrive after all query executions.
Plus: I get a MaxListenersExceededWarning message.
The timing of the queries and result arrivals:
Configuration:
My code:
Software versions
The text was updated successfully, but these errors were encountered: