Some numbers on AsyncMongo-Sessions

48 views
Skip to first unread message

Joe Bowman

unread,
Oct 10, 2011, 11:12:38 PM10/10/11
to python-...@googlegroups.com
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.



Noah McIlraith

unread,
Oct 10, 2011, 11:18:10 PM10/10/11
to python-...@googlegroups.com
Is this the Tornado sessions from here? https://github.com/milancermak/tornado/tree/

If so, is there anyway for me to use sessions without having to use an outdated fork?

Most (if not all) session libraries I've used operate as a request handler mixin.

Joe Bowman

unread,
Oct 10, 2011, 11:32:06 PM10/10/11
to python-...@googlegroups.com
No, its a new library I am working on using mongodb as the back end. It can be found at the url below but as I said its not complete and I am still finding some bugs in it.

https://github.com/joerussbowman/AsyncMongo-Sessions

asyncmongo is a requirement.

Joe Bowman

unread,
Oct 10, 2011, 11:34:53 PM10/10/11
to python-...@googlegroups.com
Just noticed the readme is out of date. The decorator is @asyncmongosession not @amsession now. Docstrings are more up to date.

Noah McIlraith

unread,
Oct 11, 2011, 12:56:27 AM10/11/11
to python-...@googlegroups.com
Any reason why settings is used instead of tornado.options?

wataka

unread,
Oct 11, 2011, 1:54:33 AM10/11/11
to Tornado Web Server
Here are more benchmarks with another sessions module

http://milancermak.posterous.com/benchmarking-tornados-sessions-0

Phil Whelan

unread,
Oct 11, 2011, 1:41:20 PM10/11/11
to python-...@googlegroups.com
H Joe,

Thanks. I'm keen to use this.

I noticed you've checked in some vim temporary files into git..


Cheers,
Phil

Joe Bowman

unread,
Oct 11, 2011, 2:44:12 PM10/11/11
to python-...@googlegroups.com
ugh.. thanks I'll clear those out next time I get a chance to push changes, and update the .gitignore

I have figured out what was causing the errors on redirects and have a change live on my dev box to address it. Figured it out on my commute in to work and haven't had a chance to get my laptop on a wireless connection to push them to github. Actually, I think this might fix the thing I have called UGLY HACK too. Will need to test that out before I push the changes as well.

Joe Bowman

unread,
Oct 11, 2011, 8:47:33 PM10/11/11
to python-...@googlegroups.com
The latest changes are live. My simple testing has everything working, if you're interested in trying the library now is the time to grab it and test it out.
Reply all
Reply to author
Forward
0 new messages