问题描述
我已经坐了一段时间了,这是一个问题.我使用Web Apps部署了flask应用程序,它包括一个网站和一个预测API.首次访问该网站时,预测所需的文件已加载到内存中.我具有始终在线"功能 在使用中,但据我了解,它只能ping通根站点,并且API本身位于.../predict上,因此似乎不受影响.
I have a problem I've been sitting on for a while. I deployed a flask app using Web Apps, it includes a website and a prediction API. When the website is first accessed, files necessary for prediction are loaded into memory.I have the 'Always on' function in use, but as I understand it it only pings the root site and the API itself is on .../predict, so it seems unaffected.
如果API空闲了一段时间,则第一次调用时需要很长时间才能做出响应,然后又很快.经过一番调查,似乎在需要我较早地加载到内存中的文件的部分中,它的速度变慢了,这导致 我相信这些文件已在某处卸载,并且将它们重新备份所需的时间比从头开始再次加载它们要花费更长的时间. (我不想每次都加载它们,因为这会大大降低响应速度.)
If the API is idle for a while, it takes a long time to respond when it's called for the first time, and then it's fast again. After some investigation it seems it gets slowed down in the parts that need the files I loaded into memory earlier, which leads me to believe those files are offloaded somewhere and it takes a lot longer to load them back up than it would've been to load them again from scratch. (I do not want to load them every time as it would slow down the response a lot.)
有人可以证实我的怀疑或向我指出一些可以解释为什么会发生这种情况的资源吗?
Can someone confirm my suspicion or point me to some resources that would explain why this is happening?
谢谢!
推荐答案
这篇关于Flask API闲置后执行速度缓慢(始终处于打开状态)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!