Does formr execute R Code sequentially?

25 views
Skip to first unread message

Samuel Merk

unread,
Oct 8, 2021, 6:33:36 AM10/8/21
to formr
Dear all!

I think - but I'm not sure, that formr executes R Code sequentially. Is this right?
I played with a minimal example containing only one note with `r Sys.sleep(20)` and starting two surveys (approx.) simultaneously. While the first slept for ~20sec, the second slept for ~40sec.

If this is true, I think it's not a good idea to run an R-extensive experiment simultaneously with 400 participants (e.g. in a lecture) :-).

Best
Samuel

Ruben Arslan

unread,
Oct 8, 2021, 6:39:31 AM10/8/21
to Samuel Merk, formr
Hi Samuel,

in principle, formr uses multiple concurrent threads in R/OpenCPU. However, if there are already many in use, which seems possible given the growing number of users, you might get queueing like you describe. I hope you don't have a real use case for Sys.sleep and this was just for testing? 
However, if you were using the same "session", i.e. you clicked "Test survey" twice, the explanation is a different one, i.e. formr waits until the first survey "returns" before dealing with the second request. This is to ensure consistent data for one user (don't overwrite things you are requesting in the second request). This should only be noticeable during testing, as for regular users, they have only one page per session. You could differentiate this by making a run and opening it once in an incognito window and once non-incognito. If it both takes 20s then, then it's not about queueing in R.

Best,

Ruben

--
You received this message because you are subscribed to the Google Groups "formr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to formr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/formr/20f4d517-22b1-4d69-9dfe-4a32184ca0d9n%40googlegroups.com.

Samuel Merk

unread,
Oct 8, 2021, 9:18:56 AM10/8/21
to formr
Hey Ruben, thanks for the fast response! 

  • Sys.sleep() indeed was only for testing :-)
  • Starting the run in an incognito window and a non-incognito windows results in two times 20 seconds.
  • What is your gut feeling: Is it worth to test what happens when 400 users more or less simultaneously start a survey which contains R syntax for producing a plot which takes about 1 second system time on a Notebook?
Best & Thanks!
Samuel

Reply all
Reply to author
Forward
0 new messages