Search code examples
pythonwsgicherrypy

CherryPy :: grafting wsgigateway vs adding it to routes dispatcher


I am new to cherrypy, and am moving code from pylons to cherrypy ... I have a WSGIGateway object that i graft onto my cherrypy tree.

cherrypy.tree.graft(mygatewayobj, '/foo/')

I also have a routes dispatcher

dispatcher.connect(route = '/foo', name ='foocontroller', controller = mygatewayobj)

Should I have both connections for the gateway, or is this redundancy a possible reason for my unexpected, error-message-less crashes? Also, if I do need to graft, should it be

/foo/ or /foo?

Solution

  • The performance of routesDispatcher.connect() is very poor compared to cherrypy.graft.tree().

    I did some benchmark test for cherrypy and the results I got was completely unexpected. The RPS drops down to nearly half when you try to use cherrypy's RouteDispatcher mechanism to route the URL. I was able to get around 2500 RPS when using cherrypy.graft.tree() and the RPS drops to around 1100 when using the routes dispatcher.

    My suggestion will be to go with cherrypy.graft.tree() as it allows you to add URL on the fly without doing a config update and is also much faster.