I've been pretty surprised by the performance I've gotten from asycn-mongo sessions. They appear to be pretty darn good.
I created 3 tests.
1: no real session, just set self.session = {} on the request object.
2: sessions built with pymongo
3: sessions with asyncmongo
The asyncmongo sessions outperformed everything, including the first one where no db was involved. pymongo came in last place. It was blocking, I was grabbing the ObjectId on initial saves.
The full round of tests were down with siege, and it wasn't saving the cookies for each request. I used -b -c 200 -t 20s, so 200 concurrent users for 20 seconds. Since it wasn't saving cookies, this was basically testing 200 new users over and over.
Test machine is my Linux laptop, an Alienware M11x R1, which is an intel core 2 duo so limited to 2 cores. This was against a single instance of Tornado with no proxy.
Transactions: 6999 hits
Availability: 100.00 %
Elapsed time: 19.75 secs
Data transferred: 20.90 MB
Response time: 0.56 secs
Transaction rate: 354.38 trans/sec
Throughput: 1.06 MB/sec
Concurrency: 196.87
Successful transactions: 6999
Failed transactions: 0
Longest transaction: 0.82
Shortest transaction: 0.01
I also ran some jmeter tests, but it was my first time using jmeter so I'm still trying to figure it out. The main reason I went to jmeter was to confirm that the sessions were really doing what I thought they were doing. Single user testing worked out, but I wanted to see if there were any issues with lots of users hitting. My test was 200 concurrent users hitting 100 times, using cookies. End result was 200 sessions in MongoDB with the test value being 99 for all of them.
The sample code for the request handler was
class MainHandler(StaticHandler):
""" Front Page """
@tornado.web.asynchronous
@asyncmongosession
def get(self):
if self.session.has_key("test"):
self.session["test"] += 1
else:
self.session["test"] = 0
self.render("index.html", template_vars=self.template_vars,
session=self.session)
* Note the tornado.web.asynchronous isn't necessary for this, noticed I had that on there and tested with it off. Got similar results.
Disclaimer: I'm still working on the sessions library. The main reason I wanted to validate it was working and session data would match expectations in MongoDB was because there's currently an ugly hack in the library where I have to validate the request method has run, because it's finish method is getting called early on at least one request handler I've built. That's one that uses post. Also redirects are still kicking out errors, though working.