作者godfat (godfat 真常)
看板Ruby
标题Re: [问题] Lighttpd的设定方式
时间Thu Oct 15 21:13:01 2009
最近收了一堆信,信箱整个爆,来赚 p 币买信箱... @@
: → ryudo:thin可靠吗?我没啥听说有production的站在用 10/15 18
根据我之前的经验,thin 没有 mongrel 稳,mongrel 算是经过考验的。
但是 thin 比 mongrel 快很多很多很多... 基本上我会建议用 thin,
除非你碰到不稳的问题,才考虑换 mongrel. heroku:
http://heroku.com/
rails/rack hosting, 他们的 dyno 是用 thin 去改的。
根据他们的说法是,比 mongrel 快,比 mongrel 小,比 mongrel 稳。
我自己的经验是比 mongrel 快很多很多,但其他的不见得。
另外很重要的是,mongrel 没有直接支援 rack,
启动 script 也不是很好用。这点 thin 也是大胜 mongrel.
不过我觉得这都是因为 mongrel 後来没在发展了....
如果 mongrel 继续发展,不会输 thin.
但现在我会说 mongrel 输给 thin 不少。
: → ryudo:unicorn还是第一次听到 10/15 18
这满新的,作者是 Eric Wong, 是 mogilefs-client 的作者。
程式写得相当漂亮,简洁俐落,设计则是参考 UNIX/POSIX 的作法。
很明显这不能用在 windows 上 XD
可以参考这页:
http://tomayko.com/writings/unicorn-is-unix
这边则是一些设计上的考量:
http://unicorn.bogomips.org/DESIGN.html
http://unicorn.bogomips.org/PHILOSOPHY.html
好,我知道大家都很懒,不想自己看 XD 正好我今天大概看了一下。
简单地说,unicorn 遵循 UNIX philosophy:
1. Write programs that do one thing and do it well.
2. Write programs to work together.
3. Write programs to handle text streams,
because that is a universal interface.
unicorn 不企图做到每件事,他只对付快速的 client, 不做 buffer.
所以前端会需要有一个 reverse proxy, 例如 nginx.
你要用 apache 也不是不行啦,但就我所知没什麽人在用 apache...
我指做这些事情。每个地方都在讲 apache bloat bloat bloat, slow slow slow...
memory leak leak leak... 他就只是很方便而已。
除此之外就是用 shared socket, select (or epoll?), 还有 prefork.
而慢速的 client? 用 Rainbows! 对付
http://rainbows.rubyforge.org/ 这是从 unicorn 切出来的。
我个人是觉得跟 passenger 架构有一点类似,只是 passenger 是整个包成一包,
但 unicorn 则是把最重要的核心拆出来。程式码也很少,除了 http parser 外,
全部都是 ruby 写成。http parser 是用 mongrel 的,用 ragel 写,产生 c 程式
再去 compile 的。ragel 是 parser generator, 最近应该也满流行的。
参考这篇留言:
http://github.com/blog/517-unicorn#comment_3142
Now don't get me wrong, Passenger is great. Point it at your app and
for the most part your are done. But if you need it to do something
different, it's fairly inflexible, and it's here, I think, that
Unicorn really shines.
当你想做点什麽手脚时,passenger 没有这样的空间让你动;
然而 unicorn 只有最核心的部份,而且全部是 ruby, 你随时可以改变什麽。
我觉得 unicorn 相当值得一试,虽然短时间内可能还是继续用 passenger.
原因很简单,目前我不需要对 passenger 动手脚 :p
而且针对 passenger 的 script 都写好了,没有重大问题前,也不用特别去换
但如果碰到什麽问题,我第一个决定试的肯定是 unicorn.
他没什麽新东西,都是过去已知的概念,但我个人觉得是个突破。
就像 rails 其实也没有什麽新东西,一个个看都没什麽,放在一起就厉害了。
: → ryudo:passenger for nginx有比apache版好吗? 10/15 18
核心是一样的,所以这个问题近似 nginx 有比 apache 好吗?
我会说这是肯定的。然 apache 好的地方在於他是老牌,工具很多,
文件很多,问题也都是已知的,所以你可以想办法避开。
nginx 相较之下年轻很多,一开始又只有俄国人用,英文文件很少。
不过也许他们放在一起比较是不太公平的,毕竟 apache 是万能型的,
他几乎什麽都有... nginx 也没有 mod_php, 你只能用 fast-cgi.
也有人说,如果你有 fast-cgi, 何必用 mod_php?
不过 apache mod_php 似乎做得非常好,足以跟 fast-cgi 相较,
而且用起来也比 fast-cgi 方便得多。
但跟 lighttpd 比较就很明显了。lighttpd 发展近几年太过迟缓,
nginx 又快速蓬勃发展,使用者量早已超越 lighttpd 一大截了...
小、快、稳,nginx 大概是这几个优点,可以取代 lighttpd,
但功能上并不容易取代 apache, 如果你需要很多 apache 的功能。
你要跑 php 的话可能还是用 apache 比较「方便」就是了。
否则 nginx 真的是好太多的选择。
passenger 不支援 nginx 的话,我不会考虑 passenger,
会继续使用 thin cluster (用了一阵子)
--
#!/usr/bin/env ruby [露比] /Programming (Kn|N)ight/ 看板《Ruby》
# if a
dog nailed
extra legs that
http://webptt.com/cn.aspx?n=bbs/Ruby/index.html
#
walks like an octopus, and Welcome ~
Ruby@ptt~
#
talks like an octopus, then
◢█◣ http://www.ruby-lang.org/
# we are happy to treat it as
█ http://www.ruby-doc.org/
# if it were
an octopus.
◥ ◤ http://www.rubyforge.org/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.28.18
1F:→ ryudo:要多写额外的init script是最不能接受之处 10/19 14:24
2F:→ godfat:哪一个 init script? 10/19 14:27
3F:→ ryudo:mongrel或thin要启动不是都要自己写init script? 10/19 14:40
4F:→ godfat:写 config 就可以了啊.. 10/19 14:53
5F:→ ryudo:nginx可以不用额外写mongrel cluster的init script? 10/19 15:02
6F:→ godfat:nginx+passenger就nginx config,thin/mongrel也是config可 10/19 15:34
7F:→ ryudo:nginx+php(fastcgi)的话呢? 10/19 16:29
8F:→ godfat:php 的 fast-cgi 就是另一回事了,那跟 nginx 没直接关系 10/19 16:43