載均衡有很多種方法,有硬件負載均衡,軟件負載均衡,還可以從域名解析下手。
不過,今天只講軟件負載均衡。
軟件負載均衡一般分兩種,從網絡協議來講(tcp/ip),主要集中在第四層和第七層進行負載均衡。
第四層就是基于IP進行負載均衡。后面還有一篇文章講這個。
第七層就是應用層。比如各種的WEB服務器。今天就講講IIS的負載均衡。
第七層的Web負載均衡,很多web服務器都支持,比如IIS,Nginx,apache等?,F在主要講一下windosw下IIS如何使用負載均衡
IIS使用ARR反向代理,實現負載均衡
什么是正向代理?
代理服務器大家可能聽說過,比如我們說的“科學上網”。就是使用代理服務器,請求經過代理服務器轉到目的服務器。這是一個正向代理。用戶知道自己使用代理,并且充許用戶隱藏客戶端自身。
什么是反向代理?
請求同樣經過代理服務器轉到目的服務器,目的服務器返回給代理服器,代理返回給客戶端。不同的時候,客戶并不知道,訪問的是一個代理服務器??蛻粽J為他在訪問目的服務器。
兩者的區別基本在于,正向代理是發生在客戶端。反向代理是發生在服務端。
首先,我們先安裝一個Web平臺安裝程序
打開web平臺安裝程序,搜索arr
寫WebApi程序
[Route("api/[controller]")]public class HomeController : Controller{ // GET: api/<controller> [HttpGet,Route("GetUserChat")] public async Task<ActionResult> GetUserChat() { var collection = new MongoHelper().GetCollection<OAChat>("OAChat"); var chatItems =await collection.Find(n => n.ChatType == 2).Limit(5).ToListAsync(); return ApiJsonFormat.GetJsonResult(chatItems); }}
返回結果
{"ResultCode":1000,"Message":"成功","DetailError":null,"Data":[{"Id":"595225a5bbccc61ff88e89a7","ChatName":"testttt","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-27 17:30:13","LastChatTime":"2017-11-10 17:43:17","LastChatText":"[定位]","IsDisbanded":false},{"Id":"5952445ebbccc71ff8adf671","ChatName":"測試2","ChatType":2,"CreaterUserId":13,"Members":[],"CreateTime":"2017-06-27 19:41:18","LastChatTime":"2017-06-27 19:48:47","LastChatText":"行","IsDisbanded":true},{"Id":"5952463dbbccc71ff8adf67d","ChatName":"巡視頻么么噠噠","ChatType":2,"CreaterUserId":13,"Members":[],"CreateTime":"2017-06-27 19:49:17","LastChatTime":"2017-12-20 19:47:17","LastChatText":"[定位]","IsDisbanded":false},{"Id":"59524c0ebbccc71ff8adf6ae","ChatName":"rrrffff","ChatType":2,"CreaterUserId":13,"Members":[],"CreateTime":"2017-06-27 20:14:06","LastChatTime":"2017-06-27 20:34:54","LastChatText":"6565","IsDisbanded":false},{"Id":"59531cdfbbccc414e8f6769f","ChatName":"都紛紛fee俄方熱熱","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-28 11:05:03","LastChatTime":"2017-06-28 11:05:13","LastChatText":"123","IsDisbanded":true},{"Id":"59531de5bbccc414e8f676a1","ChatName":"天賦過人托管人","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-28 11:09:25","LastChatTime":"2017-06-28 11:09:33","LastChatText":"呃呃呃","IsDisbanded":true},{"Id":"59531e40bbccc414e8f676a3","ChatName":"熱熱","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-28 11:10:56","LastChatTime":"2017-06-28 17:58:41","LastChatText":"333","IsDisbanded":false},{"Id":"59532140bbccc414e8f676a6","ChatName":"會厭結核有機會好好","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-28 11:23:44","LastChatTime":"2017-06-28 11:24:40","LastChatText":"eee","IsDisbanded":true},{"Id":"595321d3bbccc414e8f676a8","ChatName":"656565656","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-28 11:26:11","LastChatTime":"2017-06-28 18:50:08","LastChatText":"ggg","IsDisbanded":false},{"Id":"5954d0eebbccc40fecbea435","ChatName":"r","ChatType":2,"CreaterUserId":76,"Members":[],"CreateTime":"2017-06-29 18:05:34","LastChatTime":null,"LastChatText":null,"IsDisbanded":false}]}
新聞熱點
疑難解答