Tuesday, February 16, 2010

symfony session storage with using MongoDB

MongoDB is  an open source, scalable, high-performance, schema-free, document-oriented database written in the C++ programming language.((via: wikipedia))

symfony has the file session storage class, PDO session storage class but has no MongoDB session storage class.

So I wrote the symfony session storage class with using MongoDB.
You can use below.

As a matter of course I don't think MongoDB is the best solution for session storage but it's faster than MySQL session storage.


If you use sfMongoSessionStorage class, you configure the factories.yml.

     class: sfMongoSessionStorage
       host: localhost          #hostname
       port: 27017              #port number
       db_name: symfony         #DB name
       collection_name: session #collection name

bench mark results

This is the bench mark results on my local machine.
$ ab -n 5000 -c 100 http://localhost/index.php

MySQL   => Requests per second:    10.86 [#/sec] (mean)
MongoDB => Requests per second:    16.61 [#/sec] (mean)

Default => Requests per second:    17.58 [#/sec] (mean)
MongoDB session storage is much faster than MySQL one.

1 comment:

  1. Heya,

    i donwloaded the sfMongoSessionStorage Lib today too, did you run your benchmark after you've added an Index on the sess_id Column?

    just curious :)