WebFaction
Community site: login faq

I have a Django application running on a Webfaction server. Every few days i need to update the app's PostgresQL database, which causes several hours of server downtime. What's the best/easiest way for me to avoid this downtime? Use two live databases and somehow switch between them?

I should note that my app is pretty simple in that users only read and do not write to the database.

Thanks.

asked 19 Nov '13, 19:39

araichev
25139
accept rate: 50%

I don't understand how updating your data could result in downtime. What sort of procedure are you using to update your database, and what sort of problem do you see in your site when you update it?

(20 Nov '13, 16:28) seanf

The app is a (mostly) read-only tool designed to analyze and visualize public transport data for different cities. It does a lot of preprocessing of statistical and geospatial data, the results of which get stored in the database.

Sometimes when i update the app, which may or may not involve a schema migration, i need to reprocess that data, a task that can take several hours per city. If the app in online during that time, the user will find a mix of old, new, and null data, a situation i'd like to avoid. Technically, that situation is not downtime; you're right. Maybe i should call it frown-time, because during the reprocessing the app does not serve the user well.

What i'd like to do is update the app and database behind the scenes (again, reprocessing the data can take many hours), go live with it when it's ready, and in the meantime have users interact with the old app and database.

Any suggestions would be much appreciated. I'm a newbie to this.

(21 Nov '13, 14:53) araichev

Based on your answer to my question, I think you'll need to use two databases so that you can update the database behind the scenes, and then cut over to the new data when you're ready.

permanent link

answered 21 Nov '13, 14:59

seanf
12.2k41836
accept rate: 37%

OK. Do i also need two versions of the app, one old and one new, to prevent querying database columns that don't exist in case of a schema migration?

What's the best way to set up this doubling up of databases/apps with Django and Webfaction?

(21 Nov '13, 22:36) araichev

OK. Do i also need two versions of the app, one old and one new, to prevent querying database columns that don't exist in case of a schema migration?

I guess you might, yes. You'd really need to look at your workflow and the types of changes that you're doing to be certain.

What's the best way to set up this doubling up of databases/apps with Django and Webfaction?

Just create the second app via the control panel, create a database for it, deploy your code, and load your data. Once that's done, you can change your site configuration in the control panel to use whichever app you need, as needed.

Sorry I don't have a clear, step-by-step solution for you here.

(22 Nov '13, 14:33) seanf

Thanks, i'll follow your suggestions and see how things go.

(24 Nov '13, 14:56) araichev

OK, i'm working on this now. I set up a second Django project (with a second Git repo) and database on Webfaction. What's a good way to deploy my single development project to each of the two production projects? Use two different settings files and two different wsgi files in the development project and push the appropriate copies?

Also, when you say "you can change your site configuration in the control panel to use whichever app you need, as needed", do you mean go to Domains/Websites > Websites, select the live site, and change the apps listed in Contents?

(02 Dec '13, 20:47) araichev

OK, i'm working on this now. I set up a second Django project (with a second Git repo) and database on Webfaction. What's a good way to deploy my single development project to each of the two production projects? Use two different settings files and two different wsgi files in the development project and push the appropriate copies?

Your settings.py file shouldn't be in the git repository - only a versioned template of it should be. settings.py should be in .gitignore - see this related community post for the rationale. The wsgi file may be similar.

Also, when you say "you can change your site configuration in the control panel to use whichever app you need, as needed", do you mean go to Domains/Websites > Websites, select the live site, and change the apps listed in Contents?

Yes, exactly. This way you can "bounce" between two applications - call them "A" and "B". You currently have "A" live, and make staging updates to "B" - then you update the website record and point it to "B" and within a few minutes "B" will be live. "A" is then the next place to make staging changes, and then when those are done, update the site record back to "A" and start making staging changes on "B".

(03 Dec '13, 19:55) ryans ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×84
×25
×9
×1

question asked: 19 Nov '13, 19:39

question was seen: 3,165 times

last updated: 03 Dec '13, 19:57

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM