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 |
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. answered 21 Nov '13, 14:59 seanf 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
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.
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
Your
Yes, exactly. This way you can "bounce" between two applications - call them "
(03 Dec '13, 19:55)
ryans ♦♦
|
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?
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.