IIS服务器在递归函数中卡住了几秒钟。

huangapple go评论65阅读模式
英文:

IIS Server Gets Stuck for few seconds in recursion Function

问题

I'm calling a Flask API using AJAX with a recursive function. For most of the time, it works fine, but it gets stuck after around a minute.

All the above APIs typically take only 60-70 milliseconds to complete. However, the last API takes 10.24 seconds.

This delay is causing my entire camera app to stutter.

I initially thought the issue was in the code, but I tested the time difference inside the code, and it consistently stays at 60-70 milliseconds for all APIs.

So, it seems that before hitting my API code, it's getting stuck sometimes. I believe it's because the IIS Server is not hitting my Flask API in a timely manner.

Here's my configuration for the IIS Server:

Link to Image 4
Link to Image 5

Config File - C:\Windows\System32\inetsrv\config\applicationHost.config

Here's my JavaScript recursion function:

function api_Call() {
    cameraSensor.width = cameraView.videoWidth;
    cameraSensor.height = cameraView.videoHeight;
    cameraSensor.getContext("2d").drawImage(cameraView, 0, 0);

    let c = document.getElementById("cam_frame");
    c.width = cameraView.videoWidth;
    c.height = cameraView.videoHeight;

    $.ajax({
        type: "POST",
        headers: { 'Content-Type': 'application/json' },
        dataType: "json",
        data: JSON.stringify({'image': cameraSensor.toDataURL("image/webp")}),
        url: "/flaskapi3/imagepred",
        success: function (response) {
            data = response['data'];
            c.src = "data:image/png;base64, " + data;
            api_Call();
        },
        error: function (err) {
            setTimeout(function () {
                api_Call();
            }, 1000);
        }
    });
}

I hope this helps you understand the issue you're facing with your Flask API and the IIS Server configuration.

英文:

I'm calling an Flask API using ajax by recursion function.
For most of the time its working fine. But its getting stuck after around a minute.
IIS服务器在递归函数中卡住了几秒钟。

All the Above Api took only 60-70 mili seconds. But this last api took 10.24 seconds to complete

IIS服务器在递归函数中卡住了几秒钟。

Because of this my whole camera app look Stutter.

At first I thought it was getting stuck due to code. But I have tested with the time difference inside code and it stays at 60-70 milliseconds for all APIs.

IIS服务器在递归函数中卡住了几秒钟。

So before Hitting my API code its getting stuck sometimes. I believe its because of IIS Server is not hitting my flask API in time.

Here's my config for IIS Server

IIS服务器在递归函数中卡住了几秒钟。
IIS服务器在递归函数中卡住了几秒钟。

Config File-
C:\Windows\System32\inetsrv\config\applicationHost.config

</fastCgi>
...

<application fullPath="D:\aiml_python_code\yolov7-main\venv37\Scripts\python.exe" arguments="D:\aiml_python_code\yolov7-main\venv37\Lib\site-packages\wfastcgi.py" monitorChangesTo="" stderrMode="ReturnStdErrIn500" maxInstances="400" idleTimeout="2592000" activityTimeout="3000" requestTimeout="900000" instanceMaxRequests="200000" signalBeforeTerminateSeconds="0" protocol="NamedPipe" queueLength="100000" flushNamedPipe="false" rapidFailsPerMinute="1000" />
 </fastCgi>

Edit-

Here's my JavaScript recursion function

function api_Call() {

    cameraSensor.width = cameraView.videoWidth;
    cameraSensor.height = cameraView.videoHeight;
    cameraSensor.getContext("2d").drawImage(cameraView, 0, 0);

	let c = document.getElementById("cam_frame");
	c.width = cameraView.videoWidth;
	c.height = cameraView.videoHeight;

    $.ajax({
        type: "POST",
        headers: { 'Content-Type': 'application/json' },
        dataType: "json",
		<!-- timeout: 1000, -->
        data: JSON.stringify({'image':cameraSensor.toDataURL("image/webp")}),
        url: "/flaskapi3/imagepred",
        success: function (response) {
			data = response['data'];
			c.src = "data:image/png;base64, "+data;
			api_Call();
      },
        error: function (err) {
            setTimeout(function () {
				api_Call();
            }, 1000);
        }
    });

	};

答案1

得分: 0

在IIS FastAPI应用程序中找到配置。MaxRequests默认设置为200。我们需要将其更改为最大值。

  1. 转到FastAPI应用程序。
    IIS服务器在递归函数中卡住了几秒钟。

  2. 选择您的应用程序,将“实例的MaxRequests”从200更改为其最大值。
    IIS服务器在递归函数中卡住了几秒钟。

英文:

Found the config in IIS FastAPI App. MaxRequests default is set to 200. We have to change it to its maximum

  1. Go to FastAPI app.
    IIS服务器在递归函数中卡住了几秒钟。

  2. Select your App and change Instance MaxRequests from 200 to its Maximum value.
    IIS服务器在递归函数中卡住了几秒钟。

huangapple
  • 本文由 发表于 2023年2月6日 19:33:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360783.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定