Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Big Board Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Geographic Redundancy / Multi-Master for VB - What's going to bite me? Details »»
Geographic Redundancy / Multi-Master for VB - What's going to bite me?
Version: , by neatbrian neatbrian is offline
Developer Last Online: Oct 2018 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 01-30-2008 Last Update: Never Installs: 0
 
No support by the author.

Greetings,

I've set up a geographically redundant VB with the following configuration

- One server in a data-center on the east coast running VB
- A second server server in a data-center on the west coast running VB
  • Each server runs its own copy of VB and its own copy of MySQL.
  • Database replication is done in real time using MySQL's multi-master circular replication (updates to one database are reflected in real time on the other end). This works amazingly well. Security is ensured through a back-end encrypted SSH tunnel linking the two MySQL instances together.
  • Site/file replication is done with rsync every 60 seconds (again, using the SSH tunnel for encryption).
  • Load balancing is done with a simple round-robin DNS setup. Primary DNS is on one side, secondary DNS on the other. This gives me a 50/50 load between the two servers without needing to rely on a single-point-of-failure load balancer.
  • Failover is accomplished by using a short TTL in the DNS (60 seconds) -- if one side disappears, the other side alters the zone file automatically to remove the failed site. When the other side comes back up, the other node is added back into the DNS rotation. This ensures the maximum "Downtime" for a user will be 60 seconds (the TTL value) if their server disappears.

So far, it's working out really well. We've really been able to handle some heavy loads with absolute EASE... but there are a couple of issues I'm worried about:

1) Temp-file cleanup becomes a bit of a nightmare since neither server can really know for sure that it's safe to wipe out a temp file that might have come from the other side.

2) Cron-based events... is it safe to run these on BOTH sides?? What will happen??

3) What about things like emails for thread-subscriptions... So far I've not heard any complaints, but are both servers going to attempt to send them out? I'm operating under the assumption that the server who accepted the post to the "subscribed thread" is responsible for launching this event... so I should be fine..

4) Anything else I'm too green to understand about VB... What do I not know about VB that could bite me later in this configuration?

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 01-30-2008, 08:21 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent idea!

*subscribes*
Reply With Quote
  #3  
Old 01-31-2008, 07:07 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have no experience with this kind of setup, but an interesting idea.

1) Is it wise to synchronize temp files between the servers?

2) If O.S. cronjobs: Yes you will need to ensure yourself that each job only runs once.
If vB Scheduled Tasks: This is based on status values stored in the database. If the database is synchronised then this should not be a problem.
Reply With Quote
  #4  
Old 01-31-2008, 01:47 PM
DigitalCrowd's Avatar
DigitalCrowd DigitalCrowd is offline
 
Join Date: Nov 2001
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have setup this configuration before, one with a datacenter in Europe, another in the United States. It does work really well with VB. I don't current run this setup, as I don't have a box in Europe anymore, but I did get comments from those geographically closer to that server that it loaded much faster for them because the latency was significantly less.

The best part about this setup is literally you could shut off one server for 48 hours and turn it back on and everything syncs back up, no promoting a slave to a master and then trying to switch that back at a later date.

I did this a year or two ago, so I may have forgot some of the small details or problems I had with it or ran into. I did use Nettica for DNS failover, they provide a low-cost (not as low-cost as your own solution) that provides an "outside" monitoring of your servers and changes DNS on the fly.

I would also redirect traffic that was located in the EU to the EU server and even had a latency test for registered users to pick which server was best for them automatically.

Quote:
Cron-based events... is it safe to run these on BOTH sides?? What will happen??
You are safe with VB scheduled tasks, but if you have any CRON scripts that run against your site or database to fire off events, then you'd only want to initiate that on one server, and then if the other goes down, all the other server to perform that task. You can also take it a bit further and offset the cron time by 5 minutes or so and allow the other server which is not primary for cron to check to see if those crons had been run, and if not, run them itself.

Quote:
What about things like emails for thread-subscriptions... So far I've not heard any complaints, but are both servers going to attempt to send them out? I'm operating under the assumption that the server who accepted the post to the "subscribed thread" is responsible for launching this event... so I should be fine..
Yea, this would be a VB initiated cron/scheduled task, and you'd be fine.

Quote:
Anything else I'm too green to understand about VB... What do I not know about VB that could bite me later in this configuration?
You pretty much have to store attachments and avatars/pics in the database in this setup. You can get around it, but you lose the "it just works" part of this configuration.

I remember have some issues with the configuration, it seemed that the two masters would eventually get out of sync for whatever replication error. So, sometimes you'd have different sets of data, someone would post and then they'd end up at the other IP from a TTL expiration and wonder where their post went. Some of the issues I had I don't think would exist if I didn't have a huge latency between the masters, some 170ms I remember, opposed to what you probably have between coasts in the USA. The key was to run a script that would monitor your masters and make sure they where in sync and if not to try and correct the issue automatically, else notify you of the fact and either consider one of the boxes "failed" and drop it out of DNS or whatever is best for you. The good news is, once the replication kicks back in, it will all sync up.

