开发者

Handling multiple outbound API calls in a PHP web application

开发者 https://www.devze.com 2023-04-11 09:50 出处:网络
I\'m working on a PHP (Zend Framework) web application that, for each user request, makes multiple calls to external APIs (SOAP and/or REST over HTTP).

I'm working on a PHP (Zend Framework) web application that, for each user request, makes multiple calls to external APIs (SOAP and/or REST over HTTP).

At the moment, the API calls are sequential:

  • Call API A, wait around 1 second for results
  • Call API B, wait around 1 second for results
  • Send page back to the user

In this instance there is no dependency or relation between APIs A and B; I simply want to return the page with all the information as quickly as possible.

At the momen开发者_运维知识库t I'm thinking of either:

  • curl_multi_exec() - http://php.net/manual/en/function.curl-multi-exec.php
  • ZeroMQ - http://www.zeromq.org/

curl_multi_exec() would bind my client code for APIs A and B more tightly than I'd like.

ZeroMQ seems more complex to implement, and I'm not sure how I'd manage the worker processes and sockets.

Has anyone successfully implemented this behaviour in a PHP/Apache application without too much fuss?


Sounds like you need a cache. They are pretty easy to make and can be either filesystem or any database extension.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号