Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Load balancer implementation problem

Load balancer implementation problem

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasesysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imak
    wrote on last edited by
    #1

    I am trying to simulate a web-farm environment and I need to implement a simple ad balancer layer for this(C#/ASP.NET 2.0, IIS 5.1). I am doing it via folwing architecture. Feel free to suggest any flaws that can help me resolve the problem. I have a web-application named LoadBalancer (LB) which has lists of hosts that it needs to connect. All the hosts are running exactly same web application. So let’s say when users connects to LB, it takes him/her to a web-form on app running on Machine1. User hits a button here but let’s say that Mafchine1 becomes unavailable now, which means that LB should try connecting to application running on Machine2. This mean that I need to capture every http request in LB, see which is the device I am currently connected to , Make sure its avaialble (otherwise get the availabe machine’s URL) and then post the http request to that machine. I tried doing it in Application_PreRequestHandlerExecute event but could not figure out how to do it. Bew is the simplied code that I currently have in Gabal.asax. My questions. 1. Can this be done? 2. My current approach can work? 3. Any code samples will be highly appreicated. TIA <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { System.Collections.Generic.List<string> ListOfMachines = new System.Collections.Generic.List<string>(); int index = 0; // Hard-coded for brevity ListOfMachines.Add("http://Machine1/MyWebApp/"); ListOfMachines.Add("http://Machine2/MyWebApp/"); ListOfMachines.Add("http://Machine3/MyWebApp/"); Application["MachinesList"] = ListOfMachines; Application["CurrentIndex"] = index; } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started string NextMachineURL = GetNextAvailableMachine(); // This returns the URL from MachinesList in round-robin fashion // *** Establish the request System.Net.HttpWebRequest HttpReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(NextMachineURL); // *** Retrieve request info headers System.Net.HttpWebResponse WebResponse = (Syste

    A 1 Reply Last reply
    0
    • I imak

      I am trying to simulate a web-farm environment and I need to implement a simple ad balancer layer for this(C#/ASP.NET 2.0, IIS 5.1). I am doing it via folwing architecture. Feel free to suggest any flaws that can help me resolve the problem. I have a web-application named LoadBalancer (LB) which has lists of hosts that it needs to connect. All the hosts are running exactly same web application. So let’s say when users connects to LB, it takes him/her to a web-form on app running on Machine1. User hits a button here but let’s say that Mafchine1 becomes unavailable now, which means that LB should try connecting to application running on Machine2. This mean that I need to capture every http request in LB, see which is the device I am currently connected to , Make sure its avaialble (otherwise get the availabe machine’s URL) and then post the http request to that machine. I tried doing it in Application_PreRequestHandlerExecute event but could not figure out how to do it. Bew is the simplied code that I currently have in Gabal.asax. My questions. 1. Can this be done? 2. My current approach can work? 3. Any code samples will be highly appreicated. TIA <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { System.Collections.Generic.List<string> ListOfMachines = new System.Collections.Generic.List<string>(); int index = 0; // Hard-coded for brevity ListOfMachines.Add("http://Machine1/MyWebApp/"); ListOfMachines.Add("http://Machine2/MyWebApp/"); ListOfMachines.Add("http://Machine3/MyWebApp/"); Application["MachinesList"] = ListOfMachines; Application["CurrentIndex"] = index; } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started string NextMachineURL = GetNextAvailableMachine(); // This returns the URL from MachinesList in round-robin fashion // *** Establish the request System.Net.HttpWebRequest HttpReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(NextMachineURL); // *** Retrieve request info headers System.Net.HttpWebResponse WebResponse = (Syste

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Are you trying to implement a loda balancer ? Will it be run on your live production ? if yes, then i am suggest rather than try to use own LB try to use any other Third party S/W LB or H/B LB. We are also using Web Farm Architecture for Deploy our web application, and we are using H/W LB. Because, if you are going to implement LB , then it should be the S/W LB and there is a hughe chanllange to implement it.specially Maintain the client request and session created on server. So I will suggest you to think on that. If its your practice purpose, then you can carry on. Good Luck !!!

      cheers, Abhijit

      I 1 Reply Last reply
      0
      • A Abhijit Jana

        Are you trying to implement a loda balancer ? Will it be run on your live production ? if yes, then i am suggest rather than try to use own LB try to use any other Third party S/W LB or H/B LB. We are also using Web Farm Architecture for Deploy our web application, and we are using H/W LB. Because, if you are going to implement LB , then it should be the S/W LB and there is a hughe chanllange to implement it.specially Maintain the client request and session created on server. So I will suggest you to think on that. If its your practice purpose, then you can carry on. Good Luck !!!

        cheers, Abhijit

        I Offline
        I Offline
        imak
        wrote on last edited by
        #3

        This is my semester project. Thanks for your reply.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups