Genshi vs. Mako

As I stated previously how much I like Genshi…I’ve come to realize that the performance of Genshi under high traffic is very bad. It could be the complexity of the templates that I am using, but I’m only using a few py:match‘s and they are using once=”true”.

I decided to benchmark Mako against Genshi for my site. Both templates are identical minus the syntactical differences of Genshi vs. Mako. I used the Apache HTTP server benchmark to test the site. The site uses Pylons, SCGI, and Lighttpd.

NOTE: I did not use any caching for these tests.

Mako URL: http://blackberrytracker.com/
Genshi URL: http://blackberrytracker.com/index.genshi

Mako

Average Requests Per Second: 54.65

Genshi

Average Requests Per Second: 1.69

As you can see from the graph below, not only is the response time for Genshi much higher, but the amount of requests fulfilled per second was about 50 times less than with Mako.

I also tested the template generation time for both Genshi and Mako. I used the render() method in Pylons for testing.

Mako: 3 ms(average)
Genshi: 125 ms(average)

For the templates that I am using on my site it looks like using Mako is 40 times faster than Genshi.

Benchmark Graph

I love Genshi but when it comes down to a high performance, high traffic site, it looks like Mako is a much better choice. I guess the tradeoff is using an XML vs. text based template language. I think I’ll be using Mako from now on, until Genshi becomes more mature and hopefully more optimized. Sorry Genshi!

Posted Sunday, January 27th, 2008 under Technology.

Similar Posts

  • No Related Post
  • Diez B. Roggisch

    Can you show me the templates you used? I’m just running tests myself – a very simple page in either mako or genshi, serving mako- and genshi-based widgets (I’m under TurboGears).

    But I don’t get even close in my results – it’s even the other way round: genshi is much faster.

  • chrismoos

    Are you using includes in genshi and mako?

  • http://www.mocksoul.ru Vadim Fint

    Diez B. Roggisch, genshi just CANT be faster than pure python code (which is generated by mako), until you turn off mako generated code caching (where is no reason for doing that).

    Anyway, genshi is not slow for simple templates, but when system becomes very complicated – it is VERY slow (comparing even to django template system, which is slower than mako).

    Actually, python does not (yet) have best-from-the-best templating solution. In definitily should NOT be html->python converter (like mako). It MUST be xml based (like xslt or genshi). Thus, it must be in C to be fast ;) .

  • http://zagalski.pl Zagal

    Mako is fantastic. I didn’t know that it beats genshi so much :P .
    Regards from Poland.

  • http://www.biztel.com.au Bob Singleton

    Hi Chris,
    I decided to do some tests with securityspace.com:
    1. kid with tg1 on a 32bit platform:
    Page: http://www.biztel.com.au/static/notes.
    retrieval time 0.94 secs
    size 4.7K

    2. mako with tg2.1 on a 64 bit opteron platform
    Page: http://www.biztel.com.au:8080.
    retrieval time 0.93 secs
    size 6.5K

    3. genshi with tg2.1 on a 64 bit opteron platform
    Page: http://www.biztel.com.au:8081/environ
    retrieval time 0.89 secs
    size 8.8K

    these results seem to indicate a marginal performance difference?

    your thoughts?

    regards Bob