英文:
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.
All the Above Api took only 60-70 mili seconds. But this last api took 10.24 seconds to complete
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.
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
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。我们需要将其更改为最大值。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论