[英]serverless vs serverfull in express-graphql?
I am introducing my self to serverless and stumbled upon this: https://github.com/serverless-components/express and can't seem to understand what's difference with serverfull deployed to heroku?我将自己介绍给无服务器并偶然发现: https://github.com/serverless-components/express似乎无法理解部署到 heroku 的 serverfull 有什么区别? see i have this code in serverless:
看到我在无服务器中有这个代码:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
console.log("test");
return {
schema,
graphiql: true,
context: {
request,
//user
},
};
})
);
module.exports = app;
and serverfull:和服务器:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
return {
schema,
graphiql: true,
context: {
request,
},
};
})
);
app.listen(port, () => console.log(`Listening on port ${port}`));
can somebody tell me if there's an advantage using serverless in express-graphql?有人可以告诉我在 express-graphql 中使用无服务器是否有优势? my frontend stack is graphql-relay and i am used to express-graphql and want to explore serverless using express-graphql stack but can't seem to find a good resource to do it.
我的前端堆栈是 graphql-relay,我习惯于 express-graphql 并想使用 express-graphql 堆栈探索无服务器,但似乎找不到一个好的资源来做到这一点。 as i am reading from this :
正如我正在阅读的那样:
At this point, I think it's worth noting that not everyone agrees that running Express in a serverless function is a good idea.
在这一点上,我认为值得注意的是,并非所有人都同意在无服务器 function 中运行 Express 是一个好主意。 As Paul Johnston explains, if you're building your functions for scale, it's best to break each piece of functionality out into its own single-purpose function.
正如 Paul Johnston 解释的那样,如果您正在构建功能以实现规模化,最好将每个功能分解为自己的单一用途 function。 Using Express the way I have means that every time a request goes to the API, the whole Express server has to be booted up from scratch — not very efficient.
以我的方式使用 Express 意味着每次向 API 发出请求时,整个 Express 服务器都必须从头开始启动——效率不高。 Deploy to production at your own risk.
部署到生产环境需要您自担风险。
please clarify me请澄清我
Some of the benefits of serverless: you execute your code on-demand only when it's needed in contrast to the traditional servers that will be running 24/7.无服务器的一些好处:与将 24/7 运行的传统服务器相比,您仅在需要时才按需执行代码。 In addition, it also managed by a service provider so you won't need to worry about maintaining and scaling your server.
此外,它还由服务提供商管理,因此您无需担心维护和扩展您的服务器。
You can read more你可以阅读更多
https://dashbird.io/blog/business-benefits-of-serverless https://dashbird.io/blog/business-benefits-of-serverless
https://www.serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless https://www.serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless
https://aws.amazon.com/serverless/ https://aws.amazon.com/serverless/
https://serverless.com/blog/serverless-architecture-code-patterns/ https://serverless.com/blog/serverless-architecture-code-patterns/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.