Skip to content

[Feature]: Track inputs exclusively via JS to optimize perfomance #171

@averissimo

Description

@averissimo

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Description

🏹 Goal: Add option to track inputs via JavaScript.

How?

  • Shiny javascript events allow to detect input changing via JS (see snipped below)
  • This could replace existing logic in Telemetry$.log_all_inputs
    • Sending a message to R Shiny and processed by Telemetry class
    • Or see "Taking one step further"
$(document).on('shiny:inputchanged', function(event) {
  if (event.name === 'foo') {
    event.value *= 2;
  }
});

Benefits:

  1. Performance improvements as the Shiny R session wouldn't be monitoring the input changes

Taking one step further

🏹 Goal: Delegate write operations to external API via JS

In other words, bypass using the DataStorage backend on the current R Shiny session and send the data to a deployment of the existing PlumberAPI

In turn, the Plumber API would write to the correct backend (LogFile, SQLite, SQL, ...)

Benefits:

  1. Performance improvements as write operations would be done asynchronously in JS only
    • without blocking Shiny R session

Cons:

  • Less guarantees that data is being written as process becomes asynchronous
  • Requirement to have a Plumber API instance running

Additional work:

  • Need additional check to verify availability of Plumber API
    • Implement fallback to write data locally
    • Add documentation on how to reconcile data storages
  • Plumber API needs to be optimized to handle more queries per second (using {future})

Diagram

image

Alternatives Considered

  1. Using a queue system that allows to group together multiple events Use event queue to send messages to data storage #148

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions