Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何用一个请求调用两个AWS方法?_Amazon Web Services_Http_Amazon S3_Aws Lambda_Boto3 - Fatal编程技术网

Amazon web services 如何用一个请求调用两个AWS方法?

Amazon web services 如何用一个请求调用两个AWS方法?,amazon-web-services,http,amazon-s3,aws-lambda,boto3,Amazon Web Services,Http,Amazon S3,Aws Lambda,Boto3,我正在做一个项目,在其中调用两个方法,分别来自Boto3(用于Python的AWS SDK);每个请求平均持续1秒。所以,我想如果我能让AWS通过一个对AWS服务器的请求连续调用这两个方法,我可以缩短响应时间 举个例子,我以这种方式调用detect_faces()和search_faces_by_image()方法,其中将argument1转换为response2的过程持续2秒: // input: argument1 response1 = detect_faces(argument1) //

我正在做一个项目,在其中调用两个方法,分别来自Boto3(用于Python的AWS SDK);每个请求平均持续1秒。所以,我想如果我能让AWS通过一个对AWS服务器的请求连续调用这两个方法,我可以缩短响应时间

举个例子,我以这种方式调用detect_faces()和search_faces_by_image()方法,其中将argument1转换为response2的过程持续2秒:

// input: argument1
response1 = detect_faces(argument1)
// process response1 into argument2
response2 = search_faces_by_image(argument2)
// output: response2
我想提出一个请求,其中它将调用这两种方法并给出响应:

// input: argument1
response2 = custom_aws_method(argument1)
// output: response2

浏览互联网,我最好的发现是,我可以将argument1上传到S3存储桶中,使用Lambda服务进行处理,并通过SNS服务获得电子邮件回复。但是,通过这种方式,我认为响应时间不会减少,因为我必须获取电子邮件才能在Python上获得简单的响应。

在您的示例中,第一个请求的输出需要作为第二个请求的输入。因此,操作需要相同的总时间。如果您的目标是减少所需的总时间,则此目标不可能实现

但是,如果您有多个这样的请求,那么您可以使用多线程来并行发出API调用,而不是顺序发出API调用。这在执行多个长时间运行的操作(如文件上载/下载)时非常有用