I would like to know about load balancing servers.
I am having an application which is having load balanced server.
When i made some changes to the data, in my application how it is taking effect?
Also, when we restart the application , what are all the steps that are happening, to a load balanced server?
well, the load balancer is separate from the application code, basically it is just routing the requests to one of a number of set up servers (a.k.a. downstream servers, for instance web application servers, apache/nginx+php, etc) that handles the actual request. So to update the application (i.e. java servlet, JSP, PHP page, static HTML page, image, etc) all the downstream servers will have to be updated. As for data (i.e. articles, user database, etc) this will usually be stored in a database that all the downstream servers connect to
As for restarting the application, when you do that on each of the downstream servers it will temporarily be unable to service requests, the load balancer will thus get an "unable to connect" issue when trying to send requests to the server with the application being restarted, and will then try to send the request to the next server in the list of downstream servers. Depending on how the load balancer is set up it will automatically retry sending new requests to the previously restarted server and when the restarted downstream server is up again it will again service requests. So to update the applications you basically just update one downstream server at the time, as the other servers take over the load while it is restarted it will be no downtime, and the clients will be none the wiser
Is this a hardware appliance or at server running HAProxy/nginx/other?
Related
I have a server running expressjs that hosts the admin website and 4 to 10 additional worker servers that run a job scheduler and are constantly processing jobs and receiving new data. Is there a good way for the worker servers to notify the website server and then update the data on the website using websockets?
Worker servers can use any number of means for communicating with your main server. For example, you main server could have a special web server in your main server (not exposed to the outside world) that just receives http requests with data from the workers. So, whenever a worker gets new data, it just sends an http request to the main server.
Or, either webSocket or socket.io can be used server-to-server just fine (one end serves as the client for establishing the connection) and the other is the webSocket/socket.io server listening for incoming connections. In your case, the workers would be the clients and they would connection to your main server and then they can send data whenever they want over the webSocket or socket.io connection.
If you then want to automatically update data in various web browsers that have one of your pages open, those pages would also have a webSocket or socket.io connection open to your server so when your server gets new data, it could then tell the web page about it and the webpage could update its display without constantly refreshing/reloading a new page.
Either ws or socket.io can be used. Socket.io offers a number of features built on top of webSocket. You would choose socket.io if you want those added features. You can see a partial list of the added socket.io features here:
Moving from socket.io to raw websockets?
Suppose we have two servers serving requests through a load balancer. Is it necessary to have web server in both of our servers to process the requests. Can load balancer itself act as a web server. Suppose we are using apache web server and HAProxy. So does that mean that web server(Apache) should be installed in both the server and load balancer in any one of the server. Why can't we have load balancer in both of our server machine that will be receiving the request and talking to each other to process the requests.
At the very basic, you want to have Webservers fulfill requests for static contents, while Application servers handle business logics, i.e. handle requests for dynamic contents.
But Web servers can do many other things as well such as authenticate and validate requests, logging metrics. Also, the important part of Webserver is putting the Content it gets from Application servers with a View for client to represent.
You want to have LB sitting in front of both Web and App servers if you have more than one server. Also, there's nothing preventing you from putting both Web and App server in one.
The load balancer is in front of your webserver(s) to redirect requests according to number of sessions, a hash of source IP and destination IP, requested URL or other criteria. Additionally, it will check availability of the backend servers to ensure requests get answered even if one server fails.
It's not installed on every webserver - you only need one instance. It could be a hardware appliance, or a software (like HAproxy) which may or may not be installed on one of the webservers. Although this would not be prudent, as this webserver could fail and then the proxy would not be able to redirect traffic to the remaining server.
There are several different scenarios for this. One is load balancing requests to 2 webservers which serve the same HTML content, to provide redundancy.
Another would be to provide multiple websites using just one public address, i.e. applying destination NAT according to the requested URL. For this, the software has to determine the URL in the HTML request and redirect traffic to the backend webserver servicing this site. This sometimes is called 'reverse proxy' as it hides the internal server addresses from the outside.
I'm building an app that will call a web service that has 2 identical instances, each running on a different server, with its own IP.
The app can call any service instance at any time, but sometimes it may have difficulties getting a response from one of them (because of a network failure or a problem with the instance).
What is the recommended way to make the app automatically stop using the problematic instance?
How can it get back to using the instance when it's online again?
Are there standard libraries or tools to help this kind of scenario?
Use a load balancer.
You app will have to connect to the LB and not to the web servers directly. LBs maintain status of each server they are configured with ( through timeout or explicit http status calls). They automatically disable traffic from the disconnected servers and enable it once the instance is back.
Later on you can add or remove instances based upon your requirements ( manual or auto-scaling ) without requiring any changes in your app.
HAProxy and Nginx are widely used for internet scale load balancing. Cloud providers also provides this as a service, you can use them if you are on cloud ( like AWS has elastic load balancing, Google Cloud has Load Balancing ).
I'm totally new to clustering and load balancing.
What I'm trying to do is "Deploy Application on a Cluster which contains 2 managed servers. Now, If one of the managed server goes down, request should be redirected to another server which is Up."
For Example:
I've 2 managed servers (M1:7021 and M2:7022)
And I've a Cluster C1 having M1 and M2.
And I've an Application App1 deployed on C1 and a Data Source deployed on C1.
Application App1 is working fine.
The way through which I'm accessing application is:
http://10.184.111.11:7021/App1/
AND
http://10.184.111.11:7022/App1/
Now, Suppose if M1(7021) goes down, and request is coming like
:7021/App1/
Then, it should be redirected to :7022/App1/
Any help is highly appreciated. Thanks!
I believe you will need a load balancer (or a software equivalent) to sit above the weblogic servers and direct traffic down to those servers.
The idea being that you access your application on http://loadBalancer.com/App and then the Load Balancer forwards your request onto either one of weblogic servers. Meanwhile in the background the load balancer is continually performing health checks on the two weblogic servers to see if they are running.
In the event that one of the weblogic servers go down, the load balancer will mark it as inactive and forward all traffic to the weblogic server still running. Once the failed weblogic server has come back online the load balancer will begin routing traffic back through it.
#Garreth Well, in fact WebLogic DOES provide an internal load balancer. You are supposed to use OHS or Apache for load balancing in production environments, but for development, httpclusterservlet works great.
I got a query regarding a response from cluster of managed server (Weblogic) behind load balancer.
During a request to server (though load balancer) if server crashes then does response goes back to client OR load balancer re-route the request to another running server in that cluster (stateful request)
so the workflow is something like this:
Client request -> server1 -> crashed in between processing request -> reponse back to app -> send back to server -> load balancing-> to another running server.
does it go to client in case of crash server response
OR
Load Balancer handles the response and see that server crash response received and hence it re-request (without even client letting know about this whole crashing scene)
Depends on the Load Balancer, depends on the vendor, depends on the module and method. Your question is vague. This is what a load balancer should be configured to do. It comes built in for some load balancers like Apache and might have to be specifically configured for some others.
The load balancer should probe your application page, for example if you have an application running on http://example.com:9101/index.html, then every 15 seconds(say) it will probe the page and ensure the application is up and send traffic to it. If not, it will send it to the other members defined. So if the server crashes, it will know and stop sending. Most commercial and free load balancers have to option to be configured to do so, so does the weblogic load balancer.
Without more information, this is the most general answer I can provide.