tags:

views:

339

answers:

4

I have a slowness problem with Django and I can't find the source .. I'm not sure what I'm doing wrong, but at least twice while working on projects Django became really slow.

Requests takes age to complete (~15 seconds) and Validating model when starting the development server is also very slow (12+ seconds on a quad core..)

I've tried many solution found on the net for similar problem, but they don't seem related to me.

The problem doesn't seem to come from Django's development server since the request are also very slow on the production server with apache and mod_python.

Then I thought it might be a DNS issue, but the site loads instantly when served with Apache2.

I tried to strace the development server, but I didn't find anything interesting.

Even commenting all the apps (except django apps) didn't change anything.. models still take age to validate.

I really don't know where I should be looking now ..

Anybody has an idea ?

A: 

Then I thought it might be a DNS issue, but the site loads instantly when served with Apache2.

How are you serving your Django site? I presume you're running mod_python on Apache2?

You may want to start by running an Apache2 locally on you computer (use MAMP or WAMP and install mod_python there) and seeing if it's still slow. Then you can tell whether it's a django/python issue or an Apache/mod_python issue

ראובן
I have the problem on both Apache/mod_python and the django dev server ran locally on Linux.
h3
+5  A: 

I've posted this question on serverfault maybe it will help you.

If you are serving big static files - those will slow down response.

This will be the case in any mode if your mod_python or development server process big static files like images, client scripts, etc.

You want to configure the production server to handle those files directly - i.e. bypassing the modules.

btw, mod_wsgi is nowadays the preferred way to run django in the production environment.

If you have issues with system services or hardware then you might get some clues from log messages.

Evgeny
still doesn't explain why it takes 15 seconds to validate models when the only models installed are Django's ones..And no I don't serve big files with those projects. The biggest image is about 100k and the database isn't much bigger.
h3
sorry, what do you mean by validate models?
Evgeny
$:~/www/project$ python manage.py runserver 127.0.0.1:8000 Validating models...from there it takes between 10 and 15 seconds before i get to this message; Django version 1.1 SVN-11376, using settings 'project.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
h3
damn, how do I format code ?
h3
maybe there are issues with your mysql database or disk? you can run some simple query.
Evgeny
I think you got something here, I've made a quick try with MySQL query browser and the queries are really slow.
h3
OK found it.. I used another server on the same LAN as database server, disabling name resolution in /etc/mysql/my.cf solved the issue;[mysqld]skip-lockingskip-name-resolve
h3
A: 

I've once used remote edit to develop my Django site. The validating process seem to be very slow too. But, everything else is fine not like yours.

It's come from the webserver can't add/change .pyc in that directory.

Bird
A: 

If the validating models takes forever don't search for anything else. On a dual core some of my largest enterprise applications (+30 models) take less then a second to validate.

The problem must lie somewhere with your models but without source code it's hard to tell what the problem is.

Kind regards, Michael

Open Source Consultant

It was a problem with MySQL name resolve..The problem occured when I tried to use a separate mysql server (on the same lan). Disabling name MySQL resolve and using only IPs solved my problem.
h3