h3.
h3.

Reputation: 11058

django extreme slowness

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 ?

Upvotes: 3

Views: 3626

Answers (4)

Michael Anckaert
Michael Anckaert

Reputation:

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

Upvotes: 0

Bird
Bird

Reputation: 1129

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.

Upvotes: 0

Evgeny
Evgeny

Reputation: 10896

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.

Upvotes: 6

user122299
user122299

Reputation:

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

Upvotes: 0

Related Questions