doujiao0110 2017-07-28 02:23
浏览 116

使用guzzle时PHP请求挂起

I have the following code:

$client = new GuzzleHttp\Client(
    array(
        'base_uri' => 'https://somesite.com'
    )
);

$response = $client->request('POST', '/api', [
         'form_params' => array(
         'action'   => 'getusers',
         'api_key'   => $_POST['key'],
         'id'       => $_POST['id']
    )
]);

When multiple users are accessing the same page with the following code above, other users waits for the first or recent request to finish before loading its request.

I'm not using any session.

I have tag curl because guzzle is built on top of it. Maybe it has something to do with it?

Any workaround for this?

using xhr won't fix it because the site I'm requesting for the API does not accept other origins.

  • 写回答

1条回答 默认 最新

  • dongyi0114 2017-07-31 14:07
    关注

    Check available PHP processes if you are using PHP FPM. It has a status page (the setup is described there) to get this information.

    If all the workers are busy, then client's requests will wait. You need to increase the amount of workers to be able to process more requests at once.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化