Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using fastify-gql #231

Open
kripod opened this issue Jan 6, 2020 · 6 comments
Open

Consider using fastify-gql #231

kripod opened this issue Jan 6, 2020 · 6 comments
Labels
scope/server Related to the server component

Comments

@kripod
Copy link

kripod commented Jan 6, 2020

According to recent benchmarks done by Ben Awad, migrating to fastify-gql+graphql-jit could result in a 4x performance improvement.

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Jan 6, 2020

We’d mused about looking into this generally (other servers) but no issue/research yet. Thanks for kicking this off!

@jasonkuhrt jasonkuhrt mentioned this issue Jan 9, 2020
@jasonkuhrt
Copy link
Member

CC @mcollina 🙌

@jasonkuhrt jasonkuhrt pinned this issue Jan 9, 2020
@jasonkuhrt jasonkuhrt added the scope/server Related to the server component label Jan 12, 2020
@jasonkuhrt jasonkuhrt changed the title Consider using fastify-gql instead of apollo-server-express Consider using fastify-gql Jan 14, 2020
@jasonkuhrt
Copy link
Member

  • Serverless is something we think is important, so this was interesting to see:

    Fastify is not designed to run on serverless environments. The Fastify framework is designed to make implementing a traditional HTTP/S server easy. Serverless environments requests differently than a standard HTTP/S server; thus, we cannot guarantee it will work as expected with Fastify. Regardless, based on the examples given in this document, it is possible to use Fastify in a serverless environment. Again, keep in mind that this is not Fastify's intended use case and we do not test for such integration scenarios.

    https://github.com/fastify/fastify/blob/master/docs/Serverless.md#attention-readers

  • What do we lose by not being built on top of express? In particular, the community of middleware?

  • Ben already rolled his own taking inspiration from fastify-gql to make express-gql. No surprise his claimed motivation was that he was using some express middleware

  • We should make a perf baseline so that we can measure the impact of whatever change we make.

@mcollina
Copy link

Please check out https://github.com/fastify/aws-lambda-fastify#%EF%B8%8Fsome-basic-performance-metrics. All of this means that Fastify has a worse cold start time than express, while it provides better runtime performance (which is significant even on lambda).

I would also add that the caching technique in fastify-gql relies heavily on in-process caching to achieve maximum throughput. In-process caching is against the lambda philosophy, and as a result the benefit of something like graphql-jit are minimized.

@Weakky
Copy link
Collaborator

Weakky commented Jan 14, 2020

I think what this issue outline is that we definitely need a concept of plugins for servers. We will not fulfill everyone's requirements regardless of what we choose. We already see three different use-cases/motivations:

  • Performance (fastify)
  • Ease of use (compatibility with express middlewares & or apollo-server plugins)
  • Lambda

There's a couple of options for us as to what we choose by default (assuming we come up with a plugin system to support any graphql server). My suggestion would be to bundle by default a server that has the best ratio performance/bundle size. And for that, I think using something "minimal" like graphql-express is our best shot. WDYT?

@jasonkuhrt jasonkuhrt unpinned this issue Jan 16, 2020
@jasonkuhrt
Copy link
Member

About:

What do we lose by not being built on top of express? In particular, the community of middleware?

Well: https://github.com/fastify/fastify/blob/master/docs/Middleware.md

Fastify provides an asynchronous middleware engine out-of-the-box, which is compatible with Express and Restify middleware.

Later, expected:

Express modifies the prototype of the node core Request and Response objects heavily so Fastify cannot guarantee full middleware compatibility. Express specific functionality such as res.sendFile(), res.send() or express.Router() instances will not work with Fastify. For example, cors is compatible while passport is not.

I find this interesting as more a point for our own abstraction on the question of if we use fastify or not. See #295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/server Related to the server component
Projects
None yet
Development

No branches or pull requests

4 participants