R Shiny + Future + Plumber

743 Views Asked by At

Preamble

Inspired by the presentation by Barret Schloerke at studio::global(2021) (I will add the link as soon as it becomes available), I tried to implement an app to see the differences between using {future}, {plumber}, both or none into a Shiny app running a sequence of fast-slow-slow-fast computations (both on distinct output and in a sequence within the same one).

Gist

You can find here my attempt, including the app.R Shiny app and the plumber.R APIs.

Results

execution selected (5 s for "slow") result expectation comments
Standard run ~20 seconds before anything appear, next everything appears in the same moment ~20 seconds, appearing sequentially somehow Why did not appear sequentially?
{future} only ~5 seconds before anything appear, next everything appears in the same moment ~20 with "first fast" and "second fast" appearing almost immediatly and next (~5) "first slow" or "second slow," next (~10) the other, and finally (~20) "Sequential") I would expect that something similar to what happened here for the combined type of run... how is possible that "sequential" completed in 5 seconds???
{plumber} only same as the standard run (r should remain busy until each API call would be resolved, right?) same time (~20) but appearing sequentially some how why shiny rendered everything the same time?
{future} and {plumber} same as the standard run I do not expect this at all!, What I expected here is to have "_fast"s appearing immediately, "_slow"s quite the same time after ~5 seconds, and "sequential" after ~10 seconds from the start (i.e., ~10 seconds overall) I am totally confused here :-(

Doubts

One of the main things I did not understand is why when activating {future} (both with or without {plumber}), "first fast" does not appear immediately. And in general, why the output does not appear in a single sequence when {future} is not involved. And how is it possible that with {future} alone, "sequential" stay ~5 seconds?

So, clearly, I made something the wrong way, and I do not understand something correctly.

Questions

Can someone help me understand where/what (and maybe try to infer "why") I made the app wrong, and/or the API wrong, or their interaction wrong?

Thank you, Corrado.

0

There are 0 best solutions below