4

I'm trying to do some tests on a SOAP API and am experiencing extremely slow execution times. I've done some digging and found that it's the SoapClient constructor that takes forever to execute. I also tried using a proxy for it to see if it's the http query resulting from it, but this query is executed relatively fast.. it's after the query that it lingers for about 30 seconds.

Here's a kcachegrind screenshot for reference:

kcachegrind

And here's the WSDL query in Charles Proxy:

charles proxy

This same problem has also been reported a couple of months ago here:

PHP: SoapClient constructor is very slow (takes 3 minutes)

But he did not get an answer.

Any suggestions would be much appreciated.

Edit:

The code portion where the SoapClient is initiated (this is part of the NetSuite PHP toolkit)

        $this->client = new SoapClient( $host . "/wsdl/v" . $endpoint . "_0/netsuite.wsdl",

                                    array(  "location"              => $host . "/services/NetSuitePort_" . $endpoint,

                                            "trace"                 => 1,

                                            "connection_timeout"    => 5,

                                            "typemap"               => $typemap,

                                            "user_agent"            => "PHP-SOAP/" . phpversion() . " + NetSuite PHP Toolkit " . $version

                                    )

    );
Community
  • 1
  • 1
Naatan
  • 3,424
  • 4
  • 32
  • 51
  • 1
    What happen when you run your script second time and wsdl file is already in cache? Also, have you tried to use locally saved wsdl file and measure your script execution time? – Dmytro Zavalkin Sep 21 '11 at 21:57
  • I played around with the WSDL caching to no avail. Also, like I said, based on what I found with Charles Proxy the hangup seems to occur after the WSDL was requested and returned. – Naatan Sep 22 '11 at 01:28
  • Check the soap.wsdl_cache_ttl option. Also, is the WSDL available via plain http? Maybe the ssl layer is what is causing the slowness at your side. – Maxim Krizhanovsky Sep 24 '11 at 20:25
  • The WSDL is not the problem, as you can tell from the info I posted the slowdown occurs after the WSDL has been requested and returned (I validated this with charles proxy, screenshot of which is above). The slowdown is usually around 30 seconds, the WSDL takes about 5 seconds over https (slow, but not 30 seconds slow). – Naatan Sep 24 '11 at 21:01

1 Answers1

4

Are you using multiple users? I was getting 3-20 minute lags on the same line of code which turned out to be related to multiple users causing multiple copies of the wsdl to be fetched. http://www.ozonesolutions.com/programming/2011/05/nsclient-login-time/

Daniel
  • 794
  • 10
  • 20
  • Hi, I am currently not using multiple users.. though that is definitely planned due to NetSuite's session limit. Sounds like there are some bugs related to the caching of the WSDL though :\ – Naatan Sep 26 '11 at 13:16
  • Whew quick update, I tried disabling WSDL caching and now it goes through very fast! So it definitely seems to be the caching. Having it disabled kind of sucks.. but it beats waiting 30 seconds for a response. Though your answer wasn't the solution, it did lead me to it. – Naatan Sep 26 '11 at 13:18
  • 3
    Seems I was a bit fast with my "solution", it's not WSDL_CACHE_NONE that solved it, but rather WSDL_CACHE_MEMORY. When using WSDL_CACHE_NONE it still takes a long time.. which is weird since it should be bypassing the problem causer altogether. – Naatan Sep 26 '11 at 13:24
  • Hi, can you tell me exactly how you solved this problem? Thanks. – keepwalking Nov 03 '11 at 07:48
  • Using only one user worked for me (see link above). However, Naatan's solution might be more useful. – Daniel Nov 04 '11 at 15:13