BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles Interview With Fastify Node.js Web Framework Co-Creator Matteo Collina

Interview With Fastify Node.js Web Framework Co-Creator Matteo Collina

This item in japanese

Bookmarks

Key Takeaways

  • Fastify is a Node.js web framework focused on performance and developer experience
  • The Fastify team has spent considerable time building a highly supportive and encouraging community 
  • Fastify gained adoption by solving real needs of Node.js developers
  • Contributing to Fastify is strongly encouraged and several active contributors have found contributing as a great way to advance their careers
  • The key to open source success is finding balance and not trying to do everything for everyone.

Fastify is an open source, low performance overhead Node.js web framework filling a significant need in the ecosystem. Fastify emphasizes developer experience as a driving force in building a solid open source project and community. The Fastify project is part of the OpenJS Foundation.

To learn more about the recent Fastify 3 release and the Fastify project as a whole, we’ve invited Matteo Collina, Technical Director at NearForm, co-creator of Fastify and active contributor to the Node.js project, to join us.

InfoQ: Thanks for joining us Matteo. How did you first get started working on Fastify?

Collina: In 2016 I started helping companies scale their Node.js deployments and solve their performance issues and bottlenecks together with my colleague David Mark Clements (who also worked for NearForm at the time). We identified a common set of problems between all our clients:

  1. Generating a flamegraph to identify CPU bottlenecks was too hard. We needed a quicker user feedback loop to make the progress we were aiming to make, so 0x was born (part of Node Clinic now).
  2. Logging was a major bottleneck of all Node.js applications, so we wrote Pino. At the time Pino was about 10x faster for certain common cases. Thanks to improvements on the V8 side and a renewed focus on performance by other loggers, the gap shortened to a 2x factor. Pino has been a huge success and is now downloaded 2 million times per month.
  3. All major web frameworks at the time (e.g. Express, Restify, Hapi and Koa) introduced a huge overhead in Node.js, cutting the throughput to 10-25% of what Node.js could do. In order to compete with the incumbents, a new web framework would have to keep track of the development of the language, have an extensible plugin system and have close to zero overhead.

After we introduced Pino at Node.js Summit 2016 in San Francisco, I started thinking more about the third problem: writing a web framework. I decided this task was too big for just me (David had been pulled in another direction) and that I needed somebody else from another company to help. 

I wanted to create a web framework built on the same open governance ethos of Node.js. I decided to grow a community first and a framework later.

I started working on some preliminary modules, avvio (Fastify plugin system) and fast-json-stringify (2x throughput in rendering JSON objects), and I built a quick proof of concept. The name of this module was originally “beo” — a short version of “be open”. We renamed it to Fastify at the end of 2016.

While I was giving a training course on Node.js in Bologna (my “alma mater”), Tomas Della Vedova asked me how to get a career in open source, and I told him we could work together to build this new web framework. Tomas now works at Elastic and is the maintainer of the ElasticSearch client on npm.

InfoQ: That’s a really amazing story regarding Tomas Della Vedova. I actually got one of my first jobs in a similar fashion! What have you learned along the way working on Fastify?

Collina: Let’s list three key learnings among the thousands:

  1. “Performance” can never be an afterthought. It must be backed in from day zero. It is one of the key reasons for “rewriting from scratch”.
  2. Community matters more than anything else. I underestimated significantly the amount of effort it would take to ship a production-ready version of Fastify. Now we have around 15 individuals helping out in this community.
  3. Users will demand free support, and it is important not to give it to them. Enable them to learn and fix their own bugs instead.

InfoQ: I think we could write an entire article or ten about the expectations of open source maintainers and their time, but I digress! Are you surprised by the current state of web frameworks like Fastify today?

Collina: I think the ecosystem has been stagnating a bit due to the massive popularity of Express. There are infinite tutorials on how to use it, and its name is often associated with Node.js. 

Express v4 does not natively support async/await, which is a new construct in the language that greatly simplifies the development of applications, leaving applications affected by memory leaks and possible denial of service attacks by resource exhaustion. There are a few workarounds for this, but the fact that the framework does not natively support this is problematic. Express v5 has been in the works since 2014.

InfoQ: As one of the people that works on Dojo, I’m quietly hoping that Express v5 might soon replace Dojo as the longest time to write a next major version of a JS framework! ;) There’s a lot of talk at times about open-source fatigue. How do you stay focused and energized working on Fastify and Node.js? Any rewarding moments or stories you’d like to share?

Collina: In my experience, open source fatigue comes from maintenance. Here is my strategy: I mainly fix my own bugs and review PRs from others. I very seldomly fix bugs that do not affect me (or my clients) directly or indirectly. From developers and companies, I ask if they would like to send a PR. My tagline is “Would you like to send a PR? Remember to add unit tests.” I also have this as a GitHub template.

InfoQ: How has Fastify evolved over the past couple of years? What are some of the things that led to the significant performance improvements?

Collina: Fastify had no significant performance improvement as it is almost as fast as Node.js core. It adds very little overhead. One of the hard things is to balance adding new features without compromising throughput.

One important improvement in the recent v3 release was TypeScript support, which was primarily contributed to by Ethan Arrowood. I met Ethan at Node.js Interactive 2018 in Vancouver, Canada. He asked me how to get started in open source, and I said that we had a great vibrant community in the Fastify project. In 2019 Ethan completely rewrote our types, making Fastify fun and easy to use in TypeScript. Ethan is an engineer at Microsoft now.

InfoQ: There seems to be a common thread here: contribute to Fastify, get a job related to Fastify!

Collina: I would not guarantee this to anybody, but it has been the case with Tomas, Ethan and two others. Open source is a great way to build your own network and be publicly recognized for what you can do. You can also learn a lot via the code reviews of your peers — quality tends to be higher in OSS because there is no deadline.

InfoQ: What’s next for Fastify?

Collina: I would say stability for a year or so, as we plan to ship the next major in Q1-Q2 2021 when we can remove support for Node.js 10.x without affecting our users (see https://github.com/nodejs/Release). We will focus on the ecosystem modules and bring a fantastic developer experience in the meanwhile.

InfoQ: If someone wants to contribute to Fastify, how should they get involved?

Collinahttps://www.fastify.io/contribute/ lists all “good first issues” that newcomers can take and solve. We are normally quick in reviewing pull requests. We recommend folks to fix and work on things that you care about or use. If you find a bug or a typo, send a PR or open an issue!

InfoQ: Do you have any Fastify success stories you can share? 

Collina: There are a lot of stories that I cannot talk about and a few that I can! NearForm recently shipped the COVID-19 contact tracing application for Ireland (and a few other countries). All servers are built on top of Fastify, and they sustained a quick growth of usage from zero to 1.5 millions active users in a few days.

Yoox-Net-A-Porter has been using Fastify as their API gateway logic for a few years: Microservices: Solving a problem like routing — 2020 updateMicroservices: Solving a problem like routing - part 1Microservices: Solving a problem like routing — part 2.

InfoQ: Obviously Deno has received a lot of buzz, but there’s obviously a healthy level of skepticism about the project. Do you have any thoughts you’d like to share?

Collina: Competition is healthy! I think Deno is bringing a lot of good ideas to the Node.js community which we are implementing (both top-level await and security policies are being worked on).

One of the areas Deno differs from Node.js is the module system. I believe the fundamental reason npm and Node.js got the massive success they did is because they solved the key problem of software reuse. As we all saw, massive software reuse at world scale had some issues. I think the Deno module system is fundamentally less safe than what is npm now. Another left-pad incident is waiting to happen, but this time there is no “central entity” that can fix it.

I did not like Deno's marketing approach to the extent that I stopped following anybody tweeting about it. As an example, one of the maintainers claimed that it would “destroy Node.js” in a popular talk in Paris (that part was edited out of the talk). Similar “destroy Node.js” memes were tweeted by various parts of the community, and even the main Deno twitter account trolled Node.js with a joke. On the technical side, the methodology they use for benchmarks does not compare things equally. From my measurements in May 2020 (also confirmed by others), Node.js is close to being twice as fast as Deno in synthetic load tests.

I do not see any reason to start using (or supporting) Deno at the moment, and the community culture around Deno does not currently feel as inviting or supportive as the culture we have worked hard to foster for Node.js and Fastify.

InfoQ: Do you have any personal habits around development or self care that you would like to share with our audience?

Collina: Invest in proper equipment. We spend a lot of time in front of a screen and the quality of a proper desk (ideally with a standing option), monitor, chair, laptop, keyboard, mouse, mic and camera matters a lot. The chair, desk and screen are probably the most important bits as you need to keep an ergonomic posture while working; otherwise you will hurt your back seriously. Working on a sofa or on a kitchen table are not long-term solutions, so you need to be careful in this “remote first” world.

InfoQ: Exercise and eat well — maybe I should not take time to explain those, right? :) Thank you Matteo for taking the time to tell InfoQ and our readers about Fastify!

About the Interviewee

Matteo Collina is Technical Director at NearForm, where he consults for the top brands in the world. In 2014, he defended his Ph.D. thesis titled "Application Platforms for the Internet of Things". Matteo is a member of the Node.js Technical Steering Committee focusing on streams, diagnostics and http. He is also the author of the fast logger Pino and of the Fastify web framework. Matteo is an renowed international speaker after more than 60 conferences, including Node.js Interactive, NodeConf.eu, NodeSummit, JSConf.Asia, WebRebels, and JsDay just to name a few. He is also co-author of the book "Node.js Cookbook, Third Edition" edited by Packt. In the summer he loves sailing the Sirocco.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT