简体   繁体   English

如何在 Vercel 上运行耗时超过 10 秒的函数?

[英]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.

相关问题 如何将 Amplify Nextjs SSR 功能的超时时间从 10 秒增加到 30 秒? - How to increase timeout of Amplify Nextjs SSR function from 10s to 30s? 如何在 Vercel Next.js 上运行 http 请求 - How to run http request on Vercel Next.js .netlify/functions 的 Vercel 版本是什么? - What is the Vercel version of .netlify/functions? 如何将nextjs部署到vercel - how to deploy nextjs to vercel 如何在 Vercel 无服务器函数中处理 Postgres 连接池? (“角色连接太多”) - How to handle Postgres connection pooling in Vercel serverless functions? (“too many connections for role”) Vercel/NextJS:如何在本地开发期间从前端访问无服务器功能? - Vercel/NextJS: How to access serverless functions from frontend during local development? 在 vercel 无服务器函数上存储和更改单个变量 - Store and alter single variable on vercel serverless functions 如何使用 Next.js 应用程序在 Vercel(以前称为 Zeit Now)中安排 npm run build 每小时调用一次 - How to schedule npm run build in Vercel (formerly Zeit Now) with Next.js app to be called every hour npm 在 nextJS 和 vercel 部署中运行构建错误 - npm run build error in nextJS and vercel deploy 如何在 Vercel 上运行的无服务器 NextJS function 中替换 micro 的缓冲区 function? - How do I replace micro's buffer function inside my serverless NextJS function running on Vercel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM