Difference between sessions, R processes and connections.

Hi all,

Though I’m working on R for the last couple of years, I am unaware of these concepts. Can anyone help me understand these.

Difference between sessions, R processes and connections.


I'm no expert on this either, but here is how I see this:

Every time you start R to tinker with code, it starts an R session. This session normally has 1 R process attached to it, given R is a single threaded language. So in most cases the session and the process are similar. I think the session is referring to everything that runs on top of the R process like the interface in which you are editing your code (e.g. RStudio)

There are a few cases where I feel there is a clearer distinction. First, when you run things in parallel (using any of the packages that implement this), the session will have multiple R processes attached to it, each running a part of the code in parallel. So they all belong to 1 session but are running different things. The second, opposite example is where you run an R script from a command line without actually opening the R or RStudio interface. In this case, you are just running an R process, but there is no interface active.

Finally, connections / sessions is more a thing I think about when working with Shiny. When someone connects to your app, it starts a new session. Multiple sessions can be attached to a single R process (again since R is single threaded) unless you have something like Shiny server where multiple processes can be started to handle more traffic from various sessions.

I hope this might help you a bit, but again I'm not sure I got all the details correct, so maybe someone else can correct me or add more.


Thanks for the response.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.