Hatena's Infrastructure from the beginning
-
Upload
shinji-tanaka -
Category
Technology
-
view
4.578 -
download
3
Transcript of Hatena's Infrastructure from the beginning
![Page 1: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/1.jpg)
はてなのインフラ いまむかし
株式会社はてな 田中 慎司
![Page 2: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/2.jpg)
目次
はてなのサービスを支えるインフラ 創業時からこれまでの変遷
2001年~ 2008 年 7年の歴史 今の問題認識と将来
注 : 一部 OSC Kansaiのプレゼンとかぶってます
![Page 3: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/3.jpg)
(いまさら )
はてな紹介
![Page 4: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/4.jpg)
はてな
![Page 5: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/5.jpg)
株式会社はてな
2001年創業@京都 従業員 35 名 (+ インターン 10名 ) ウェブのサービス提供会社
人力検索 ブログ ソーシャルブックマーク
会員 80万人 1,000万UU/月 6,000万 PV/日
![Page 6: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/6.jpg)
はてなのインフラの規模
サーバ 350 → 台 仮想化して 500台 14 ラック、ピーク時 240Mbps
![Page 7: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/7.jpg)
インフラ初期2001年~ 2002年
![Page 8: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/8.jpg)
2001年当時の「はてな」
![Page 9: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/9.jpg)
サーバー構成 2001年
Pentium III の自作 PC
Apache
PostgreSQL
※ネットワーク機器は省略
Perl CGIApache
PostgreSQL
![Page 10: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/10.jpg)
→ 問題発生 解決の積み重ね
CGIでは激重 CGI → Apache::Registry に変更
mod_perlの負荷が問題に リバース Proxyの導入
1台ではリソース不足 DBを分離・MySQLに リバース Proxyとmod_perlの分離
複数サービスの立ち上げ リバース Proxyで振り分け (人力・アンテナ )
![Page 11: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/11.jpg)
アンテナ人力検索
サーバー構成 2002年
Reverse Proxy で切り分け
proxy
mod_perl
MySQL
mod_perl
MySQL
クローラ
![Page 12: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/12.jpg)
はてなの初期 (2001~ 2002)
試行錯誤により徐々に三層構造へ → フレームワークにより開発が効率化 はてなアンテナ
はてなアンテナのヒットによりサーバーが増え始める
![Page 13: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/13.jpg)
インフラ拡大期2002年後半~ 2005年
![Page 14: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/14.jpg)
サーバーケースを設計
ケースを設計、サーバーは自作 自作サーバーの利点
早い、うまい、安い 柔軟に構成変更可能
![Page 15: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/15.jpg)
アンテナ人力検索
サーバー構成 2002年終り頃
proxy
mod_perl
MySQLslave
mod_perl
MySQL#1slave
クローラ#1
クローラ#2
MySQL#2
mod_perl
MySQLmaster
MySQLslave
MySQLmaster
MySQL#1slave
![Page 16: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/16.jpg)
2003年 3 月 はてなダイアリー
![Page 17: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/17.jpg)
はてなダイアリーのバックエンド
過去の反省を活かしたテーブル設計 開始当初からパーティショニング
サーバー増加ペースも増加 2004年頭には 50台規模
![Page 18: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/18.jpg)
当時のネットワーク図
![Page 19: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/19.jpg)
2004年 2 月 東京へ移転
サービスを一日停止してトラックで運搬 当時のサーバー台数 : 50台
![Page 20: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/20.jpg)
サーバー構成 2004年
mod_proxy_balancer の導入 フェイルオーバー /バック
Apache 2.2mod_proxy_balancer
mod_perl mod_perl mod_perl mod_perl
![Page 21: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/21.jpg)
2005 年 サービスリリースラッシュ 2 月 はてなブックマーク
2泊 3日の合宿で開発
サーバーは 200台規模へ 5 月 はてな RSS 7 月 はてなマップ , はてなグラフ 11 月 はてなリング 翌年 3 月 人力検索はてなリニューアル
![Page 22: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/22.jpg)
当時の運用の問題点
SPOF多数 まともにフェイルオーバーしていたのは
mod_proxy_balancer のみ Reverse Proxy 多数のMySQLスレーブ群 Nagios → → で監視 ダウン 人力で対応
回線飽和 ベストエフォート 100Mbps 回線 太い商用回線を借りる程のお金が無い
電力不足 増え続けるサーバーに対する電力不足
![Page 23: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/23.jpg)
はてなインフラ 2.0 (C)id:naoya
2006年後半~ 2007年
![Page 24: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/24.jpg)
2006 年夏 KLabさんとの出会い
DSAS オープンソースで完璧な可用性 " こんなに簡単! Linuxでロードバランサ "
![Page 25: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/25.jpg)
LVS (IPVS) + keeplived
ipvs + keepalived#1
Real Server#1 Real Server#2 Real Serve#3
ipvs + keepalived#2
VRRPACTIVE BACKUP
TCP CHECK
Linux でロードバランサ
![Page 26: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/26.jpg)
サーバー構成 2006年 9月
MySQL の手前に LVS を導入
LVS#1
mod_perl mod_perl mod_perl
LVS#2
MySQL MySQL MySQL
ACTIVE BACKUPVRRP
ヘルスチェック
![Page 27: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/27.jpg)
LVSの導入効果
多数の SPOFが解消される Reverse Proxy MySQL サーバー群 mod_proxy_balancer の不安定部分
運用の効率化 アプリケーション担当とインフラ担当の仕事の分離が可能に
![Page 28: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/28.jpg)
2007年 1 月 さくらインターネットiDCへ DC分の収益は確保できるまでに成長 電力、場所、回線問題を解決 一年がかりのプロジェクト
サービス単位で数回に分ける
![Page 29: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/29.jpg)
データセンター移転に伴い
インフラチームを発足、体制強化 最終的に 6 名 (アルバイト 2名 )
ちなみに、私もこのあたりで加入しました
基幹ネットワークを全面的に設計し直し LVS + KeepAlived の積極導入
古いサーバーをリプレイス OS を CentOS へ刷新 / 64ビット化
![Page 30: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/30.jpg)
移転プロジェクトの変遷
2007年 1 月 新DCオープン 2007年 2 月 フォトライフ 2007年 4 月 グループ 2007年 5 月 ブックマーク 2007年 6 月 ダイアリー 2007年 7 月 アンテナ 2007年 8 月 RSS 2007年 9 月 人力検索、ポータル 2007年 11 月 アンテナ、カウンター、検索
![Page 31: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/31.jpg)
サーバー構成 2007 年半ば LVS三層
proxy proxy
LVS
LVS
mod_perl mod_perl mod_perl mod_perl
LVS
MySQLl MySQL
LVS
LVS
LVS
![Page 32: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/32.jpg)
一部商用サーバーの利用
故障後のリカバリが面倒な箇所を商用に DB マスタや LVS など基幹部分
![Page 33: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/33.jpg)
64bit の追い風
メモリ 4GB の壁を突破 8GB, 16GB ...
DB のデータの大部分を OS がキャッシュできる
メモリ増設で I/O 負荷を下げられる テーブル分割の必要性が下がる
MySQL Conference 2007の YouTubeのKeynoteが参考になった
![Page 34: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/34.jpg)
マルチマスタ化
MySQL MySQL
MySQL マスタが SPOF
お互いに互いのスレーブの関係 ACTIVE - BACKUP Keepalived で切り替え
MySQLslave
MySQLmaster
MySQLslave
![Page 35: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/35.jpg)
2008年 1 月 DC移転完了
![Page 36: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/36.jpg)
インフラ 2.0 (C) id:naoyaができるまで
はてなインフラのターニングポイント KLab さんに感謝
チーム体制で役割分担 DC移転タイミングでの再設計 オープンソースでも高可用インフラ
LVS, KeepAlived, DRBD, Squid etc.
![Page 37: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/37.jpg)
はてなのインフラの今2008年 8月
![Page 38: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/38.jpg)
「守り」から「攻め」へ
インフラが強い = 企業の強み・足腰 サービス開発との両輪
![Page 39: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/39.jpg)
仮想化技術の導入
Xen 1 台のハードウェアで複数の OS 現在 500 ホスト中 150 ホストが仮想ホスト
idle 時間が多いサーバーは集約 任意のタイミングで仮想ホストを別ハードに移動させることが可能に (高価&不安定な )ネットワークストレージは使用せず
![Page 40: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/40.jpg)
Xen でディスクレスサーバ-
仮想ホストをディスクレスサーバーで 中央のファイルサーバから OS のイメー
ジを取得して boot ファイルサーバから独立 オンメモリで動作 一部で稼働中
![Page 41: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/41.jpg)
Hadoop の導入
Google の MapReduce の OSS 版 分散ファイルシステム 並列計算クラスタ
用途 ログ解析 →データ分析 インデクシング
![Page 42: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/42.jpg)
サーバー管理ツール
サーバーホストの情報管理 ホスト情報はサーバーから自動取得
負荷状況調査 他ツールと連携
Nagios 設定ファイル Capistrano のデプロイ先 社内 IRC サーバ
![Page 43: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/43.jpg)
サーバーのセットアップの簡略化
OSの自動インストールシステム PXE Boot でインストール
Puppet はてな内 RPMレポジトリ
Perl モジュール、カスタマイズしたソフト、自社ライブラリ
Capistrano Subversion, gitからデプロイ
Selenium で自動テスト ... は未だできていません
![Page 44: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/44.jpg)
はてなのインフラ 4つのフェーズ
インフラ初期 2001年~ 2002 年 試行錯誤 Web + DB 三層構造、フレームワーク
インフラ拡大期 2002年後半~ 2005年 自作サーバ、負荷分散 ...
はてなインフラ 2.0(C)id:naoya 2006年後半~2007年
チーム化と可用性確保 LVS、DRBD、DC 移転 ...
はてなインフラの今 2008年 8月 Xen、Hadoop 、サーバー管理ツール ...
![Page 45: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/45.jpg)
はてなのインフラ課題と将来
![Page 46: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/46.jpg)
課題認識
求められるインフラとしてのレベル 様々なトレードオフ
まだまだ不安定 頻度は低下したものの、まだまだ急所がある
日々追加される機能 (バグ ) 微妙に壊れるハード・ソフト
実際、 DSASはとにかくはてなの 24/7レベルは私にはとても合格点を出せない (しなもん会長の面を見過
ぎや )
404 Blog Not Found:DIY 24/7 - 書評 - [24時間 365日 ]サーバ /インフラを支える技術
![Page 47: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/47.jpg)
インフラに求められるレベル
社会インフラ度
日々の変化
電気・電話
交通・金融
オンラインバンキングなど
はてな
![Page 48: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/48.jpg)
インフラのトレードオフ
安い頻繁な機能追加対症療法
限界まで使う
信頼できるバグが少ない根本的な対策余裕がある
インフラとして求めれられるレベル・投入可能なリソースなどなど
から適切な方策を選んでいく
![Page 49: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/49.jpg)
より強固なインフラを目指して
被害を局所化 アプリケーションの疎結合化 自動的なリカバリ 転んでもすぐ起きる
自律的なインフラ 負荷がキツくなったら、勝手に増殖
でも、できるだけコストをかけずに 人手ではなく、頭を使って仕組みでカバー
![Page 50: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/50.jpg)
まとめ
はてなのインフラの変遷を紹介しました 試行錯誤の歴史です
これからも新しい仕組みを投入していきます
インフラの仕事はとてもクリエイティブです !
根性論には否定的です
Googleの初期のインフラ
![Page 51: Hatena's Infrastructure from the beginning](https://reader036.fdocuments.net/reader036/viewer/2022070317/5566133cd8b42a06318b4da9/html5/thumbnails/51.jpg)
ご静聴ありがとうございました
@京都・東京