Skip to content

complete_unicorn_nginx doesn't include haproxy but complete_passenger_nginx does #325

Closed
gabceb opened this Issue Apr 5, 2013 · 11 comments

6 participants

@gabceb
gabceb commented Apr 5, 2013

HAProxy was removed from the complete_unicorn_nginx template by 54faef3 but complete_passenger_nginx still has HAProxy.

I am a newbie on rubber and was following the tutorial by Railscast but using unicorn instead of passenger. I thought the unicorn and the passenger would include the same roles but they didn't.

@gabceb
gabceb commented Apr 6, 2013

I guess my question is more about why the decision of not having a web role with haproxy for the nginx/unicorn setup. This questions is also posted on the Google forums load balancer on complete_unicorn_nginx_postgresql

@jimcavoli

This question is well-answered in the group linked and is a non-issue as to the functionality of the template. I'm glad you're getting an understanding of how to modify the roles and add templates to roles in the case you want particular functionality. As far as being an issue on @rubber it seems to be both a non-issue and a non-feature request. I'd like to see this one closed on such grounds and because it's being well-addressed more appropriately elsewhere.
@wr0ngway , @SegFaultAX - would one of you you or another admin close / voice otherwise?

@gabceb
gabceb commented Apr 10, 2013

You are correct @jimcavoli, this question was answered on Google Groups and it should be closed. The fact that I had to deal with this also helped me understand a lot more about nginx and why it does not need a load balancer and that is why HAProxy is not needed. I also learned a lot about Rubber in general.

I would suggest adding a small blurb to the Wiki for those people (like me) that are coming from the Railscast tutorial and want to get started with Nginx/Unicorn instead of Passenger/Apache. I am sure this question will keep coming up as more people discover the awesomeness of Rubber.

I am just a developer getting into the devops world and I thank Rubber (and all the developers here) for making this learning process a lot easier. :smile:

@SegFaultAX
rubber member

Thanks for the questions and kind words @gabceb! I'm closing this as the issue seems resolved.

@SegFaultAX SegFaultAX closed this Apr 15, 2013
@thimios
thimios commented Apr 16, 2013

@gabceb Thanks a lot for your response. It is still unclear to me why nginx does not need a load balancer. How would you add two application nodes on a cluster and do the load balancing without using elb or haproxy? Is there a way to use one nginx node as the load balancer for multiple instances running unicorn?

thanks!

@nirvdrum
rubber member

I'm a bit fuzzy on this as well. It was explicitly removed from unicorn and my only guess as to why is because unicorn can do zero downtime deploys. I'll look into this more when I get some spare time.

@gabceb
gabceb commented Apr 16, 2013

All I did was to add an ELB before my web/app machines based on @thimios response on Google groups. I tried a lot of things (including adding an HAProxy role) but didn't work. I also didn't know what I was doing back when I was trying things out so now that I have a better understanding of how rubber works I may give it a try later. Maybe @messick can shed some light now this since he created the PR that removed HAProxy from the template.

You guys should also take a look at this Github blog post. My understanding is that adding HAProxy after ELB is just adding an extra load balancing step that is not needed since the Unicorn sockets are load balanced in the OS Level.

@nirvdrum
rubber member

Well, part of the issue is we're begging to add additional providers other than AWS. So ELB isn't a valid option in that scenario.

@jridgway

This is exactly where I'm at right now. I'm trying to use rubber on Digital Ocean.

@nirvdrum
rubber member

You can vulcanize the haproxy template on top of what you have in the interim.

@jridgway

Thanks, nrvdrum. I wasn't exactly sure what you meant but I fixed it anyways by adding the code below to rubber/role/haproxy/haproxy-base.conf config. I also had to explicitly add the haproxy role to my web server, since the web role was unexpectedly not dependent on it in rubber-complete.yml. I'm looking forward to this being fixed for real. Not having the choice to use Digital Ocean is a killer for me.

<%
  backend_hosts = rubber_instances.for_role('app').collect { |i| i.name }
%>

listen nginx_proxy 0.0.0.0:<%= rubber_env.web_port %>
  option forwardfor
  <% backend_hosts.each do |server| %>
    server <%= server %> <%= server %>:<%= rubber_env.web_port  %> maxconn <%= rubber_env.max_app_connections %> check
  <% end %>

listen nginx_proxy_ssl 0.0.0.0:<%= rubber_env.web_ssl_port %>
  mode tcp
  option forwardfor
  <% backend_hosts.each do |server| %>
    server <%= server %> <%= server %>:<%= rubber_env.web_ssl_port %> maxconn <%= rubber_env.max_app_connections %> check
  <% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.