Make sure both boxes have IDENTICAL clocks and sync to the same time server on a very frequent basis. The more the two boxes are out of the sync, the more often you need to sync them. I remember having issues where someone would post a response to someone else, but it would show up before the person who asked, because of some clock issues.

It was fun, I enjoyed setting it up. I was asked recently how I had that setup and if I'd do it again, and I said that while it worked and I would recommend it for the right situation, it was more prone to glitches than a setup where it was a master slave configuration. You can accomplish the same thing by having a slave mysql on the second server and its own caching server. While you still have added latency between the servers (because of the geo-distance) so anyone hitting that secondary box could have slightly slower access, it does provide you with all your goals and if the master server goes down, promote the slave master and keep going forward. It's not as easy to get all back up and going in the original config as was master-master, but the frequency of that happening should be few and far between.

Last thing I can think of, is when you do VB upgrades or anything that uses the DB, you can't just shut down one server, perform the upgrade, bring it up and then do it all over again on the other. You still have to take down the site, update the php files on BOTH servers, and run upgrade.php, then bring it back up. Because they both share the same database, if you turn one off, the other goes off.

As I said earlier, I am sure there are things I'm forgetting... but nice to see someone else do this. I don't feel like such a rebel anymore.

What people considering this setup need to remember is to ask your question WHY do you need a geo-distant solution? If your motivation is strictly a failover in the event that the primary datacenter has an outage, goes out of business, gets hit by a tornado, or covered in volcanic ash, then your best running a "hot stand-by" that doesn't need to have all the meat and potatoes of your primary server, but could take the load, even if temporary until you could figure out how long the primary server will be out and what you need to bring up another box or if your holding steady on the backup.

For those looking to setup a server in say Europe and one in the United States and the primary motivation is to provide a faster site to those in their respective home locations this can be accomplished by loading a up server with all your attachment, images and "bulk" of your web page to a server closer to them, without actually running VB on it. The "text" can still come from your primary server or you could setup a "slave" type setup so that it could be a hot fail-over if needed and don't load balance between the boxes, just send traffic that is closer to the other secondary box when it seems appropriate for those users.

Everyone SHOULD keep a copy of their database and files at some other location outside of the datacenter their server is in. That is just a given and most people don't do that. They might backup to another drive in their server or to a "backup space" provided by the datacenter.

Scott
Reply With Quote
  #5  
Old 02-01-2008, 11:49 PM
FlyBoy73 FlyBoy73 is offline
 
Join Date: Jan 2002
Location: Texas, USA
Posts: 297
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent information. Thanks!
Reply With Quote
  #6  
Old 02-02-2008, 08:08 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would love to read more experiences with this setup.
How about bandwidth costs? With the database being sent to the other server frequently, this seems like a costly adventure.
Reply With Quote
  #7  
Old 02-03-2008, 10:23 AM
DigitalCrowd's Avatar
DigitalCrowd DigitalCrowd is offline
 
Join Date: Nov 2001
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alfa1 View Post
I would love to read more experiences with this setup.
How about bandwidth costs? With the database being sent to the other server frequently, this seems like a costly adventure.
Bandwidth usage is very small compared to regular web traffic. Your only transferring the changes in the data between the databases and any usage associated with syncing up your web directories.
Reply With Quote
  #8  
Old 02-13-2008, 07:15 PM
mikellogg mikellogg is offline
 
Join Date: May 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Round-robin DNS isn't going to help people connect to a closer server. They will randomly connect to either the east or west coast server.

Quote:
Originally Posted by DigitalCrowd View Post
For those looking to setup a server in say Europe and one in the United States and the primary motivation is to provide a faster site to those in their respective home locations this can be accomplished by loading a up server with all your attachment, images and "bulk" of your web page to a server closer to them, without actually running VB on it. The "text" can still come from your primary server or you could setup a "slave" type setup so that it could be a hot fail-over if needed and don't load balance between the boxes, just send traffic that is closer to the other secondary box when it seems appropriate for those users.
That sounds like the best we can achieve, though you will need to use something other than round-robin DNS to let browsers know which is closest.
Reply With Quote
  #9  
Old 02-13-2008, 07:50 PM
DigitalCrowd's Avatar
DigitalCrowd DigitalCrowd is offline
 
Join Date: Nov 2001
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use round robin, just use whichever server it hits to make the decision on which is closer and redirect the browser to a dns name associated with the closer server.
Reply With Quote
  #10  
Old 02-13-2008, 08:10 PM
mikellogg mikellogg is offline
 
Join Date: May 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DigitalCrowd View Post
You can use round robin, just use whichever server it hits to make the decision on which is closer and redirect the browser to a dns name associated with the closer server.
Request goes to www.forums.com
Then you redirect to east.forums.com or west.forums.com?
That's not DNS round-robin, that's redirecting

I would love to be proven wrong. I've been looking for a (cheap) solution to this issue for a while. DNS round-robin distributes the load, but it uses round-robin, which, by definition, is semi-random. I've been using it for three years now.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04803 seconds
  • Memory Usage 2,312KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete