Express vs Fastify performance (2024)

The goal of this article is to find out what web framework deliver better performance for simple Node.js microservice.

Almost two years I was a big fan of Express. Now is a time to test something new. Fastify support HTTP2 and can deliver a better performance. Let’s check it out.

How I test

I use two c5.large AWS instances in the same region and the same AZ. One as microservice and another as load testing server.

Microservice

  • Ubuntu Server 18.04 LTS
  • Nginx as a reverse proxy for Node
  • Node v10.15.0 LTS
  • PM2
  • Express 4.16.4
  • Fastify 1.13.3

Load testing server

  • Ubuntu Server 18.04 LTS
  • wrk

I’ll run two simple apps implemented in Express and Fastify. I’ll start and test one by one. Also, I’ll test four endpoints with a different payload size. Every endpoint I will test with a different number of open connections. Every test duration is 2 minutes.

Source Code

Results

GET /books

Return an array of 10 books.

Win: Fastify

Express vs Fastify performance (2)
Express vs Fastify performance (3)
Express vs Fastify performance (2024)

FAQs

Express vs Fastify performance? ›

By using the fast-json-stringify library, fastify can serialize JSON string much faster than express , and such difference makes fastify to be faster than express .

Is fastify slower than Express? ›

Fastify is around 20% faster than Express in almost every request. The only exception is a request with an empty response (possible due to an issue with a code).

What are the advantages of fastify over Express? ›

Fastify provides full encapsulation for plug-ins, automatically parses JSON with relatively faster rendering, and provides quick routing. Among other benefits, Fastify also has a cleaner syntax for writing async code in controllers. Express, however, has a stronger user base with plenty of documentation available.

Is ExpressJS good for large projects? ›

Middleware frameworks, like Express. js, are suitable for small and medium projects. If you are going to develop a large project that will be supported by a large team of developers, Express. js is not the best choice.

Is fastify compatible with Express? ›

The fastify-express plugin adds full Express compatibility to Fastify. It provides a use() method which we can use to add Express middleware and routes to our Fastify server. This gives us the option of gradually migrating parts of an existing Express application over to Fastify.

Does Microsoft use fastify? ›

Fastify is downloaded more than 700,000 times a week. At this moment, it is used in about 25,000 projects. A lot of companies are already on board, including giants such as Microsoft.

Is ExpressJS still relevant? ›

js is a minimalistic framework and does not come with many features out of the box. This means you will have to use third-party libraries or build your own solutions for certain functionality. Despite this, Express. js is still a very popular choice among Node.

Why is ExpressJS so popular? ›

One of the many reasons ExpressJS is so popular is the availability of numerous frameworks and libraries that provide extremely powerful tools for developing highly scalable, feature-rich software applications. In addition, several businesses rely on these frameworks and libraries to develop their applications.

Why NestJS is better than Express? ›

NestJS provides a more structured and opinionated approach, which can make it easier to build complex APIs with proper separation of concerns. Express, on the other hand, is more lightweight and flexible, which makes it a popular choice for simple or small-scale APIs.

Why use KOA over Express? ›

Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. By leveraging async functions, Koa allows you to ditch callbacks and greatly increase error-handling.

Which framework is best for large-scale applications? ›

Express and Django, for instance, are considered among the best backend frameworks for large-scale web applications. Angular and React are considered as top frontend frameworks.

Does NextJS replace ExpressJS? ›

Does NextJS Replace ExpressJS? No, it does not, as both Next. js and Express. js are two different frameworks that are used to build different sets of applications.

How scalable is ExpressJS? ›

Express. js has proven to be very scalable over the years because of the number of large companies using the framework on their server daily. It handles user requests and responses efficiently and requires little to no extra configuration when developing a large-scale web application.

Is fastify a backend? ›

Fastify is a framework for backend web development with a powerful plugin architecture and the least overhead. It's primarily inspired by Hapi and Express and is one of the fastest web frameworks running on Node.

Does NestJS use fastify? ›

A significant advantage of NestJS is that it is framework-independent. Instead of using Express, we can use an adapter using another library with a similar request/response pipeline. The most popular implementation besides Express is the Fastify adapter.

What is fastify Express alternative? ›

Bareserver is an extremely simple and fast web server for Node. It's a new way to build RESTful services. It's a minimal alternative to Express, Fastify, and the like.

Is FastAPI faster than Express? ›

Bun/express simply outperforms Python/FastAPI in almost all the metrics by a high margin.

Which companies use fastify? ›

54 companies reportedly use Fastify in their tech stacks, including Armut, payever, and bee10.
  • Armut.
  • payever.
  • bee10.
  • Development.
  • airCloset.
  • Backend.
  • Protect.
  • Seven Senders.

How many requests can Express handle per second? ›

A benchmark made by Fastify, shows that Express. js can handle approx 15,000 requests per second and the basic HTTP module, 70K requests per second.

What is better than ExpressJS? ›

Fastify is aimed at helping developers quickly build high-performance APIs and web apps in NodeJS and TypeScript. It processes requests 20% faster than ExpressJS, making it a good ExpressJS alternative. Top features: Fastify can handle up to 30,000 queries per second, depending on the complexity of the code.

Is it worth learning NodeJS in 2023? ›

So, without a doubt, Node. js is immensely popular. It is basically JavaScript, and as you may know, JavaScript is not only the most popular programming language but also, it is a core technology of the World Wide Web. So, it is definitely worth learning an incredibly popular language.

Is NodeJS still relevant 2023? ›

NodeJS is absolutely still relevant in 2023. In 2022 Node. js overtook Javascript code library React. js to become the most commonly used framework for web development worldwide.

Is Express better than NodeJS? ›

Compared to NodeJS, ExpressJS manages server setup clutter more efficiently. In contrast, NodeJS has an event-driven, non-blocking I/O model, which makes it a practical and lightweight server option. There must be a low-latency environment that can handle many concurrent connections.

How do I make ExpressJS faster? ›

6 Easy Ways to Speed Up Express
  1. gzip Compression. gzip compression isn't anything new to web servers, but it's an easy thing to forget about, especially when you're used to using frameworks that enable it by default. ...
  2. Minify with Uglify. ...
  3. Reduce Your Middleware. ...
  4. Increase Max Sockets. ...
  5. Use Cache-Control.
Feb 13, 2023

How fast is ExpressJS? ›

Express is a big hit among developers for the speed it delivers to Node. js applications. In terms of speed, a simple 'Hello, World' benchmark performance shows that an Express program can handle 11,202 requests per second.

Why don't use NestJS? ›

Do not use NestJS if: You are building micro-services. The level of abstraction is too generic with overly simple examples in the documentation and it does not allow for the level of granular control needed.

What is the downside of NestJS? ›

Cons for using the NestJS framework

At some point, most NestJS projects will encounter circular dependencies. This problem is well-documented by both Nest and the community package nestjs-spelunker, which focuses on the overall dependency injection tree.

Who is NestJS competitor? ›

Top 10 NestJS Alternatives
  • Ext Js. Ext Js is the best alternative for NestJS. ...
  • Jhipster. Another best alternative for NestJS is Jhipster. ...
  • Angular. It is free and open-source web application framework written in typescript language. ...
  • Express. js. ...
  • D3. Js. ...
  • Moment. js. ...
  • Backbone. js. ...
  • CreateJS. Another alternative for Nest.

What is the best middleware for node JS? ›

Recommended Express middleware libraries

Express is the most popular framework when building NodeJS web applications.

Is Express good for production? ›

Express is used by big names like Accenture, IBM, and Uber, which means it's also great in a production environment. If you are similarly using Express in this manner (or even just using Express with a team), it's important to learn how to organize your project structure to increase productivity.

Why is KOA so expensive? ›

Why is KOA So Expensive? In many cases, you get what you pay for. KOA is expensive because it's privately owned and operated. The owners have expenses they have to cover for franchising the KOA name.

What is the best language for API development 2023? ›

JavaScript, Python, C#, Java, C, C++, Rust, Go, TypeScript, and Swift will be the best programming languages for app development in 2023.

Which deep learning framework is fastest? ›

Francois Chollet originally developed Keras, with 350,000+ users and 700+ open-source contributors, making it one of the fastest-growing deep learning framework packages. Keras supports high-level neural network API, written in Python. What makes Keras interesting is that it runs on top of TensorFlow, Theano, and CNTK.

Which framework is best for web development in 2023? ›

11 Most Popular Web Frameworks
  • Angular. A front-end web framework that specializes in single-page applications, Angular uses HTML and TypeScript. ...
  • jQuery. jQuery helps developers use JavaScript and document object model (DOM) manipulations more easily. ...
  • React. ...
  • Ruby on Rails. ...
  • Vue. ...
  • ASP.NET Core. ...
  • Django. ...
  • Express.

Why I don t use NextJS? ›

Next. js is not very flexible when it comes to routing. The default approach is page-based, where you specify whether to generate those pages server-side, client-side or static. While this is good for simple applications, if you need something more complex, you'll need to write a lot more code and make use of Node.

Is there anything better than next JS? ›

Choosing between Next. js and React depends on the specific needs of your project. If you're building a large-scale web application that requires complex routing and heavily data-driven components, React may be a better option.

Is NextJS faster than React? ›

The major difference between Next JS and React JS is performance. If we talk about Next. js applications, they are extremely fast because of the static destinations and server-side rendering. Of course, they are viable due to many performance enhancement features, such as Image Optimization.

Which companies use ExpressJS? ›

1944 companies reportedly use ExpressJS in their tech stacks, including Twitter, Accenture, and kevin..
  • Twitter.
  • Accenture.
  • kevin.
  • Intuit.
  • Client Platform.
  • Trustpilot.
  • Pratilipi.
  • Frontend Stack.

What is the maximum response size in ExpressJS? ›

The default maximum renderable response size is set at 50MB.

How popular is ExpressJS? ›

According to Stack Overflow's 2022 survey, ExpressJS is still among the most widely used web frameworks, and it is considered a very rational choice to build large-scale applications with. Express is a JavaScript framework, so both the frontend and the backend can be built using the same (extremely popular) language.

What is the fastest JS framework? ›

Vue.js is the fastest JS framework available. Developed by a former Google Engineer, Vue is a lightweight framework that has an architecture focused on declarative rendering and component composition.

How many requests can fastify handle? ›

Let's cover a few of the features that makes Fastify so performant: Fast—able to serve up to 30,000 requests per second (depending on code complexity) Fully extensible via its hooks, plugins and decorators. Expressive and developer friendly.

Which tool is best for backend web development? ›

Frameworks and Platforms
  • Django. Image Source. Specifically for Python, Django is a back-end web development framework that allows you to efficiently create applications. ...
  • Ruby on Rails. Image Source. ...
  • Node. js. ...
  • Meteor. Image Source. ...
  • Laravel. Image Source. ...
  • Heroku. Image Source. ...
  • GitLab. Image Source.
Feb 7, 2023

How fast is fastify? ›

Highly performant: as far as we know, Fastify is one of the fastest web frameworks in town, depending on the code complexity we can serve up to 76+ thousand requests per second. Extensible: Fastify is fully extensible via its hooks, plugins and decorators.

Is NestJS good for Microservices? ›

In fact, NestJS provides a range of advanced features that can be used to build robust and scalable microservices. Let's explore these features in more detail. One helpful feature of NestJS is the ability to use pipes to transform incoming request data.

Which is better NestJS or Nextjs? ›

Nest might be the ideal choice if you are more familiar with JavaScript and are willing to learn new things in-depth. However, if you want to stick with traditional JavaScript frameworks, Next would be a better option for you as it has a lower learning curve.

Can I use Express without node? ›

You cannot use Express without NodeJS by definition so you have to deploy your backend somewhere else in you want to use it. I suggest giving a look Firebase: you could write your backend using http cloud functions in express without paying anything until a reasonable amount of traffic (after that, is pretty cheap).

How do you get raw body in fastify? ›

import fp from "fastify-plugin"; import rawbody, { RawBodyPluginOptions } from "fastify-raw-body"; export default fp<RawBodyPluginOptions>(async (fastify) => { fastify. register(rawbody, { field: "rawBody", // change the default request. rawBody property name global: false, // add the rawBody to every request.

Is FastAPI faster than ExpressJS? ›

From simple math, we can see that Express and Gin are 2.6 and 14.8 times faster than FastAPI respectively in terms of average time per request. Also, Express and Gin can serve 4.7 and 12 times more requests than FastAPI respectively in the same time period.

Which Python API framework is fastest? ›

Top Python Frameworks for Web Development in 2023
  1. Django. Django is a free, open-source Python framework that enables rapid development of complicated code and applications by programmers. ...
  2. CherryPy. CherryPy is a lightweight, quick, and stable Python web development framework. ...
  3. Pyramid. ...
  4. Grok. ...
  5. TurboGears. ...
  6. Web2Py. ...
  7. Flask. ...
  8. Bottle.
Mar 14, 2023

What is the fastest API framework for go? ›

Fast performance: Echo framework is known for its fast performance and is able to handle a large number of requests quickly and efficiently. This makes it a great choice for building APIs that need to handle a lot of traffic.

Is Django faster than FastAPI? ›

FastAPI is way faster than Django and is one of the fastest web frameworks for Python. The only faster frameworks are Starlette and Uvicorn (fun fact - FastAPI is built on Uvicorn). It used to be challenging, but since Python 3.4 Async I/O was added, FastAPI allows out-of-the-box concurrency.

What is the fastest JavaScript runtime environment? ›

Bun is a fast all-in-one JavaScript runtime

Run, test, transpile, and bundle JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime built for speed, with a native bundler, transpiler, test runner, and npm-compatible package manager baked-in.

Which is the fastest web framework NodeJS? ›

Some of the most popular and fastest node js framework include:
  • Fastify.
  • Koa.
  • Express.
  • Restify.
  • Hapi.
Jul 28, 2022

Which is better NextJS or ExpressJS? ›

And the main difference between ExpressJS and NextJS is that, If you are building an API or a server-side application, then the ideal option would be to use ExpressJS as it is lightweight, flexible, fast, has a large developer community, and comes with certain plugins for app development.

Can Nextjs replace Express? ›

Next. js doesn't replace Express and you can use them together. Next. js uses some Node.

Which framework is better than Express? ›

When performance is a critical demand from your web application, Koa is what you need. Especially for a big project, the framework can build extensive apps with large and experienced development teams. Under certain circ*mstances, Koa has proven to be a faster framework than Express.

Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6427

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.