Introduction

restana is a blazing fast, minimalist, “connect”-like middleware layer compatible framework, that is optimised for building performant REST APIs.

Someone can just say, it is a minimalist version of express.js

const app = require('restana')({})
app.get('/user/:id', (req, res) => {
  res.send('Hello user: '+ req.params.id)
})
app.start(3000) 
restana framework analogy 😉 — photo courtesy of https://pexels.com

Not just another framework

As described in a previous postI am an API Gateway guy, and I do strongly believe that distributed systems are the present and the future.

Some time ago, during my contribution to the Hydra Integration project, I had the opportunity to research and reflect on the performance of top 10 tradicional Node.js frameworks used for building REST APIs.

Later on at ShareNow, I spent most of my time building APIs and distributed systems with Node.js.

I found out that most of those widely used frameworks like Express, Hapi, Restify, Sails, … contains many layers of “optional/unused” code that run over and over again for every request/response cycle!


In modern architectures, where micro-services become the ultimate “dummy computing instance”, using Express, Sails or Hapi.js should be seen as an unnecessary technological decision, you are not building monoliths anymore…

So here is the list of what I though was the minimum requirements for an ideal REST APIs optimised framework:

  • Low overhead, zero friction HTTP Server abstraction (HTTPS, HTTP2 compatible).
  • Request routing capabilities.
  • Connect-like middleware compatible (so we can re-use hundreds of existing middlewares).
  • Async/Await compatible.
  • JSON serialisationas first class citizen.
  • Low memory consumption, high throughput.
  • Extensible and un-opinionated.

And this is how the restana project was born back in April 2017, initially as a performance experiment:

https://www.npmjs.com/package/restana

A look after 3 years

At the time of writing, restana has time-travelled to v4.3.4, 366 commits, 41 releases, 8 contributors and ~1500 weekly downloads.
View at Github https://github.com/jkyberneees/ana

The core of restana, the reason for its extreme performance was moved into a separated project named: 0http
https://www.npmjs.com/package/0http

0http is currently the faster HTTP server framework implementation ever written in pure Node.js, also confirmed by this independent benchmark:
https://github.com/the-benchmarker/web-frameworks/blob/37f10ec284cad74552ad3012b51165c74fdbba54/README.md

Restana is also the default HTTP server framework for fast-gateway, the awesome Node.js API Gateway:
https://www.npmjs.com/package/fast-gateway

The restana-static docker image allows developers to efficiently serve static files using Node.js: https://hub.docker.com/r/kyberneees/restana-static


Besides the community adoption, as a tech lead, I have used restana in production at scale, not just one, but several times.

So, what makes restana special?

  • Extreme performance!
Source https://www.npmjs.com/package/restana
  • No optional or unused code, every line is required and carefully optimised for performance.
  • Light, but complete routing engine with middlewares and nested routers support.
  • Simple error handling mechanism with async support.
  • Minimalist, extensible and un-opinionated.
  • Connect/Express.js middlewares compatibility.
  • Plays best with distributed architectures such as micro-services.
  • Includes TypeScript definitions for IDE code completion.

Conclusions

The restana project is an invitation to write faster and resource efficient REST APIs in Node.js.

You are invited!

Spread the love