IS OPC UA a lot slower than OPC DA?
11 views (last 30 days)
Show older comments
Hi everyone,
I'm testing OPC UA versus OPC DA and I'm surprised, thta OPC UA seems a lot slower. Can I do something better in order to speed it up?
Here's just a short code I used for the test.
Thanks in advance for your help!
Swantje
% OPC UA
uaClient = opcua('opc.tcp://localhost:49320');
connect(uaClient);
simNode = findNodeByName(uaClient.Namespace,'Gruppe1');
myNodeTags = findNodeByName(simNode,'tag', '-partial');
tic;
[val,ts,qual] = readValue(uaClient,myNodeTags);
Dauer_UA = toc;
fprintf('Die Abfrage von %i Werten hat mit OPC_UA: %0.3f s gedauert\n', numel(val), Dauer_UA);
% OPC DA
daClient = opcda('localhost', 'Kepware.KEPServerEX.V6');
connect(daClient);
group = addgroup(daClient);
tagNames = arrayfun(@(i) sprintf('Kanal2.Device1.Gruppe1.tag%d', i), 1:25, 'UniformOutput', false);
items = additem(group, tagNames);
tic;
[data] = read(group);
Dauer_DA = toc;
fprintf('Die Abfrage von %i Werten hat mit OPC_DA: %0.3f s gedauert\n', numel(data), Dauer_DA);
0 Comments
Answers (1)
Ayush
on 22 Jul 2025
Hi Swantje,
I understand that OPC UA can appear slower than OPC DA especially in basic tests like the one you mentioned above.
You can try the following solutions to improve the OPC UA performance:
1. Avoid using "findNodeByName" function in production. This function is good for testing or exploring but not efficient. Here, once you have found your desired node paths, save them and reference them directly in the code (further this can be automated as well).
Here is the MATLAB code for your reference:
myNodeTags = [...
opcuaNode('ns=2;s=Kanal2.Device1.Gruppe1.tag1', uaClient), ...
opcuaNode('ns=2;s=Kanal2.Device1.Gruppe1.tag2', uaClient), ...
... % add more as needed
];
You can read more about "opcuaNode" here in the official documentation: https://www.mathworks.com/help/icomm/ug/opcuanode.html
2. OPC UA supports "batched reads", but not all servers or clients handle this efficiently. You can try the following:
a. test whether breaking large reads into smaller batches improves speed.
b. Compare read speeds for smaller chunks.
3. You can also try to use subscriptions instead of polling like for example if you're repeatedly reading values, you should consider using subscriptions instead of "readValue". Subscriptions push value changes, which can be more efficient over time. You can read more about subscriptions here in the official documentation: https://www.mathworks.com/help/icomm/ug/subscribe-to-opc-ua-nodes.html
Here is pseudo MATLAB code for your reference:
sub = subscription(uaClient, 1);
h = subscribe(sub, myNodeTags);
4. Try checking server limits: You can limit the performance of OPC UA connections unless specifically tuned. Check for example:
a. Maximum items per read
b. Maximum number of sessions
c. Client update rate (scan rate)
You can read more about "OPC UA" here: https://www.mathworks.com/discovery/opc-ua.html
Hope it helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!