Question

I just noticed an issue on our production server whereby the apache balancer was configured thusly:

<Proxy balancer://thin_cluster>
  BalancerMember http://127.0.0.1:6000
  BalancerMember http://127.0.0.1:6001
  BalancerMember http://127.0.0.1:6002
  ProxySet lbmethod=bybusyness maxattempts=1 timeout=30
</Proxy>

But the thin config file only specified 2 servers;

thin.yml (condensed for brevity)
address: 127.0.0.1
port: 6000
servers: 2    # <-- wrong!!

The number of thin servers was increased from 2 to 3 about 6 months ago, but whoever increased it forgot to increase the servers count in the thin.yml file (they only did it in the apache config file). The reason I started looking into this is that it had been noticed that every third request to the application was slow. I'm assuming this is why.

The question I have is: What would thin actually do under these conditions? Why did the application still work? Surely every third request would have full on died rather than "coped with this situation".

Thanks in advance.

Was it helpful?

Solution

Thin doesn't know or care about the Apache configuration. It only adheres to its own config and will only spawn 2 servers as a result.

The reason every third request was kinda slow is probably due to Apache rerouting the request. Since the two thin servers are using ports 6000 and 6001 the reference from Apache to port 6002 cannot reach a server - the port is simply not used by any.

Apache still tries sending the request there, because it also doesn't know if there's a server behind that address/port. It then waited for a timeout (a few seconds?) since no response was given and then rerouted the request to one of the other ports (6000 or 6001).

Apache doesn't "save" the unreachable server because it might just be a temporary outage. You can probably change this behavior with some settings (at least that is possible in Nginx)

You should either remove the third port definition in Apache or add another thin server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top