참고 : http://klen.github.io/py-frameworks-bench/



1. python + flask-restplus :  769 rps

  실행 : python run.py


2. python + flask-restplus + gunicorn 8 : 3000 rps

  실행 : gunicorn run:app --workers=8


3. python + flask-restplus + gunicorn 8 + meinheld(http://meinheld.org/) : 24000 rps

  실행 : gunicorn run:app --workers=8 --worker-class=meinheld.gmeinheld.MeinheldWorker


4. go + gin-gonic : 42000 rps

  실행 : ./yamoe


클라이언트 실행

wrk -d20s -t10 -c200 http://localhost:5000/hello



테스트 환경

OS ubuntu on virtualbox

CPU : 8 cores

RAM : 8 GB


python 3.6.3

  Flask==0.11.1

  flask-restplus==0.10.1

  gunicorn==19.7.1

  meinheld==0.6.1


go : go version go1.10.1 linux/amd64


run.py

from flask import Flask

from flask_restplus import Api, Resource


app = Flask(__name__)

api = Api(app)



@api.route('/hello')

class HelloWorld(Resource):

    def get(self):

        return {'hello': 'world'}



if __name__ == '__main__':

    app.run(debug=False)



main.go

package main


import "github.com/gin-gonic/gin"

import "net/http"

import "fmt"

import "runtime"


func main() {


// set use cores

//runtime.GOMAXPROCS(runtime.NumCPU())


// get use cores

fmt.Println(runtime.GOMAXPROCS(0))


router := gin.Default()


router.GET("/hello", func(c *gin.Context) {

c.JSON(http.StatusOK, gin.H{"hello": "world"})

})


router.Run(":5000")

}