[英]How to run functions that take more than 10s on Vercel?
My app periodically runs a function which takes ~20 minutes to run.我的应用程序会定期运行 function,运行时间约为 20 分钟。
This is fine in development.这在开发中很好。 But when I deployed the app on Vercel, the function doesn't complete.
但是当我在 Vercel 上部署应用程序时,function 没有完成。
This is because Vercel allows up to 10s limit execution for functions.这是因为 Vercel 允许函数执行最多 10 秒的限制。 How can I run this function?
如何运行这个 function?
Unfortunately there is not much you can do if you want to keep using nextjs with Vercel.不幸的是,如果您想继续将 nextjs 与 Vercel 一起使用,那么您无能为力。 You can host it in aws amplify, but by the time of this answer the lambda functions are not working out of the box with nextjs 12. There are others services out there to help you hosting it in aws, but honestly you should be better of either not using nextjs api routes or, if you really want to use it, create an external app for doing the long process, triggered by the nextjs functions, and request the results to this app or to some database straight from the client side.
您可以将它托管在 aws amplify 中,但是到此答案时,lambda 功能无法与 nextjs 12 一起使用。还有其他服务可以帮助您在 aws 中托管它,但老实说,您应该更好要么不使用 nextjs api 路由,要么,如果您真的想使用它,请创建一个外部应用程序来执行由 nextjs 函数触发的漫长过程,然后直接从客户端向该应用程序或某个数据库请求结果。
This is Vercel's solution for the problem, which in this situation is not very helpfull https://vercel.com/guides/what-can-i-do-about-vercel-serverless-functions-timing-out这是 Vercel 针对该问题的解决方案,在这种情况下不是很有帮助
cron jobs, serverless lambda aws cron 作业,无服务器 lambda aws
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.