express-graphql 中的无服务器与全服务器?
serverless vs serverfull in express-graphql?
我正在自我介绍无服务器并偶然发现了这个:https://github.com/serverless-components/express 似乎无法理解部署到 heroku 的 serverfull 有什么区别?看到我在无服务器中有这段代码:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
console.log("test");
return {
schema,
graphiql: true,
context: {
request,
//user
},
};
})
);
module.exports = app;
满服务器:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
return {
schema,
graphiql: true,
context: {
request,
},
};
})
);
app.listen(port, () => console.log(`Listening on port ${port}`));
有人可以告诉我在 express-graphql 中使用无服务器是否有优势?我的前端堆栈是 graphql-relay,我习惯于 express-graphql 并想使用 express-graphql 堆栈探索无服务器,但似乎找不到好的资源来做这件事。正如我正在阅读 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. 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. 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. Deploy to production at
your own risk.
请澄清一下
无服务器的一些好处:与 运行 24/7 的传统服务器相比,您仅在需要时按需执行代码。
此外,它还由服务提供商管理,因此您无需担心维护和扩展服务器。
你可以阅读更多
https://dashbird.io/blog/business-benefits-of-serverless
https://www.serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless
https://aws.amazon.com/serverless/
https://serverless.com/blog/serverless-architecture-code-patterns/
我正在自我介绍无服务器并偶然发现了这个:https://github.com/serverless-components/express 似乎无法理解部署到 heroku 的 serverfull 有什么区别?看到我在无服务器中有这段代码:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
console.log("test");
return {
schema,
graphiql: true,
context: {
request,
//user
},
};
})
);
module.exports = app;
满服务器:
app.use(
"/graphql",
graphqlHTTP(async (request) => {
// add user context
return {
schema,
graphiql: true,
context: {
request,
},
};
})
);
app.listen(port, () => console.log(`Listening on port ${port}`));
有人可以告诉我在 express-graphql 中使用无服务器是否有优势?我的前端堆栈是 graphql-relay,我习惯于 express-graphql 并想使用 express-graphql 堆栈探索无服务器,但似乎找不到好的资源来做这件事。正如我正在阅读 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. 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. 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. Deploy to production at your own risk.
请澄清一下
无服务器的一些好处:与 运行 24/7 的传统服务器相比,您仅在需要时按需执行代码。 此外,它还由服务提供商管理,因此您无需担心维护和扩展服务器。
你可以阅读更多
https://dashbird.io/blog/business-benefits-of-serverless
https://www.serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless
https://aws.amazon.com/serverless/
https://serverless.com/blog/serverless-architecture-code-patterns/