HAProxyの最大接続数設定はコンフィグファイル+αが必要だった罠
コンフィグファイルのmaxconn設定してるのに
HAProxyの接続数が頭打ちになるわ〜、ぼやいていたところ、
id:sfujiwaraさんから以下のような回答をいただきました。
HAProxyの接続数が頭打ちになるのはなんでじゃろ。ulimit/maxconnは設定してるんだけど
@toritori0318 何接続ぐらいですか?
@fujiwara 2000くらいですかね。ちなみにwebsocketで常時接続です
2012-05-02 13:48:44 via Echofon to @fujiwara
@toritori0318 ソースみたら #define DEFAULT_MAXCONN 2000 というのがありましたが、maxconnの設定が効いていないんでしょうか
@fujiwara おおなるほど。設定のしかたが悪いのかなあ?ちょっと見なおしてみます。ありがとうございます!
2012-05-02 13:52:52 via Echofon to @fujiwara
@toritori0318 defaults.h にこんなコメントが > The only way to override this limit will be to set it via the command-line '-n' argument
あなたが神か…!*1
helpを確認。
Usage : haproxy [-f <cfgfile>]* [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ] [ -p <pidfile> ] [ -m <max megs> ] -v displays version ; -vv shows known build options. -d enters debug mode ; -db only disables background mode. -V enters verbose mode (disables quiet mode) -D goes daemon -q quiet mode : don't display messages -c check mode : only check config files and exit -n sets the maximum total # of connections (2000) -m limits the usable amount of memory (in MB) -N sets the default, per-proxy maximum # of connections (2000) -p writes pids of all children to this file -de disables epoll() usage even when available -ds disables speculative epoll() usage even when available -dp disables poll() usage even when available -sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.
今回の場合だと 「-n」 と 「-N」 を両方指定したところ
想定通りの接続数まで行きました。
しかしこれ、コンフィグファイルのmaxconnだけ設定すれば良いと
勘違いしてる人いるんじゃないかなー?
わりと罠な気がする。
本日の教訓
ソース嫁。
*1:何回目だw