Merge request polling is expensive, does not cache adequately, should slow down on background tabs

Each open tab showing a merge request will poll GitLab.com at a high rate, generating expensive uncached requests.

For example, I opened a MR that has not seen activity for several weeks and monitoring the amount of polling traffic the tab generates:

image

https://log.gitlab.net/goto/b5d9cad45570e91484e00cd8901efa5d

(Some of this time, my laptop was closed)

This is what I found:

  • During the time that my laptop was open, the browser tab made ~5 requests per minute.
  • The tab was in the background for almost the entire duration of the test. Backgrounding a tab does not appear to slow the polling rate. It should. This would be good for the GitLab.com service and also for users laptop power consumption.
  • Not all of these are conditional requests (ie, using ETags or If-Modified-Since), The conditional request polling architect does not appear to being used. Documentation here: https://docs.gitlab.com/ee/development/polling.html
  • Other conditional requests still appear which generate a cache hit still appear to be relatively expensive (hitting Gitaly for example)

This all adds up to a lot of traffic generated by polling, most of it on unchanged resources.

Gitaly calls generated by merge request polling endpoints:

image

Database queries generated by merge request polling endpoints:

image

What can be done?

  1. Slowing polling on background tabs is both good for our servers and courteous to our user's laptop battery lifetimes. It would be easy to implement.
  2. Consider using the conditional request polling architecture: https://docs.gitlab.com/ee/development/polling.html (or, if there are reasons why it cannot be used in these cases, address those technical failings)
Edited by Andrew Newdigate