Skip to content

Instantly share code, notes, and snippets.

@fxg42
Last active January 26, 2017 20:02
Show Gist options
  • Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Comparing Express, Phoenix, Rails, Flask, Grails and... PHP?
<?php
echo json_encode(array('hello'=>'world!'));
?>
from flask import Flask
from flask import jsonify
app = Flask(__name__)
@app.route("/")
def hello():
return jsonify(hello="world!")
if __name__ == "__main__":
app.run()
class HelloController < ApplicationController
def index
render json:{"hello"=>"world!"}
end
end
class HelloController {
def index() {
render([ hello:"world!" ] as grails.converters.JSON)
}
}
var express = require('express');
var router = express.Router();
router.get('/', function(req, res) {
res.json({hello:'world!'});
});
module.exports = router;
defmodule HelloPhoenix.PageController do
use Phoenix.Controller
alias Poison, as: JSON
plug :action
def index(conn, _params) do
json conn, JSON.encode!(%{hello: "world!"})
end
end
@fxg42
Copy link
Author

fxg42 commented Nov 4, 2014

I ran 100K queries first and than did a benchmark for 10k. The idea was to give any vm optimization a chance to run. In Grails' case, the first 10k queries were dealt with at a rate of 400 req/s. After 100k queries, the throughput jumped to about 1400 req/s -- possibly due to vm optimizations.

@RobinDaugherty
Copy link

Just a note: rails s in the development environment runs a single-threaded server that has debugging tools enabled. It's not close to production performance or behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment