Does anyone know what formula is used for this value specifically in the context of the Google Analytics dashboard? I want to set up a load test to match this value.
I believe that the "right now" number is calculated as the number of unique users that have visited the site in the last 5 minutes.
To figure this out, I set up GA on a fresh new site where I was the only visitor. I watched the real time report as I clicked around, and then I waited until the "right now" number went back down to zero. It was five minutes.
For load testing, I recommend ignoring Google Analytics. GA doesn't include most robots nor does it tell you about image, CSS, and JS assets downloaded from your site. Those can put significant additional load onto your servers.
For load testing it is usually much better to use you access logs. Replay all the hits from your access logs during a busy period to get a much more accurate view of how your web server performs under a real load.
Real time is calculated by a hit, which is an interaction resulting in data being sent to Google. Each time the tracking code is triggered by a user's actions (page view, conversion, refresh, etc) Google Analytics records that activity. Each interaction is packaged into a "hit" and sent to Google's servers.
There are some caveats with Real-Time view, which in my opinion is most effective to determine if you have installed GA properly. The following can affect the number of true or live visitors:
Real-Time is not compatible with User ID enabled views If you have any filters applied to your view (it's always best to have 1 view called "unfiltered" which has no filters or modifications made to it) then it may take up to 2 hours to reflect in Real-Time
*For Mobile Apps, hits are batched to preserve mobile device battery life - thus you may notice delays. "Batching" occurs on the order of minutes, according to Google.
Lastly, what may be the most likely culprit is Campaign Attribution - according to Google:
Due to a change in the way Universal Analytics sends and stores campaign information for Real-Time reporting, it is possible that, during a single session, a user stops being recognized as coming from a specific campaign and is instead counted as a direct referral. As a result, you'll see traffic and conversions incorrectly attributed to a Source of (direct). You'll only see this in Real-Time reports; in standard reports, traffic and conversions will be attributed correctly.
Hope this helps!