nextcloud / nextcloud/server

User status automation: add caching or work with timestamped user status to reduce number of calculations / calendar queries

Open
#40,760 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage enhancement feature: status performance 🚀
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Feature Request

With https://github.com/nextcloud/server/issues/31177, the calculation for the user status will be redone any time the user status API endpoint is called, even if the availability hasn't changed at all.

This includes

  • loading of all calendars
  • querying of all calendars for events within the next hour
  • the availability calculation
  • updating the status if neccessary (db query)

As calendar queries are quite expensive, they shouldn't be redone any time the user status is called.

Implementation

There are two options on how to reduce the workload.

The first option is to cache all or some of the calculation by:

  1. Caching the complete FREEBUSY result
  2. Caching the VAVILABILITY settings (-1 query to the database)
  3. Not updating the status if a cache hit exists (-1 query to the database, plus no recalculation)
  4. Caching the query results for the calendar query
  5. Caching the search for calendars via principal URI

Using the status timestamp is another option to reduce the recalcualtation.

The user_status app already provides a timestamp when a status will become invalid. It would possible to use the end timestamp of a busy period from the FREEBUSY calculation to invalidate the status for a regular busy event.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the user status API endpoint and trace the calendar loading, FREEBUSY calculation, availability lookup, and status update described in the issue. Compare caching with using the status or busy-period end timestamp, then verify that repeated requests avoid unnecessary calendar queries and recalculation while status invalidation still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.