Here’s an example that demonstrates why variance often matters more than speed. Suppose you have a computer that runs one program at a time. Alice is studying astrophysics and running a complex planetary motion simulation that takes hours to run. Bob is learning to code and wants to run his first “Hello, World” script.
In isolation, Bob’s program will be fast. But if Alice is running her simulation at the same time, Bob may need to wait for hours for his code to run! In a multi-threaded OS, Bob’s code will still run about as quickly, regardless of whether Alice is running her simulation.
MongoDB currently has a limitation: one operation per socket at a time. By default, a Mongoose connection has 5 sockets open to the MongoDB server, so only 5 operations can make progress at the same time. You can configure this using the `poolSize` option.
For example, `poolSize = 1` means only one operation at a time. The `findOne()` in the below code will take 1 second, because it is blocked behind the “slow train” of the `find()` that sleeps for 1 second.