7, September 2008

Big daily database update - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Big daily database update
« previous next »
Pages: [1] Print

Author Topic: Big daily database update  (Read 566 times)
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« on: Dec 13, 2006, 08:56:39 PM »

Now that I know how to download a file with curl I have to process the file and update my database with the values of the new download. The process will be updating about 5 to 20 thousand records in one table and adding 20 thousand new records to another.

Just processing the 7.5 MB file and displaying the records on screen takes about 1.5 minutes. Does anybody have any idea on what I can expect on how long the updating of the database could take?

A couple of minutes is not too bad, but visitors could see some weird things when they would visit during the update, so my idea is this: if I keep 2 versions of the database, the visitors will see the first while the second is being updated. After the update has finished I can have the site switch over to use the updated database and the update process can run again on the first database. This way, no matter how long the update takes, the visitors will never encounter a database that is in the process of being updated.

Am I taking this too far? Is there a better way to handle this? Should I just do the update and forget about the potential visitor during the update?


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #1 on: Dec 13, 2006, 09:23:50 PM »

You can hold somewhere a variable - or a record in the database - that the update is in process.

With that way you can easilly alert the user that the update is on the run.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #2 on: Dec 13, 2006, 09:30:13 PM »

That is how I was planning on switching between the two databases, by storing the current live database name in a table. I think I'll just do the two database thing, just for the extra geek-factor Wink

btw: congrats on your 5000th post!


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #3 on: Dec 13, 2006, 09:36:26 PM »

Yeah but this is not the correct way to do this.

Renaming the database all the time may cause other problems. For example what happens if the user is coming to the site the time that you are renaming the database? Smiley Plus it will create some overhead to the database and the filesystem.

BTW I've just realized that I have made almost 1/4 of the posts in that forum! I think I have to slow down....

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #4 on: Dec 13, 2006, 09:54:16 PM »

I'm not renaming the database. The plan is to have two databases, DBa and DBb then in the config table the name of the current live database is stored. Whenever a page is requested I first read the config table, where I find DBa or DBb and then read the data from the correct database.


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #5 on: Dec 13, 2006, 09:55:44 PM »

Oh, that's not a bad idea. It will just need some more space, but who cares, right? Smiley

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #6 on: Dec 13, 2006, 09:58:56 PM »

I still have a few GB free on the server so thats not a problem at all.


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Dec 13, 2006, 10:31:40 PM »

I think that is a good idea, just update some field with database name after the update is ready.

Nico updating a lot of files is very time consuming and it could be also a problem of timeouts, try to handle the data a different way like using replace for example.



Last blog : Is your website is down? Know before your visitors do!
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5205
Tags : php database update high availability Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Big daily database update
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep 07, 2008, 06:07:46 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.301
Total Topics: 7.479
Total Members: 3.904
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Brandon

20 Guests, 3 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.