localhost django dev server vs. postgres slow on mac os?
Anyone notice slowness from a django dev server running on Mac OS and connecting to a remote (postg开发者_运维技巧res) db? It doesn't seem to be the DNS problem referenced elsewhere. We've got a staging instance running the exact same code on the same remote staging box that's hosting the db, and the performance on that instance is very crisp.
Here's the output of the performance middleware running locally:
Total: 19.58 Python: 6.39 DB: 13.19 Queries: 17
And on the staging server:
Total: 0.07 Python: 0.05 DB: 0.02 Queries: 16
Maybe it's postgres client network overhead from connecting to the remote db, or something? I don't mind doing the development on the staging server, but it's nice being able to run things locally too.
Two things:
- The Django dev server is painfully slow. Any external connections will be restricted by it.
- The connection to an external database is limited by your machine's local upstream and downstream capabilities (the bottleneck usually being your internet connection).
Any time you're developing locally and connecting to an external database server, it will be slow. For concurrent Drupal development at work, we source control our sites
folder and use the same database that, though external, never leaves our local network. It's still like molasses in Alaska in January.
I strongly recommend setting up PostgreSQL locally and copying your external database to a local one. It isn't a very time-intensive process and will save you headaches and keep you much more productive.
I faced the same problem when I was using replica of my production database in development environment. The problem turned out to to be in django_session
table which had a size near Gigabytes. Simplest solution was to clear that table as I did not need to use users session data in development.
I used simple command:
TRUNCATE TABLE 'django_session'
also additional info on the issue can be found here: https://dba.stackexchange.com/questions/52733/why-django-session-table-grows-on-postgresql
精彩评论