java - Application with auto update and MongoDB replica set -
java - Application with auto update and MongoDB replica set -
i'm in process of providing our applications of high availability capability.
our applications have auto update feature (using mongeez) ensures construction of databases/collections/documents on right format application version.
the problem i'm having hard time, on how resolve replication , versioning problem.
i'll utilize next illustration improve explain problem.
i need update application x application x2.0 on both servers without downtime, following:
stop application xa install 2.0 version on server a launch application x2.0a application x2.0a automatically updates mongodb 2.0 format since using mongodb replica set, automatically propagates changes in mongodb instances problem!!!... application xb still running version 1.0 it's using 2.0 version of databases/collections/documents structurehow can solve issue? doing wrong in previous "workflow"?
let's suppose:
f1: format 1.0 f2: format 2.0 xa: reads & writes f1 xb: new application, reads & writes f2 (document 2.0)if f2 compatible f1, can create xa & xb run together. seems cause isn't described :)
if f2 not compatible f1, there lot of work do.
=============== simple method ==================
addversion
field document (or utilize field distinguish between f1 , f2) make xb compatible f1&f2: if reads f1 writes f1, if reads f2 writes f2 upgrade applications xb (xa not affected because there no f2 @ moment) make xb writes f2: if reads f1 writes f2, re-deploy xb. convert f1 documents f2 =============== mutual complex method ==================
let's define concepts first:
c1: collection f1 c2: collection f2 xb: application switch command reading: c1 or c2. uses xa's logic read c1.steps:
xa running, reads & writes f1 in c1 migrate info c1 c2 (upgrade f1 f2) analyze , execute oplog create sure new modifications in c1 migrated c2 xb reads c1, write c1&c2 (important!) deploy xb step step, xa not affected because c1 usable switch xb read c2 remove legacy code f1 in xbyou need programs(scripts) step2 & step3.
if don't care cold data, can skip step2&step3, allow xb run time migrate hot data.
=============== method ==================
divide server groups. eg: g1(xa1, xa2), g2(xa3, xa4) use nginx/haproxy balance requests make requests sent g1(xa1, xa2) deploy xb g2, result: g2(xb3, xb4) make requests sent g2(xb3, xb4) deploy xb g1, result: g1(xb1, xb2) make requests sent g1(xb1, xb2)/g2(xb3, xb4) convert f1 documents f2there risks:
in step 3/step 5, server load may exceed, need in non-business time if have bugs in xb, there no way rollback. java mongodb updates auto-update high-availability
Comments
Post a Comment