Advanced Search

Results 1 to 6 of 6

Thread: Migrating your live database

  1. #1
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Question Migrating your live database

    Hi People,

    I am not too sure if this is the correct section to post this. (Mods pls move this to the appropriate section if not)

    This is a common scenario when you need to move your live website which has a good amount of traffic all the time to a new server. How do you manage to move the db WITHOUT locking the db or putting up a "site under maintenance" page and loosing any data?

    Whats the best approach assuming the db server is on the same web server ?

    Thanks in advance
    Last edited by cancer10; 11-24-2011 at 02:34 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Honestly, it varies entirely by site. You can't avoid all problems because the DNS records for your domain will need to update to reflect the location of the new server and that happens for each individual whenever their ISP/browser updates the info. So you'll have about 2 hours (technically up to 24, I think) for the transition.

    If you're just switching the DB, then all you need to do is shut down the site for as long as it takes you to copy the DB. You'll need to backup the DB, then import it to the new server. Then just switch the connection info for your site. But you'll lose any intermediate posts any way that you do that because they either won't be recorded (if you have the site "down") or they'll be uselessly recorded on the old server after you've backed up the DB (if you leave the site running while moving).

    The best approach will be to turn off the site for a few minutes once everything is really ready to go then move it quickly and turn it back on. You can do that at 3am or whenever there isn't much use to minimize the effect.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Thanks for the reply.

    What do the big giants like facebook/twitter do when they upgrade their site / db? Do they follow the same approach, as I have never seen an "upgrade" banner on their site?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Many big sites do have slight downtime. It might not be while you're awake, though.

    It is theoretically possible to upgrade different users at different times. Remember that big sites like that aren't on one server. They're usually using a cloud server system so that redirecting traffic within that works differently than moving to a new server.

    Another way to make it almost instantaneous would be to automate the process: use a script on the server to switch everything all at the same moment. Of course you'd need to be incredibly careful and so forth, but that way you would not have any problems with timing since it would take less than a second of downtime to make it work (if everything went right).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Alright. Thanks for all ur replies.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Now that I'm seeing this thread again, there's another important point:
    It's not necessarily that everything takes a long time to setup. It's usually just a moment or two (probably less than a minute) to change a line or two of code and upload all of your new files.

    Then the site works. But the reason sites usually have 15 minutes to several hours of downtime is so you can check that everything is working-- downtime is better than debugging a live site.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •