什么是系统的可扩展性?到底什么是可扩展性?这年头,作为软件设计架构师若是系统没有可扩展性对外交流时都不好意思。可是如何选择可扩展性方案?水平扩展仍是垂直扩展?是不是很矛盾呢,本文为你分析可扩展性的真实含义和实际项目中的取舍。Whenaskedwhattheymeanbyscalability,alotofpeopletalkaboutimprovingperformance,aboutimplementingHA,oreventalkaboutaparticulartechnologyorprotocol.Unfortunately,scalabilityisnoneofthat.Don’tgetmewrong.Youstillneedtoknowallaboutspeed,performance,HAtechnology,applicationplatform,network,etc.Butthatisnotthedefinitionofscalability.每每和他人提及可扩展性的含义时,很多人开始讨论提高性能,实施高可用性,乃至谈论特定的技术或协议。显然这些并非是可扩展性。不要误解,您固然需要了解关于速度,性能,可用性,应用平台,网络等相关的一切,但这并非可扩展性的概念。Scalability,simply,isaboutdoingwhatyoudoinabiggerway.Scalingawebapplicationisallaboutallowingmorepeopletouseyourapplication.Ifyoucan’tfigureouthowtoimproveperformancewhilescalingout,itsokay.Andaslongasyoucanscaletohandlelargernumberofusersitsoktohavemultiplesinglepointsoffailuresaswell.简单地说,可扩展性就是关于如何处置更大规模的业务。比如,Web应用程序就是允许更多的人利用你的服务。若是你不能弄清楚如何提高性能的同时向外扩展,没关系。只要你能处置更大规模的用户,即即是存在多个单点故障也没有问题。Therearetwokeyprimarywaysofscalingwebapplicationswhichisinpracticetoday.在今天实践中有两个关键的缩放Web应用程序的方式:垂直扩展和水平扩展。“VerticalScalability”–Addingresourcewithinthesamelogicalunittoincreasecapacity.AnexampleofthiswouldbetoaddCPUstoanexistingserver,orexpandingstoragebyaddingharddriveonanexistingRAID/SANstorage.“垂直扩展“-在同一个逻辑单位添加资源以增加容量。这样的例子触目皆是,比如升级服务器的CPU,比如在RAID/SAN存储设备上增加硬盘。“HorizontalScalability”–Addingmultiplelogicalunitsofresourcesandmakingthemworkasasingleunit.Mostclusteringsolutions,distributedfilesystems,load-balancershelpyouwithhorizontalscalability.“横向扩展“-增加多个逻辑单元资源而且使他们作为一个整体在工作。大多数的集群解决方案,比如散布式文件系统,负载均衡都是通过横向扩展技术来进行的。Everycomponent,whetheritsprocessors,servers,storagedrivesorload-balancershavesomekindofmanagement/operationaloverhead.Whenyoutrytoscalethat,itsimportanttounderstandwhatpercentageoftheresourceisactuallyusable.Thismeasurementiscalled“scalabilityfactor“.Ifyouloose5%ofaprocessorpowereverytimeyouaddaCPUtoyoursystem,thenyour“scalabilityfactor”is0.95.Ascalabilityfactorof0.9meansyouwillonlybeabletouse90%oftheresource.每一个部件,无论它是处置器,服务器,存储驱动器或负载均衡有必然的管理上或操作上的开销。当您尝试进行扩展时,很重要的一点是要了解实际的资源利用率,这种测量方式被称为“可扩展性因子“法。若是每添加一个CPU到系统,都会失去5%的处置器功率,那么您的可扩展性系数为0.95。当可扩展系数为0.9时,意味着你将只能利用90%的资源。Scalabilitycanbefurthersub-classifiedbasedonthe“scalabilityfactor”.以“可扩展性因子“为基础,可扩展性可以进一步细化分类。Ifthescalabilityfactorstaysconstantasyouscale.Thisiscalled“linearscalability“.若是你的可扩展性系数维持不变,这就是所谓的“线性的可扩展性“。Butchancesarethatsomecomponentsmaynotscaleaswellasothers.Ascalabilityfactorbelow1.0iscalleub-linearscalability“.但某些组件有可能无法像他人一样可以扩展,该系数低于1.0的就是所谓“分线性可扩展性。“Thoughrare,itspossibletogetbetterperformance(scalabilityfactor)justbyaddingmoreco...