How to Set OPC UA Monitored Item Queue Size
When a value changes several times between two publishes, OPC UA can either keep every change or throw the old ones away, and the queue size on each monitored item is what decides. Engineers who leave it at the default of one are surprised when fast pulses or counter jumps vanish on the trend. This page shows how to size the queue to your sampling and publishing rates so nothing meaningful is lost, and how to read the overflow flag that tells you when it was.
Set OPC UA Monitored Item Queue Size in one line: To set an OPC UA monitored item queue size, make the queue at least as large as the number of samples that can occur in one publishing interval - roughly the publishing interval divided by the sampling interval. Set the discard policy to keep newest or oldest per your need, and watch the overflow bit, which flags whenever the queue filled and a sample was dropped.
Work Out How Many Samples Fit Between Publishes
The queue holds sampled changes waiting for the next publish. So the number you need is how many samples the server can take in one publishing interval: publishing interval divided by sampling interval. If you sample four times faster than you publish, up to four changes can pile up between publishes, and a queue of one keeps only one of them. The rest are discarded and, unless you set the flag, silently.
This ratio is the whole calculation. A queue smaller than the ratio will drop data on any point that changes every sample; a queue larger than the ratio wastes memory but loses nothing. Because the settings interact, size the queue only after you have fixed the sampling and publishing rates - see OPC UA subscriptions and monitored items for how those two rates relate.
Choose the Discard Policy Deliberately
When the queue does fill, the discardOldest flag decides which sample dies. Keep oldest-discarded, the usual default, when you care most about the latest value and can tolerate losing intermediate steps: a level trend where only the current level matters. Keep newest-discarded when the sequence itself matters and the earliest unreported change is the one you must not lose.
For most process telemetry, discarding the oldest is right, because a monitoring client wants current reality. But for anything you are integrating or counting - a totalizer, an event stream - think hard, because dropping intermediate values corrupts the total. If sequence integrity is critical, a queue that never overflows is the only safe answer, which means sizing it to the ratio above with headroom.
Read the Overflow Bit to Confirm Nothing Was Lost
OPC UA sets an overflow indicator in a data change notification whenever the queue filled and a value was discarded. This is your ground truth: if the overflow bit never sets, your queue is large enough for the real traffic, whatever the theory said. If it sets, you are losing samples and the trend has gaps you cannot see any other way. Treat a set overflow bit the way you would a bad quality flag - see the OPC quality code substatus - as the server telling you the data is not complete.
Log the overflow occurrences during commissioning under realistic process activity, not a quiet test. A queue that is fine at 2 a.m. can overflow during a startup transient when everything moves at once. Size for the worst burst you expect, and the overflow bit staying clear through that burst is your acceptance criterion.
Verify With a Worked Example
Say a flow value is sampled four times per publish - a quarter-second sampling period against a one-second publishing interval. A queue of one keeps one of those four fast changes and discards three. Set the queue to at least four to keep them all; set it to five or six for headroom against a jittery sample clock. Push the flow through a fast swing and confirm the client sees each intermediate value, not just the endpoints.
Now confirm the overflow bit stayed clear through that swing. If it set, raise the queue and repeat. If it stayed clear, you have proven the queue against real motion rather than a datasheet number. Because the exact right size is site-specific, this measured verification is the step you cannot skip.
Common Mistakes
The default queue size of one is the classic trap: it silently downsamples every fast point to the publish rate, and because there is no error, nobody notices until a missing pulse causes a bad total. The second mistake is ignoring the overflow bit, which is the only signal that samples were dropped.
A third is over-sizing every queue to a huge number to be safe, which balloons server memory on a large subscription for points that never change fast. Size to the sample-per-publish ratio with modest headroom, not to a round large number. And do not use a deep queue to paper over a publishing interval that is simply too slow for the process - fix the cadence first.
Frequently Asked Questions
What queue size should an OPC UA monitored item use?
At least the number of samples that fit in one publishing interval - publishing interval divided by sampling interval - plus a little headroom. If you sample four times per publish, a queue of one keeps one of four changes and discards three. Confirm the size by pushing the value through a fast swing and checking the overflow bit stays clear.
What does the OPC UA overflow bit mean?
It means the monitored item's queue filled between publishes and at least one sampled value was discarded according to the discard policy. It is the only reliable signal that data was lost. If the overflow bit sets under realistic process activity, increase the queue size or shorten the publishing interval until it stays clear.
Should I discard oldest or newest when the queue overflows?
Discard oldest when only the current value matters, such as a level or pressure trend. Discard newest when the earliest unreported change must not be lost. For totalizers or event sequences, dropping intermediate values corrupts the result, so size the queue so it never overflows rather than relying on either discard policy.
Sources and verification
This page references the protocol specifications published by the organizations below. Editions, product capabilities, and documentation change over time - confirm current requirements and specifications directly with the source.
- OPC Unified Architecture Specification (IEC 62541) - OPC Foundation
Merobix is not affiliated with, endorsed by, or sponsored by these organizations; their names are used only to identify the standards and products discussed.
Automation services
Need help turning this into a working system?
Merobix integrates SCADA, programs Allen-Bradley and Siemens PLCs, and designs and fabricates industrial control panels.
Meeting requests are reviewed before confirmation.