django/python performance vs play/java

2,919 views
Skip to first unread message

drakkan

unread,
Jul 5, 2011, 3:54:52 PM7/5/11
to Django users
Hi,

I did a small test app that basically render a web page and do 3
queries to the database (these queries are needed to fetch some data
displayed on the web page). I deployed this app with nginx+uswgi

here is the relevant nginx conf:

location / {
uwsgi_pass 127.0.0.1:49152;
include uwsgi_params;
}

I configured nginx to serve the static files too:

location /media {
root <root path for media>;
autoindex on;
}

I launch uswgi as follow:

uwsgi --chdir=<path> --
module='django.core.handlers.wsgi:WSGIHandler()' --env
DJANGO_SETTINGS_MODULE=myapp.settings --master --pidfile=/tmp/project-
master.pid --socket=127.0.0.1:49152 --max-requests=5000 --process=5

then I benchmarked the app with ab:

ab -n 1000 -c 4 http://127.0.0.1:80/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software: nginx
Server Hostname: 127.0.0.1
Server Port: 80

Document Path: /
Document Length: 24293 bytes

Concurrency Level: 4
Time taken for tests: 28.914 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 24423000 bytes
HTML transferred: 24293000 bytes
Requests per second: 34.59 [#/sec] (mean)
Time per request: 115.654 [ms] (mean)
Time per request: 28.914 [ms] (mean, across all concurrent
requests)
Transfer rate: 824.89 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 4
Processing: 46 115 42.6 110 636
Waiting: 46 115 42.5 109 636
Total: 46 116 42.6 110 636

Percentage of the requests served within a certain time (ms)
50% 110
66% 121
75% 131
80% 139
90% 161
95% 177
98% 203
99% 220
100% 636 (longest request)

now I implemented the same app using playframework, a java based
framework and benchmarked with ab again:


ab -n 1000 -c 4 http://127.0.0.1:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software: Play!
Server Hostname: 127.0.0.1
Server Port: 9000

Document Path: /
Document Length: 19614 bytes

Concurrency Level: 4
Time taken for tests: 4.436 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 19961000 bytes
HTML transferred: 19614000 bytes
Requests per second: 225.44 [#/sec] (mean)
Time per request: 17.743 [ms] (mean)
Time per request: 4.436 [ms] (mean, across all concurrent
requests)
Transfer rate: 4394.59 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 7 18 6.6 16 47
Waiting: 6 17 6.6 16 47
Total: 7 18 6.6 16 47

Percentage of the requests served within a certain time (ms)
50% 16
66% 19
75% 22
80% 23
90% 27
95% 30
98% 34
99% 38
100% 47 (longest request)


so play is outperforming django! obviously django is not in debug mode
ecc..., is there something wrong in my test setup (I already tried to
adjust the uwsgi launch line I tryed more process or 1 process with
threads ecc with no relevant improvement) or django/python is simply
much slower than java? I tried to run play behind nginx proxy too: the
results are pratically identical. Note the response time too: the
slowest play response is 47 ms, the fastest django one is 110 ms,

any suggestion to improve performance is appreciated,

thanks in advance,
drakkan

bruno desthuilliers

unread,
Jul 5, 2011, 4:57:46 PM7/5/11
to Django users
On 5 juil, 21:54, drakkan <drakkan1...@gmail.com> wrote:

(snip)

> or django/python is simply much slower than java?

According to most benchmarks, Python (that is: current canonical
implementation of...) is indeed way "slower" than Java (idem), that's
a fact. FWIW, according to the same benchmarks, Java is slower than C+
+, which is slower than C, which can be slower than your-platform-
highly-optimized-assembly-code - but you need to be very good at hand-
optimizing assembly code to beat any decent C compiler. You may
notice a pattern here (if you don't, try implementing a simple blog in
assembly, then port it to a different platform, and come back when
you're done <g>).

To make a long story short: if you're looking for raw execution speed,
forget about Java and go for C - and let us know when you'll have a
working prototype.


Maksymus007

unread,
Jul 5, 2011, 4:58:51 PM7/5/11
to django...@googlegroups.com
Of course Java IS faster by a few factors then Python. I switched recently to Play development from django and I also noticed different. Moreover Play uses many mature tools, like JPA/Hibernate, ehcache etc which are called industrial standards.
One more thing - Play! uses its own build-in http server, and keep one connection to a database alive at all the time, Django run as FCGI or mod_wsgi manages this a bit different.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Xavier Ordoquy

unread,
Jul 5, 2011, 5:46:00 PM7/5/11
to django...@googlegroups.com
Hi,

Install Django debug toolbar and have a look at what's wrong with your application.
My numbers are very different from yours.

I just ran some tests and I am around 350 req/s with 4 sql queries.
I'm a on dual core (4 virtual cores), using gunicorn/mysql with debug turned off, 4 workers processes

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software: gunicorn/0.12.2
Server Hostname: 127.0.0.1
Server Port: 8088

Document Path: /project/1/
Document Length: 4327 bytes

Concurrency Level: 4
Time taken for tests: 14.041 seconds
Complete requests: 5000


Failed requests: 0
Write errors: 0

Total transferred: 22405000 bytes
HTML transferred: 21635000 bytes
Requests per second: 356.10 [#/sec] (mean)
Time per request: 11.233 [ms] (mean)
Time per request: 2.808 [ms] (mean, across all concurrent requests)
Transfer rate: 1558.29 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1

Processing: 10 11 3.5 11 73
Waiting: 10 11 3.5 10 73
Total: 10 11 3.5 11 73

Percentage of the requests served within a certain time (ms)
50% 11

66% 11
75% 11
80% 11
90% 11
95% 12
98% 14
99% 23
100% 73 (longest request)

Jonas Geiregat

unread,
Jul 5, 2011, 7:07:15 PM7/5/11
to django...@googlegroups.com

We all know python is slower in raw execution speed than it's brother Java but I can't imagine it to be _that_ slow.


Maybe there's something wrong with the queries you perform. Django's ORM is know for it's 'hidden execution' of queries. Some more insight in your querying code might be useful.

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>


Jonas Geiregat
jo...@geiregat.org

drakkan

unread,
Jul 5, 2011, 7:31:45 PM7/5/11
to Django users
Hi,

thanks for your comments, I installed django-debug toolbar and I can
confirm I'm doing similar queries from both django and play. The query
I do with hibernate in play should be slower since I'm doing a left
outer join while django do an inner join, since the field on which I
join cannot be null.

I tryed gunicorn but it gives similar performance to uwsgi, I'm
testing on my latptop (1 core). Maybe there is something wrong in my
template but it is basically a base.html and then index.html that
extends base.html, additinally I have some "include <other.html>"
where other.html is a small fragment of code

On 6 Lug, 01:07, Jonas Geiregat <jo...@geiregat.org> wrote:
> We all know python is slower in raw execution speed than it's brother Java but I can't imagine it to be _that_ slow.
>
> Maybe there's something wrong with the queries you perform. Django's ORM is know for it's 'hidden execution' of queries. Some more insight in your querying code might be useful.
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I did a small test app that basically render a web page and do 3
> > queries to the database (these queries are needed to fetch some data
> > displayed on the web page). I deployed this app with nginx+uswgi
>
> > here is the relevant nginx conf:
>
> > location / {
> >            uwsgi_pass 127.0.0.1:49152;
> >            include uwsgi_params;
> >    }
>
> > I configured nginx to serve the static files too:
>
> > location /media {
> >            root <root path for media>;
> >            autoindex on;
> >    }
>
> > I launch uswgi as follow:
>
> > uwsgi --chdir=<path> --
> > module='django.core.handlers.wsgi:WSGIHandler()' --env
> > DJANGO_SETTINGS_MODULE=myapp.settings --master --pidfile=/tmp/project-
> > master.pid --socket=127.0.0.1:49152 --max-requests=5000 --process=5
>
> > then I benchmarked the app with ab:
>
> > ab -n 1000 -c 4http://127.0.0.1:80/
> > This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> > Copyright 1996 Adam Twiss, Zeus Technology Ltd,http://www.zeustech.net/
> > Licensed to The Apache Software Foundation,http://www.apache.org/
> > ab -n 1000 -c 4http://127.0.0.1:9000/
> > This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> > Copyright 1996 Adam Twiss, Zeus Technology Ltd,http://www.zeustech.net/
> > Licensed to The Apache Software Foundation,http://www.apache.org/

Xavier Ordoquy

unread,
Jul 5, 2011, 7:56:58 PM7/5/11
to django...@googlegroups.com
Hi,

Is there anyway you can upload the project to bitbucket or github ?

Regards,
Xavier.

Kenneth Gonsalves

unread,
Jul 5, 2011, 10:52:22 PM7/5/11
to django...@googlegroups.com
On Tue, 2011-07-05 at 13:57 -0700, bruno desthuilliers wrote:
> To make a long story short: if you're looking for raw execution speed,
> forget about Java and go for C - and let us know when you'll have a
> working prototype.

or like the facebook guys write C in php.
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

drakkan

unread,
Jul 6, 2011, 4:35:07 AM7/6/11
to Django users


On 5 Lug, 22:57, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
Bruno, I'm talking about an high level framework such as play (http://
www.playframework.org/). Develop an application with play is as simple
as a django one, until now I used django and I like python more than
java and I want to understand if I'm doing something wrong or if is
the framework/programming language that is performing so bad. I sent
my code to Xavier, I noticed now I sent a private email, if someone
other would like to see my test code I can resend the link to download
it, however is a really simple app that make two db queries and render
a template I cannot see anything wrong in it

thanks
drakkan

bruno desthuilliers

unread,
Jul 6, 2011, 5:44:21 AM7/6/11
to Django users
On Jul 6, 10:35 am, drakkan <drakkan1...@gmail.com> wrote:
> Bruno, I'm talking about an high level framework such as play (http://www.playframework.org/).
> Develop an application with play is as simple as a django one,

The framework might be fine (I'll give the doc a read), but the
language still sucks ;)

But anyway - I have to admit I didn't pay attention to the numbers and
mostly took your post as the usual "Java is faster than Python" troll,
sorry. Shouldn't post when I'm tired after a hard day :-/

I'll run a couple apache-bench on some of my own Django projects to
see if there something wrong with your results (at least the django
part).

Thomas Guettler

unread,
Jul 6, 2011, 6:46:22 AM7/6/11
to django...@googlegroups.com
Hi,

I would choose the framework, that you like. You can optimize later. And
this would be the same for all frameworks: You need a good cache strategy.

Are you expecting several hundred requests per minute?

I guess there is something wrong with your benchmark. I don't think django/python
is much slower.

Thomas

On 06.07.2011 01:31, drakkan wrote:
> Hi,
>
> thanks for your comments, I installed django-debug toolbar and I can
> confirm I'm doing similar queries from both django and play. The query
> I do with hibernate in play should be slower since I'm doing a left
> outer join while django do an inner join, since the field on which I
> join cannot be null.

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

drakkan

unread,
Jul 6, 2011, 7:31:50 AM7/6/11
to Django users


On 6 Lug, 12:46, Thomas Guettler <h...@tbz-pariv.de> wrote:
> Hi,
>
> I would choose the framework, that you like. You can optimize later. And
> this would be the same for all frameworks: You need a good cache strategy.
>
> Are you expecting several hundred requests per minute?
>
> I guess there is something wrong with your benchmark. I don't think django/python
> is much slower.

I need to develop a web app that need to run on low end hw (probably
intel atom, not decided yet). I love django/python and I already used
it in several web apps and I would like to use it in this project too.
However it seems that the performance difference between play/java and
django/python grow when the hw resource decrease. For example on a 8
core server play is "only" 2-2.5x faster that django (no one will
notice this difference if you don't have a very high traffic website),
on an intel atom play is 15x faster than django and this is
noticeable.

I know about caching and play support memcached too, I guess if I
enable memcached on both framework the results doesn't change much,

thanks for your suggestions

>
>   Thomas
>
> On 06.07.2011 01:31, drakkan wrote:
>
> > Hi,
>
> > thanks for your comments, I installed django-debug toolbar and I can
> > confirm I'm doing similar queries from both django and play. The query
> > I do with hibernate in play should be slower since I'm doing a left
> > outer join while django do an inner join, since the field on which I
> > join cannot be null.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/

Uros Trebec

unread,
Jul 6, 2011, 7:43:58 AM7/6/11
to Django users
Hi,

Have you tried any kind of DB connection pooling with Django?

I find Jacob's Deployment Workshop [0] to be a treasure chest of tips
and tricks for Django deployment.
Also take a look at the code/config he uses [1].

[0] http://ontwik.com/python/django-deployment-workshop-by-jacob-kaplan-moss/
[1] https://github.com/jacobian/django-deployment-workshop/

Best of luck,
Uros

akaariai

unread,
Jul 6, 2011, 8:03:25 AM7/6/11
to Django users
On Jul 5, 10:54 pm, drakkan <drakkan1...@gmail.com> wrote:
> so play is outperforming django! obviously django is not in debug mode
> ecc..., is there something wrong in my test setup (I already tried to
> adjust the uwsgi launch line I tryed more process or 1 process with
> threads ecc with no relevant improvement) or django/python is simply
> much slower than java? I tried to run play behind nginx proxy too: the
> results are pratically identical. Note the response time too: the
> slowest play response is 47 ms, the fastest django one is 110 ms,
>
> any suggestion to improve performance is appreciated,

Which database do you use? If you happen to use PostgreSQL, then
connection creation can be a major source of your performance
problems. In that case, try using pgbouncer or PgPoolII. Play would
most likely use a connection pool by default, while Django relies on
external connection pooling.

I have an application which does a lot more than 3 queries. With
connection pooling enabled:
Requests per second: 90.69 [#/sec] (mean)

Without connection pooling:
Requests per second: 32.98 [#/sec] (mean)

- Anssi



- Anssi

Shamail Tayyab

unread,
Jul 6, 2011, 8:36:59 AM7/6/11
to Django users
Pretty interesting..

So, I've an idea here..

Why don't you log this output in some file.. (and share)

def page (request):
start = time.time()
# function definition
elapsed = (time.time() - start)
return HttpResponse()

This way, see if its the framework that's taking the time, or its the
processing/DB connection (put the same before and after a DB call)

Tx

On Jul 6, 12:54 am, drakkan <drakkan1...@gmail.com> wrote:
> Hi,
>
> I did a small test app that basically render a web page and do 3
> queries to the database (these queries are needed to fetch some data
> displayed on the web page). I deployed this app with nginx+uswgi
>
> here is the relevant nginx conf:
>
> location / {
>                 uwsgi_pass 127.0.0.1:49152;
>                 include uwsgi_params;
>         }
>
> I configured nginx to serve the static files too:
>
> location /media {
>                 root <root path for media>;
>                 autoindex on;
>         }
>
> I launch uswgi as follow:
>
> uwsgi --chdir=<path> --
> module='django.core.handlers.wsgi:WSGIHandler()' --env
> DJANGO_SETTINGS_MODULE=myapp.settings --master --pidfile=/tmp/project-
> master.pid --socket=127.0.0.1:49152 --max-requests=5000 --process=5
>
> then I benchmarked the app with ab:
>
> ab -n 1000 -c 4http://127.0.0.1:80/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd,http://www.zeustech.net/
> Licensed to The Apache Software Foundation,http://www.apache.org/
> ab -n 1000 -c 4http://127.0.0.1:9000/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd,http://www.zeustech.net/
> Licensed to The Apache Software Foundation,http://www.apache.org/

drakkan

unread,
Jul 6, 2011, 9:33:10 AM7/6/11
to Django users
using pgpool I get a 2,5x performance improvement thanks! I'll try on
intel atom again to see if there I have more improvements

>  - Anssi
>
>  - Anssi

akaariai

unread,
Jul 6, 2011, 9:51:44 AM7/6/11
to Django users
On Jul 6, 4:33 pm, drakkan <drakkan1...@gmail.com> wrote:
> using pgpool I get a 2,5x performance improvement thanks! I'll try on
> intel atom again to see if there I have more improvements

The best way to check where your performance problems come from is
using profiling.

In my experience, the most likely things to cause you performance
problems in Django are database queries and template rendering. If
template rendering is a problem for you, try Jinja2. Depending on the
complexness of your template this can give you up to 10x performance
gains. Jinja2 template language is almost like Django's. There are
minor differences which can be annoying if you use both template
engines at the same time.

- Anssi

Björn Lindqvist

unread,
Jul 6, 2011, 9:57:55 AM7/6/11
to django...@googlegroups.com
2011/7/6 drakkan <drakk...@gmail.com>:

> Bruno, I'm talking about an high level framework such as play (http://
> www.playframework.org/). Develop an application with play is as simple
> as a django one, until now I used django and I like python more than
> java and I want to understand if I'm doing something wrong or if is
> the framework/programming language that is performing so bad. I sent
> my code to Xavier, I noticed now I sent a private email, if someone
> other would like to see my test code I can resend the link to download
> it, however is a really simple app that make two db queries and render
> a template I cannot see anything wrong in it

Please send the link. Just because you can't see anything wrong with
the code, doesn't mean there isn't anything wrong with it. Likely, you
are doing something wrong which eats up the performance but without
seeing the source, one can only speculate on what that may be. Your
"simple" app aren't as simple as you think it is.

There are dozens of similar threads created on the python related
mailing lists each year. In some cases python is slower than language
X, in other cases it is faster (because much of the core is
implemented in C, for example) other times it does not matter because
the task is IO bound anyway.


--
mvh/best regards Björn Lindqvist
http://www.footballexperts.net/

drakkan

unread,
Jul 6, 2011, 11:44:17 AM7/6/11
to Django users
You can download the code here:

http://77.43.75.110/temp/cinquestelle.tar.gz

you need sorl as dependencies too:

http://pypi.python.org/pypi/sorl-thumbnail/3.2.5


On 6 Lug, 15:57, Björn Lindqvist <bjou...@gmail.com> wrote:
> 2011/7/6 drakkan <drakkan1...@gmail.com>:

akaariai

unread,
Jul 7, 2011, 11:16:35 AM7/7/11
to Django users
On Jul 6, 6:44 pm, drakkan <drakkan1...@gmail.com> wrote:
> You can download the code here:
>
> http://77.43.75.110/temp/cinquestelle.tar.gz
>
> you need sorl as dependencies too:
>
> http://pypi.python.org/pypi/sorl-thumbnail/3.2.5
>

I took a quick look of the source. I think the limiting factor for you
is template rendering speed. If I read the code correctly, you are
generating thumbnails for every request. That could be the limiting
factor, too. Activating cached template loading could help you a
little.

- Anssi

Venkatraman S

unread,
Jul 7, 2011, 12:43:21 PM7/7/11
to django...@googlegroups.com

On Wed, Jul 6, 2011 at 7:21 PM, akaariai <akaa...@gmail.com> wrote:

The best way to check where your performance problems come from is
using profiling.

In my experience, the most likely things to cause you performance
problems in Django are database queries and template rendering. If
template rendering is a problem for you, try Jinja2. Depending on the
complexness of your template this can give you up to 10x performance
gains. Jinja2 template language is almost like Django's. There are
minor differences which can be annoying if you use both template
engines at the same time.


How do you compare template rendering performances?
Also, is there any good free loadtesting tool which can be used in django-devserver?

Jason

unread,
Jul 7, 2011, 1:55:06 PM7/7/11
to Django users
Good catch.

Drakkan, I suggest trying out this ProfilingPanel for the Django Debug
Toolbar (very easy to setup).

http://backslashn.com/post/505601626/profiling-execution-with-the-django-debug-toolbar

I'd be very curious to know what you find.

Jason

unread,
Jul 7, 2011, 3:26:36 PM7/7/11
to Django users
I recommend you give this a shot:

http://backslashn.com/post/505601626/profiling-execution-with-the-django-debug-toolbar

It might give some clues and is VERY fast to setup.

Thomas Guettler

unread,
Jul 8, 2011, 8:44:58 AM7/8/11
to django...@googlegroups.com, drakk...@gmail.com

On 06.07.2011 15:33, drakkan wrote:
> On 6 Lug, 14:03, akaariai <akaar...@gmail.com> wrote:
>> On Jul 5, 10:54 pm, drakkan <drakkan1...@gmail.com> wrote:

...

> using pgpool I get a 2,5x performance improvement thanks! I'll try on
> intel atom again to see if there I have more improvements

Hi,

I am interessted in the result. Please post them to the list.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/

drakkan

unread,
Jul 8, 2011, 9:03:19 AM7/8/11
to Django users


On 8 Lug, 14:44, Thomas Guettler <h...@tbz-pariv.de> wrote:
> On 06.07.2011 15:33, drakkan wrote:> On 6 Lug, 14:03, akaariai <akaar...@gmail.com> wrote:
> >> On Jul 5, 10:54 pm, drakkan <drakkan1...@gmail.com> wrote:
>
> ...
>
> > using pgpool I get a 2,5x performance improvement thanks! I'll try on
> > intel atom again to see if there I have more improvements
>
> Hi,
>
> I am interessted in the result. Please post them to the list.

test from my laptop

django+uwsgi+pgpool2:

Requests per second: 71.40 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
50% 56
66% 64
75% 70
80% 73
90% 81
95% 86
98% 93
99% 98
100% 134 (longest request)


without pgpool2:

Requests per second: 35.87 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
50% 107
66% 119
75% 128
80% 135
90% 154
95% 171
98% 196
99% 213
100% 306 (longest request)


play 1.2.2 default options and default template engine (no japid)

Requests per second: 186.12 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
50% 20
66% 23
75% 26
80% 27
90% 32
95% 35
98% 42
99% 47
100% 68 (longest request)

the db is postgres 8.4

I have no time to try jinja2 now, I guess it should speed up django a
bit,

drakkan


>
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/

akaariai

unread,
Jul 8, 2011, 10:33:25 AM7/8/11
to Django users
On Jul 8, 4:03 pm, drakkan <drakkan1...@gmail.com> wrote:
> I have no time to try jinja2 now, I guess it should speed up django a
> bit

Trying jinja2 in your project is hard - you are using some template
tags, and you would need to port them to jinja2. Then you would need
to rewrite your templates so that they work under jinja2. This would
take some time for sure.

What you could do is check out the profiler suggested in this thread.
Jinja2 is generally somewhere from 5x to 10x faster that Django
templates. So if you can see that half of your time is spent in
template rendering, then you could probably almost double the speed of
your application using Jinja2. If you don't want to do that, you can
check how fast your code is without any template rendering: just
return HttpResponse("") from your view. But remember to evaluate your
queries, querysets are evaluated only on access. This will give you
some clue how much Jinja2 would benefit you.

- Anssi

Venkatraman S

unread,
Jul 8, 2011, 10:37:36 AM7/8/11
to django...@googlegroups.com


On Fri, Jul 8, 2011 at 8:03 PM, akaariai <akaa...@gmail.com> wrote:

Trying jinja2 in your project is hard - you are using some template
tags, and you would need to port them to jinja2. Then you would need
to rewrite your templates so that they work under jinja2. This would
take some time for sure.

What you could do is check out the profiler suggested in this thread.
Jinja2 is generally somewhere from 5x to 10x faster that Django
templates. So if you can see that half of your time is spent in
template rendering, then you could probably almost double the speed of
your application using Jinja2. If you don't want to do that, you can
check how fast your code is without any template rendering: just
return HttpResponse("") from your view. But remember to evaluate your
queries, querysets are evaluated only on access. This will give you
some clue how much Jinja2 would benefit you.

Actually, i was just wondering more about this. I recently tweaked my app and cleaned up
all the expensive queries etc; and wanted to know the issues with jinja2.

I am starting a different thread on this; so that its easy to track.

-V
Reply all
Reply to author
Forward
0 new messages