Can the webservice set a limit memory usage for who queries it?

Asked

Viewed 255 times

2

I’m having trouble with a webservice because I make a query that returns 69300 records and everything goes well but already with 69595 records it gives error.

The question: The webservice can you set a limit memory usage for the query? I am consuming 90MB in this query.

The program being run is strictly provided by webservice as shown below:

$array  = array ( 
        'key'       => '8b0dc65f996f98fd178a9defd0efa077',
        'module'    => 'imoveis',
        'method'    => 'busca_fotos',
        'field'     => array (
            'CODIGO'    => 'Codigo',
            'IMAGEM_G'  => 'Foto'
        ),
        # 'limit'   => '69300'
    );

    $client = new SoapClient(null, array (
        'uri' => 'http://soap.imo.bi/',
        'location' => 'http://soap.imo.bi/soap.dll',
        'trace' => 'trace'
    ));

    $res    = $client->get($array);
    $tot    = count($res);

    echo "<pre>";
         print_r($res);
    echo "</pre>";
  • 1

    I once understood that you was developing this web service. So you’re just having problems with the large amount of data returned by it, right?

  • And another thing, that key stated in your example is not your confidential information?

  • It can be changed. Regarding the problem, the large amount of data returned is the problem.

  • Take a look at my updated response.

2 answers

3

Ideally you set a limit of records returned query (where you can be sure it will not exceed your memory limit) and implement some kind of paging so that it is possible to navigate through all the results without having to submit everything at once.

Imagine if a Google search returned all the results at once.


Updating:

Following the manual of the web service you are using:

Parameter: limit

String: The result limit can be specified, it can be a simple numerical value or pagination. For pagination, it should be use the format x,y, where x is the registration number and y is the limit of records.

All you need is to use the parameter limit to page the results and pick up a piece at a time. This way you do what you have to do with this "page" of results, discard and part for next.

3


The basic question is quite easy to answer: yes, of course, it can. Any program can set limits as it wishes. Ideally, especially webservices has limitations to prevent abuse.

But by link posted it seems that the problem there is another. It seems that the server is bogged down. Ironically most likely by not imposing usage limits.

Without more information it is difficult to say exactly what is happening but it is clear that the service provided was not well developed, which is very common. It is very common for people to test to see if it works but forget that the most important test is to test to see what happens when it does not work and not let catastrophic situations like the one in the example.

  • Based on the Updating question, is it possible to talk about bad programming? Could it be problem related to webservice? On this server only has this script, there is nothing else.

  • 2

    I don’t know the SoapClient but overall this code does not seem to have any apparent problem. Of course this feedback created by SOAP can be gigantic. The problem may be there and not in script.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.