您的位置:首页 > 运维架构 > 网站架构

设计一种100%可用性服务的架构--适用于任何系统(B/S,C/S)[中英文版本]

2014-11-03 17:21 429 查看

设计一种100%可用性服务的架构--适用于任何系统(B/S,C/S)[中英文版本]

-- How to design an architecture which have 100 percent availability service?



版权所有,转载请注明出处http://blog.csdn.net/yangzhenping,谢谢!

本篇原创非译文,有需要设计和部署这种架构的,请私信我,谢谢!

最近一直在想怎样设计一种100%可用性的服务,于是有了最初的版本:



如上图,有多个备份的网页服务器和数据库服务器,还有一台同步服务器把主数据库A中的数据同步到其他副本从服务器

问题来了:

当数据库服务器A还没来得及被DBSync Server同步到B上,这时A宕机了,我们可能会丢失部分数据。

那我们怎么才能不丢失数据呢?

As above graph, there are some backup web servers and database servers, also have one sync server to sync data from master database server A to other slave database servers.

Then problem comes:

We may lost some data when some data in DBS A didn’t sync toDBS B and it is outage!

How can we NOT to lose any data?



根据上面这个设计所碰到的问题,我又设计了下面的架构,当然这个架构还可以继续提升,文章结尾再说哈:

Based on above problem, I design another architecture like below, of course we can improve it again, talk it at the end of this article:



网页服务器A提交一个SQL脚本请求(包含requestId,它是一种Guid类型)给主数据库服务器A,
A的DbSync Service会将这个SQL脚本请求同步给副本服务器B,然后再在A上执行这个SQL脚本,最终把结果返回给网页服务器A。

同样数据库服务器接受到来自A的请求,会同步这个SQL脚本到下一个副本服务器C上,然后执行结果返回给RCS结果比较服务器(所有的副本服务器的DBSync
Service都会返回结果给RCS)。

RCS结果比较服务器会根据同一个requestId比较主数据库服务器执行的结果和副本服务器执行的结果:

如果主DBS执行成功,副本执行失败,RCS会重新在副本上重新执行直到成功。

如果主DBS执行失败,副本也执行失败,RCS不会做任何事。

如果主DBS执行失败,副本执行成功,我们有两种选择:

选择一:RCS在主DBS上重新执行直到成功,然后通知用户他之前提交的失败任务现在成功了。

选择二:RCS在副本服务器上回滚已经成功的这个SQL脚本,在主DBS上不做任何事。

Web Server A request a SQL script (Contains requestId, it isa Guid type) to Master DBS A, in DBS A its sync service will sync the SQLscript to Slave B, then DBS A’s Sync service will do the SQL script and
thenreturn the result to Web Server A.

Also DBS B’s sync service receive the SQL script will syncthe SQL script to the next Slave DB server C, then execute the SQL script andreturn toResult Compare Server (allslave DB server’s
DB sync service will return the result toResult Compare Server).

Result Compare Server will compare the result usingrequestId, compare the Mater’s requestId result to Slave’s requestId result:

If Master execute pass, but Slave execute failure, RCS willrerun until pass on Slave.

If Master execute fail, and Slave execute failure, RCS willdo nothing on Slave.

If Master execute fail, but Slave execute pass,

Option 1, RCS will rerun on Master until pass and notifyuser about this request pass when it pass.

Option 2, RCS will roll back the SQL script action on Slave,and do nothing on Master.



文章的结尾顺便说下,这个可以继续提升为可用性更高的服务,就是搭建一台RCS的备份服务器。

本文主要提供一种100%可用性架构是针对网页服务器和数据库服务器,当然您也可以把它应用于C/S架构上。

At the end of this article, you can improve it to be a better service, that's deploy another RCS backup server.

This article provide a way to deploy 100% high availability web server and database server, of course, you can also use it in C/S, not only B/S, thanks.

版权所有,转载请注明出处http://blog.csdn.net/yangzhenping,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