Forums

Pages take a long time to load.

Hello,

What would cause a webapp to load really slowly?

Requesting any page takes 3-5 sec to retrieve base HTML page from Django. Loading page content is done via jQuery Ajax call to my webapp's API, and it takes another 20-40 seconds for the server to return the JSON data.

On my personal PC running a local server, retrieving base HTML takes about 90 ms, and retrieving page content from API via jQuery Ajax takes about 100 - 200 ms.

My current setup:

  • Django 1.10 / Python 3.5
  • Free Beginner's Account
  • Site: centennial.pythonanywhere.com
  • API: django rest framework

Any help is appreciated.

Oh- if you are using sqlite, we recommend migrating to MySQL. (disk access on pythonanywhere is significantly slower than local)

I created a new SQL database under the 'Databases' tab, and put this in my django project settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'centennial$<myName>',
        'USER': 'centennial',
        'PASSWORD': '<myPassword>',
        'HOST': 'centennial.mysql.pythonanywhere-services.com',
    }
}

but now reloading the app fails everytime and gives me the message "There was a problem. If this keeps happening , please send us feedback." Might I be missing a step somewhere?

I just recloned the entire repo from GitHub, and everything works now. Pages are super snappy. Looks like migrating to MySQL did the trick.

Great, glad you got it working!

Just one thing to point out, in case anyone else is puzzling over a similar issue -- the ENGINE setting in the settings.py that you quoted above is for SQLite. For MySQL you need to use "django.db.backends.mysql". That may have been the cause of the problem.