How is the general description in real time of the active users of Google Analytics calculated?

The real time is calculated by a hit, which is an interaction that results in sending data to Google. Each time the tracking code is activated by a user's actions (page view, conversion, update, etc.), Google Analytics records that activity. Each interaction is packaged in a "hit" and sent to Google servers.

There are some warnings with the view in real time, which in my opinion is the most effective to determine if you have installed GA correctly. The following may affect the number of true or live visitors:

Realtime does not support views enabled with user ID
If you have filters applied to your view (it is always better to have a view called "without filter" that does not have filters or modifications), it can take up to 2 hours to reflect in real time.

* For mobile applications, hits are grouped to preserve the life of the mobile device's battery, so you may notice delays. "Batching" occurs in the order of minutes, according to Google.

Finally, 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 reports, it is possible that,
during a single session, a user stops being recognized as coming from
a specific campaign and, instead, is counted as a direct reference. As a
As a result, you will see traffic and conversions incorrectly attributed to a
Source of (direct). You will only see this in the reports in real time; in
Standard reports, traffic and conversions will be attributed.

I hope this helps!