Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25414

Concurrent requests for a document whose content isn't prepared yet all prepare it in parallel

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • 18.10.0-rc-1
    • 17.10.0
    • Old Core
    • Unknown

    Description

      XWikiDocument#getPreparedXDOM caches the prepared content of a document, but when there is no usable prepared content yet, each thread that asks for it runs the whole preparation of the content on its own. This happens when a document is loaded in the document cache or its content changes, and for each request sending Cache-Control: no-cache.

      The preparation of the content can be expensive: it includes, for example, the syntax highlighting of all the code macros of the page, also inside wiki macros. When many requests for such a page arrive at the same time (for example from crawlers), they all prepare the same content in parallel and compete for the CPU, so each of them takes longer and more requests pile up. In production, this was observed as a burst of requests taking up to more than 15 minutes, with almost all of their time spent preparing the content.

      Instead, a thread that needs the prepared content while another thread is preparing it should wait for that preparation and reuse its result when the cache control allows it, that is when the preparation started after the start of its request.

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              MichaelHamann Michael Hamann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: