Ruby vs Node vs Go (Rails vs Express vs Gin)

Photo by Jonathan Chng on Unsplash

Comparing 3 web frameworks, how fast can they render the message “hello” via a templating engine back to the user. There is no optimisation going on. The premise is:

  • pull the framework
  • create the route controller handler
  • assign a variable with a string message
  • create the view for the template engine
  • render the view back

Load test

Using wrk, since all of them will be on the same port the command will be the same for all. Using 12 threads, concurrent 400 requests for duration of 30 seconds.

wrk -t12 -c400 -d30s http://127.0.0.1:3000/home

Ruby on Rails

This will be our baseline. Ruby used 2.6.3. Rails used 5.2. Command used to generate the Rails project.

After setting the route. The controller looks like this:

And the view looks like this:

Results: saw that CPU usage was around 100%.

Express.JS + EJS

Pretty standard setup. Using morgan middleware to output requests in console.

Results: saw that CPU was around 100%

Gin (Go)

The only package here is the Gin web framework. Everything else is standard Go. Oh, and to be a bit unfair we are gonna compile it into a binary, but it will still be running in debug mode.

Result: CPU usage was high, around 550%

developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store