Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

high CPU usage in PHP, using ReadMultipleItems, ToString

More
29 Sep 2010 13:53 #88 by steveh
Thanks for the response.1) The retrieved strings are typically: "12 {VARTYPE(3)} @20/08/2010 18:08:44; OPCQUALITY(192)"and no longer. Some strings with a bad quality value have no value component: "@28/09/2010 16:05:52; OPCQUALITY(28)"but excluding these makes no difference.2) I am getting no failures. I always get a return string for each tag requested.3) I dont really understand how to extract the various different types of data using COM objects in PHP. I have been following your single PHP example, and learning from experimentation, and from attempting to convert examples in other code types to PHP. There is precious little guidance available out there for this combination. I will try using the Vtq->Value method to see if that makes a difference.

Please Log in or Create an account to join the conversation.

More
29 Sep 2010 11:26 #87 by support
I will try to reproduce it here.
Some initial thoughts and answers:
1) In the loop you provided (foreach($results as $X) $result=$X->Vtq->ToString();), there is actually a lot of switching between your application, and the QuickOPC-COM (i.e. eopcdal process, if "Local Server" is used). Retrieving the Vtq property needs one switch to QuickOPC, and calling ToString another switch. And the CPU load would be generated by both processes. That itself, however, should not be a problem, and unless we are talking some extreme data such as megabyte-sized strings, the CPU should remain relatively low.
2) I would not expect any direct relation to which target server is used. The fact that this does not occur with the test server is weird. What kind of data is the real server returning? Isn't it possible that some or all of the readings have failed? In such case, the ReadMultipleItems method itself would succeed, but the Vtq property would not be accessible, or more precisely, an attempt to access it would return a failed HRESULT, which in most hosts leads to a runtime exception - but maybe we need to check precisely what PHP does, especially in this kind of loop.
3) If you suspect that the ToString method is causing this, have you tried something a bit different? - such as extracting the Vtq->Value (or other sub-properties), and converting it to a string in your app code instead?

Please Log in or Create an account to join the conversation.

More
29 Sep 2010 02:59 #86 by steveh
The memory leak problem seems to be solved with the upgrade to PHP 5.3.3, however I am having another problem with CPU usage. It was probably always there but masked by the more obvious memory leaks.

The real world CLI script I am using is now exhibiting a steadily increasing CPU usage, until the core used by the PHP process reaches around 85% usage, at which point it levels off and the script just runs quite slowly. This takes several minutes to build. The eopcdal process does not increase CPU usage at all. See the attached images. I have the opcdal process running as a service.

I have been doing some work to try to understand what is causing this, but so far it is not clear.

It would be usful to be able to understand what aspects of a ReadMultipleItems() call and its result disection will show up as PHP usage. Superficially it looks like the ToString() method may be a culprit. It looks like ReadMultipleItems() calls alone dont cause the increase, but when I then extract values from the result using ToString() the usage starts to climb.

Can you say whether all the CPU usage for the loop:
foreach($results as $X) $result=$X->Vtq->ToString();
would be all PHP, or would some of it be eopcdal?

It looks for all the world that the PHP process is drowning in housekeeping.

Also, I have not been able to reproduce this behaviour using the test server, so is it possible that processing aspects of the OPC server that the eopcdal service is communicating with could be contributing to the degree of PHP CPU usage?

Any assistance appreciated.

Cheers,

Steve.

PS - you might want to move this to a new thread.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.049 seconds