PHP new SOAP Client

I have a small PHP file that is used to retrieve data from a 3rd party via SOAPClient process every 10 seconds or so. To do this I have the PHP file loaded each time to trigger another SOAP request. My hosting company says that my site is using extraordinary resources and I wonder what I can do to reduce any strain on the hosting. I have 2 simple questions.

1. The file establishes a 'new SOAPClient' every time it loads but is always the same 3rd party WSDL file. Do I need to do this each time and, if so, does this action require 'closing' at the end of the PHP file (like using mysql_close after accessing a database)?

2. Is there a simpler, more efficient way using PHP SOAPClient to get this data every 10-15secs?

If the answer to no1 is proven to be 'yes - it should be closed' then there is no need for an answer to no2.

Many thanks.
robertybobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

virmaiorCommented:
1. There's no requirement that you need to close it.  the memory should be clearing when the script itself closes.  mysql_close itself is not really that useful.

2.  If you are pulling data every 10-15 seconds, then you may want to rethink the way you are doing this rather than ask how SOAPClient could be more efficient.  A few suggestions come to mind.  

First, why not leave the same instance of the app running for a few minutes at a time and just have it sleep 15 seconds between sending the requests?

Second, you could try to use WSDL caching, but I doubt this is much of the source of the high utilization.

Third, it might be more a question of what you do with the XML returned or how big it is to begin with.  The XML processor is heavily memory intensive in PHP.  In the case of one app, we are using regex to clean up their sloppy repetitiveness in order to handle things more smoothly.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
robertybobAuthor Commented:
Thx Virmaior.

The data would need to be retrieved for very long periods (hours) so I assumed that if the PHP file contains 'sleeps' before running a function to check data again it would never actually finish loading?

The WSDL file will be big but the data pulled fairly concise.

The main query was about the possible closing of SOAPClients so thats useful. I'm currently moving almost all calcs/processing to javascript as opposed to PHP and have the actual PHP flie requested down from 30k to less than 2k so this will certainly help bandwidth issues so will see about resources in time.

I'll close this question in the morning to allow others a bit of time to see it in case anything extra to be added.

Thanks again
0
virmaiorCommented:
I am not sure what you mean by
"The data would need to be retrieved for very long periods (hours) so I  assumed that if the PHP file contains 'sleeps' before running a function  to check data again it would never actually finish loading?"

you stated that
"I have a small PHP file that is used to retrieve  data from a 3rd party via SOAPClient process every 10 seconds or so"

what I am suggesting is that rather than start a new php script every 10 seconds, you use the same script for say 5 minutes to pass data and then start a new one...

...

if ran continuously, it would never finish loading, but by running it for longer than one pull, you could have it keep running and consume less resources.

----

one other question.  how big is the data that you are pulling down?


----

finally, it's not exactly clear to me why the appropriate response would be closing the question as I am answering your question.
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

robertybobAuthor Commented:
Sorry - when I said 'close' that meant accept answer and move on since it seems that the SOAPClient is coded correctly......

Whilst the file is small and the retrieved data per request is small, the data would be required to be retrieved every 10sec or so for 8-10 hours minimum every day. I can see if it would be possible to run the same file for 10-20 retrievals during each load but might not be feasible - tho is an interesting thought.

The response data from the WDSL is probably not more than 1k in size and in many cases much less.

0
virmaiorCommented:
yeah, maybe your host just sucks?
that's really not that much load.


0
robertybobAuthor Commented:
Thx - will see how it goes with the reduced PHP file size
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.