We recently covered this question in several iterations in the ravendb mailing list.
The actual content of the discussion wasn’t so interesting as the number of ways idle time can make you life… interesting. In order to avoid having issues with idle time, you need to:
- Disable IIS unloading for inactive websites.
- Disable RavenDB unloading for inactive databases.
- Make sure that the HD doesn’t spin down during inactivity.
- You need to make sure that the system doesn’t got to idle / hibenration.
- Check that the server hasn’t been paged.
- Check that the CPU hasn’t moved to low power mode.
- Check authentication timeouts.
In the end, it was actually the last one that caused the problem. By default, Windows Auth token expire after 15 minutes, so you have to re-authenticate again, and that may make the first query after a while a little slower.
Just for fun, by default, all of the above happen. And that is just when running on a physical machine. When running on VMs (or in the cloud), you need to do all of those checks for the VM and the host machines.