最近在蹦心的开发环境下交叉对比测试了标题中各个牛X东东的组合架构,最后采用的结构是:
Haproxy->Varnish->Nginx/Cherokee/Lighttpd
前端使用Haproxy作为BigIP的负载均衡节点,最新版对双机热备、L7交换均有较好支持,友好的web状态监控也很不错;至于为什么不选择Varnish、Nginx或者LVS作为负载均衡,不多说了,具体问题可以和我探讨;
在Haproxy下挂载Varnish作为cache和二级负载分发处理层,考虑因素是比squid更好的可配置性和理论性能数据;
后端的web server优先考虑Nginx,其次进行了部分节点部署Cherokee,一方面为了测试性能,也是为了跟踪该软件后续升级后的表现,从目前我的测试环境来看,并非有Nginx性能好,因为从Haproxy的优先选择结果来看,更多的会选择Nginx后端分发请求,即使有weight优先的情况下。Lightpd逐渐的退出我们的系统了,更新的停滞和相对性能无优势的现状使得被我逐渐放弃。
其实从很多中小站点来说,对于使用Haproxy还是Varnish或者Nginx做负载均衡,差别都是不大的,理论的测试数据对中小站点来说,没有太多实际意义,选择一个最熟悉,配置最方便的才是最好的,综合实际情况来说,用Nginx作为负载均衡还是不错的,比如可以集中处理日志,灵活的配置文件语法可以方便的使用正则配置L7交换逻辑,这些都是很实际的。
随着蹦心的发展,将不断根据具体情况调整架构并且随时和大家分享经验。

嗯,如果是单纯的做反向代理,HAProxy是性能最高的
[Comment ID #31686 Will Be Quoted Here]
这位朋友有没有什么关于haproxy使用的好经验分享?
@Michael:
1、关于配置源码exampels目录下有不少例子。注意最大fd数(连接数)还有超时时间之类的。可适当调节一下进程数看看有没有效果。
2、注意buffer大小对整个内存占用的影响。如果对默认值(16K)不满意,你可以修改它。
3、sepoll的性能不错,但是有bug会导致CPU占用100%,我不知道现在这个bug修复了没有,如果你想稳妥点,那可以只用epoll。
以上都要对你的实际应用测试后才知道是否有意义 🙂
[Comment ID #31692 Will Be Quoted Here]
太好了,目前已经测试运行快一周了,我多试试不同的参数组合配置看看,感谢!
不错,我们现在用的是Nginx-> varnish -> Nginx+PHP,前端的响应时没有什么问题的。只是后端数据库感觉有些瓶颈,不知道你们是怎么处理的?
[Comment ID #31694 Will Be Quoted Here]
后端数据库一般通过主辅库分离,然后配合mysql-proxy(LVS/Haproxy)等对多个辅库进行负载均衡,然后再加入memcached以及自己写的app中间数据引擎来缓存和索引,大致是这样
Haproxy->Varnish->Nginx+PHP->Memcached->Proxy(LVS)->MySQL (Other App + MySQL)
生产环境中至少keepalived+haproxy*2保证前端转发正常吧。单台haproxy一旦出现问题整个项目不能用,风险太大吧。
没错,对于在预算允许的情况下,合理的架构设计最重要的一条就是避免任何的单点,但是实际情况下如何呢? 我们绝大部分的网站不在前端是单点,就是后台某个环节是单点,这任何的单点都会导致一旦出现故障,整个网站就出现系统维护或者暂时无法访问的提示页面出现,NB的公司通常会使用两台F5这样的设备实现高可靠性,稍差点的,一般会使用两台LVS或者Haproxy通过心跳线来做实时热备,更差点的公司,能考虑到使用LVS或者Haproxy已经不错了,绝大部分公司的实际情况是,根本考虑不到这些情况,有的也是因为预算不足所致。
有关负载均衡,可以到我另外一个文章里面探讨:http://www.toplee.com/blog/71.html
后端数据库一般通过主辅库分离,然后配合mysql-proxy(LVS/Haproxy)等对多个辅库进行负载均衡,然后再加入memcached以及自己写的app中间数据引擎来缓存和索引,大致是这样
Haproxy->Varnish->Nginx+PHP->Memcached->Proxy(LVS)->MySQL (Other App + MySQL)
————–
呵,还好有括号说明,不然我还真理解成lua的那个“mysql-proxy”了。
我们当前的mysql slave均衡还是通过代码随机选取的,谈不上真正意义上的均衡,接下来我是打算在内网放一台专用于的均衡的服务器,应该是lvs或者haproxy。
另外,我观察到varnish的round-robin,random两个均衡策略对后端没有效果,不知道你碰到没有?
director webserver round-robin {
{ .backend = sina1; }
{ .backend = sina2; }
}
#director webserver random {
# .retries = 3;
# { .backend = sina1; .weight=5; }
# { .backend = sina2; .weight=5; }
#}
生产环境会出现一个峰值并发,一旦峰值并发超出haproxy的承受范围您怎么处理?即使用keepalived把前端转到备机上的haproxy,但备机的haproxy仍然无法承受这个峰值转发,依然会有大量转发堆积到前端。影响用户体验。一般这种峰值只出现几分钟几十分钟不等。如果不使用F5之类的硬件有没有更好的解决办法?
我认为前端不可能只用一台haproxy来做成载的吧,如果是多台又没有lvs进行分配请求就可以考虑使用dns轮询的方式做负载,当然这样也会有风险存在,但总比单台承担风险要强
另外我认为,如果因为成本考虑而不能保证所有单点消除的话,可以考虑使用heartbeat2.x的技术,达到多机互为备份的做法,规避一下风险
都是高手啊。搜索资料看到博主的站 不错
我只停留在部分用过的阶段。
对于这些个反向代理,我基本都用过,单单是性能对比的话 haproxy-varnish-nginx-squid
也可能是本人水平的有限,通过google找了很多高手的例子 感觉squid做静态的,如 图片服务器的话 很强大
我想问下 Haproxy->Varnish 这两个分别怎么配置啊
我配置了haproxy的服务器 跳出503
Hello, i feel that i saw you visited my website thus i got here to return the choose?.I’m trying to
to find things to improve my website!I guess its good enough to
make use of a few of your ideas!!
It’s awesome in support of me to have a web site, which is good designed for my
knowledge. thanks admin
Touche. Outstanding arguments. Keep up the amazing work.
I blog frequently and I really appreciate your content.
The article has really peaked my interest. I am going to book mark your website
and keep checking for new information about once a week.
I opted in for your RSS feed too.
Hey great blog! Does running a blog like this take a lot
of work? I have absolutely no knowledge of coding but I was hoping to
start my own blog in the near future. Anyways, should you have
any recommendations or techniques for new blog owners please
share. I know this is off topic but I just needed to ask.
Cheers!
Hey! This post couldn’t be written any better! Reading
through this post reminds me of my previous room mate!
He always kept chatting about this. I will forward this
page to him. Fairly certain he will have a good read.
Many thanks for sharing!
Hi there friends, good piece of writing and nice urging commented here, I am genuinely enjoying by these.
I’ve been surfing on-line more than 3 hours lately, yet I by no means discovered any attention-grabbing article like yours.
It is beautiful price sufficient for me. In my view, if all site owners and bloggers made good content as you did, the internet
shall be much more helpful than ever before.
Hello, after reading this amazing piece of writing i am also delighted to share my experience here
with friends.
I like the valuable information you provide in your
articles. I’ll bookmark your weblog and check again here regularly.
I’m quite sure I’ll learn plenty of new stuff right here!
Best of luck for the next!
What’s up to every single one, it’s truly
a pleasant for me to visit this website, it consists
of useful Information.
Helpful info. Lucky me I discovered your website unintentionally, and I’m stunned why
this accident didn’t took place in advance! I bookmarked it.
With havin so much written content do you ever run into any problems of plagorism or copyright violation? My site
has a lot of completely unique content I’ve
either created myself or outsourced but it seems a
lot of it is popping it up all over the web without my permission.
Do you know any solutions to help protect against content from being
ripped off? I’d really appreciate it.
My brother recommended I might like this blog. He was totally
right. This post truly made my day. You can not imagine
just how much time I had spent for this info!
Thanks!
I am sure this piece of writing has touched all the internet people, its really really pleasant post on building up new webpage.
Thanks on your marvelous posting! I actually enjoyed reading it, you’re a great author.
I will ensure that I bookmark your blog and may come back down the road.
I want to encourage that you continue your great writing, have a nice holiday weekend!
I know this if off topic but I’m looking into starting my
own weblog and was curious what all is needed to
get setup? I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet smart so I’m not 100% certain. Any suggestions or advice would be
greatly appreciated. Appreciate it
I enjoy reading an article that will make people think.
Also, thanks for allowing me to comment! plenty of fish natalielise
Hey there, You’ve done a great job. I will definitely digg it and personally suggest to
my friends. I’m sure they will be benefited from this web site.
Incredible! This blog looks just like my old one!
It’s on a completely different topic but it has pretty much the same page layout and design. Outstanding choice of colors!
Hi! I’ve been following your blog for some time now and finally got the courage
to go ahead and give you a shout out from New Caney Texas!
Just wanted to mention keep up the excellent job!
Howdy! This article couldn’t be written much better!
Going through this article reminds me of my previous roommate!
He constantly kept talking about this. I will forward
this article to him. Fairly certain he will have a great read.
Thank you for sharing!
Excellent blog post. I certainly love this website.
Thanks!
Great article, just what I needed.
Howdy! Someone in my Facebook group shared this website with us so I came to
check it out. I’m definitely loving the information. I’m book-marking
and will be tweeting this to my followers! Excellent blog and amazing style
and design.
A person necessarily help to make significantly articles I’d state.
This is the first time I frequented your web page and thus far?
I surprised with the analysis you made to make
this particular submit amazing. Great process!
This piece of writing presents clear idea in favor of the new
users of blogging, that really how to do blogging and site-building.
My brother recommended I may like this blog. He was once entirely right.
This put up truly made my day. You can not consider just
how so much time I had spent for this info!
Thanks!
We stumbled over here different website and thought I may as well
check things out. I like what I see so now i’m following you.
Look forward to going over your web page yet again.
Heya are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started
and create my own. Do you require any coding expertise to
make your own blog? Any help would be really appreciated!
I like it when people get together and share thoughts.
Great site, stick with it!
I was suggested this website by my cousin. I am not sure whether this
post is written by him as no one else know such detailed about my difficulty.
You’re wonderful! Thanks!
Hi, i think that i saw you visited my site thus i came to “return the favor”.I am attempting to find
things to enhance my site!I suppose its ok to
use a few of your ideas!!
This paragraph presents clear idea designed for the new viewers of
blogging, that really how to do running a blog.
Thanks a bunch for sharing this with all folks you really understand what you’re speaking approximately!
Bookmarked. Kindly also talk over with my site =). We
could have a link alternate contract between us
Today, I went to the beach with my children. I found a
sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed
the shell to her ear and screamed. There was a
hermit crab inside and it pinched her ear. She never wants to go
back! LoL I know this is totally off topic but
I had to tell someone!
I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it
for you? Plz respond as I’m looking to construct my
own blog and would like to find out where u got this from.
thank you
You are so interesting! I don’t think I’ve read through anything
like that before. So wonderful to discover another person with unique thoughts on this
topic. Really.. thank you for starting this up.
This web site is something that’s needed on the web, someone with a little originality!
Your style is really unique in comparison to other people
I have read stuff from. I appreciate you for posting
when you have the opportunity, Guess I will just book mark this
page.
Today, I went to the beach front with my children. I found a sea shell
and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
There was a hermit crab inside and it pinched her ear. She never wants to go back!
LoL I know this is entirely off topic but I had to tell someone!
This is really interesting, You are a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your excellent post.
Also, I’ve shared your website in my social networks!