Michal Charemza
Michal Charemza

Reputation: 27012

Shiny: how does it handle concurrent requests?

If I start a Shiny application using

R -e 'shiny::runApp("/app", host="0.0.0.0", port=8888)'

how does it handle concurrent requests / what is its worker model?

Is each request handled in a different thread, process, does it use an event-loop model, or even, does it just handle them one at a time?

Upvotes: 1

Views: 392

Answers (1)

Pork Chop
Pork Chop

Reputation: 29397

  1. Since R is single threaded so as the shiny, and its built on top of node
  2. All sessions are connected via a websocket to that thread
  3. Traditionally shiny reactive programming using standard event loop model
  4. There is a concept of a flush cyclewhich does the following: receiving, updating, reacting, and sending so while reactives or observers are updated its not possible to update other inputs. This is done to avoid race conditions
  5. You can take advantage of async programming within shiny by using promises package
  6. If you want to integrate some of more advanced js libraries you can work with the V8 package
  7. You can also integrate react.js with shiny

Upvotes: 3

Related Questions