Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Load Balancing

by meonkeys (Chaplain)
on Nov 14, 2000 at 07:05 UTC ( [id://41498]=note: print w/replies, xml ) Need Help??


in reply to RE: Re: using Net::Telnet to test Apache
in thread using Net::Telnet to test Apache

I'm talking about different hosts. Sorry for not being clearer. What I meant is that a URL does not necessarily specify which host a http daemon is active on. For instance, you could have 20 boxes that all correspond to one URL--http://foobar.com for example--that alternately serve pages to balance the load. I'm sure you already know all this.

So, now the question is, what is the best way to test how each individual host's http daemon is doing? The only way I know how is by telnetting into that host's port 80 and doing a HTTP get. IO::Socket::INET sounds interesting, although I don't quite understand how it differs and I haven't successfully implemented it yet.

Replies are listed 'Best First'.
RE: Load Balancing
by Fastolfe (Vicar) on Nov 14, 2000 at 07:37 UTC
    No matter what you use, be it Net::Telnet or IO::Socket or the LWP modules, if you connect to 'example.com' and that hostname is load balanced, you're going to get different servers handling the request, sure. Sorry, I didn't realize that was going to be an issue (it's the first time you brought it up). If you can access each server individually by IP, perhaps you can simply pass that URL to the LWP modules: e.g. http://192.0.0.1/page.html. If you're using virtual hosting such that the Host: header makes a difference, I guess you're better off using IO::Socket and speaking HTTP yourself. If there isn't a way you can reach an arbitrary server directly, I don't see how any of the methods presented can help you, as they'd all be influenced by the load-balancing setup.
      Thank you. You have much knowledge in this area and your help is truly appreciated. I will give IO::Socket a go, and, of course, read more and more and more....
        No, you're being lead down a dark tunnel with no cheese at the end again.

        There's nothing that using your IO::Socket code buys you as far as distinguishing a "load-balanced web server", whatever you mean by that.

        If you have 10 "A" records for "www.someserver.com", then look those up and use the specific IP in your URL, and then be sure to add a "host" header to get the right virtual server, if that makes a difference in your testing.

        Please stop refuting the advice of people whom you are asking advice of, unless you've got some good rebuttal. Sheesh.

        -- Randal L. Schwartz, Perl hacker

RE: Load Balancing
by AgentM (Curate) on Nov 14, 2000 at 07:24 UTC
    I don't quite understand why you don't use LWP::Simple. In order to best simulate a real web browser, you should be downloading all of the web page anyway, so complicating your code with Net::Telnet just isn't worth it- unless you have a counter argument, I just don't see the point...
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
      How would you find out that one of your load-balanced boxes' httpd was working more slowly than the others? I'm open to suggestions.
        Use available benchmarking software like Big Brother to optimize your system. Your current testing scheme may become invalid if you uncover network anomalies (or are you looking for network anomalies?). Have a simple script pound your webserver locally (assuming that it's a dedicated webserver) or over a connection that is otherwise dead of traffic. Every machine most likely has an IP (metaserver setup, right?), so use that in your call to LWP::Simple. Fork a multitude of fake browsers and see how many concurrent hits the server can take. Do this with all the machines and compare results. Good luck.

        I just thought of an easier way. I believe most webservers have some benchmarking capabilites. In that case, throw a benchmark patch onto the metaserver to time how much each serve is taking in response to the same web page being retrieved repeatedly. You'll be easily able to pick out the slow poke!

        AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://41498]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found