Strange postgres slow query every day around the same time on Heroku

Viewed 383

I have a production app on heroku with postgres, serving a Rails API. Every day between 7-8am, there will be one or more long-running requests (about 20s or more) and it only occurs then. According to logs the time spent is in the database

  • There are no scheduled jobs
  • Backups are not scheduled anywhere close to that time
  • Traffic is at its lowest at that time
  • Memory is stable
  • There are other requests between the daily restart and that, so the dynos are not "cold"
  • It is not always the same endpoint, and it doesn't occur any other time

I'm not sure if it means anything but timezone is Singapore GMT+8, so 7-8am is right before midnight.

Has anyone else experienced this or has ideas to troubleshoot?

EDIT to add details:

enter image description here

You can see here (Scout APM) that it precedes the high throughput, basically before the start of the work day, so it's not due to load.

enter image description here

In fact there is pretty much no load at all. Neither is it the first request since server restart (at 4am). The slow request at 7:46am here was repeated at night (same url, same query string) which finished in under a second

0 Answers
Related