search solutions on aws
TRANSCRIPT
![Page 1: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/1.jpg)
Search Solutionson AWS
![Page 2: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/2.jpg)
Name• Eiji Shinohara / 篠原 英治
Social • Twitter: @shinodogg• Blog: https://shinodogg.com
AWS Solutions Architect• Area of Depth
• AWS Search Services• Digital Advertising Technology
![Page 3: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/3.jpg)
AWSの検索サービス• Amazon CloudSearch
• https://aws.amazon.com/jp/cloudsearch/
• Amazon Elasticsearch Service• https://aws.amazon.com/jp/elasticsearch-service/
Amazon CloudSearch Amazon Elasticsearch Service
![Page 4: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/4.jpg)
A9.com → The team joins AWS• CloudSearch/Amazon ES の開発拠点はパロアルト
![Page 5: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/5.jpg)
Amazon CloudSearch• ⾃動拡張するフルマネージド検索サービス• 2011 API• A9が作ったプロプライエタリな検索エンジン• Amazon.comで使っているもの• 東京リージョンは対象外
• 2013 API• on top of Apache Solr• 多⾔語対応• ⽇本語の形態素解析、n-gram、カスタム辞書にも対応
• 東京リージョンは2014年3⽉からサービス提供中
![Page 6: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/6.jpg)
Amazon CloudSearch• Auto Scaling / Auto Partitining
Auto Partitioning
Auto Scaling
![Page 7: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/7.jpg)
Amazon Elasticsearch Service• Elasticsearchのマネージドサービス• AWSクラウド上で Elasticsearch を簡単に構築可能• Elasticsearchの分散/スケーリング機能はクラウドと相性が良い• インスタンスタイプと台数を選択するだけでプロビジョニング
• デフォルトでKibanaがインストールされる• Management ConsoleにてURLをクリックするだけで直ぐ利⽤可能
• 使った分だけの従量課⾦• ノードに利⽤するEC2の時間課⾦• EBSボリュームを使った場合はEBSの料⾦
•略称はAmazon ES
![Page 8: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/8.jpg)
AWS Podcast•Episode #145 | September 5, 2016• Jon Handler: Principal Search Services Solutions Architect• Elasticsearchとは?• Elasticsearchのどういうところが良い?• Amazon Elasticsearch Serviceとは?• Eliminate undifferenciated heavy lifting• Easy to manage, operate, and scale• Security• Monitoring• Just a few clicks to deploy
![Page 9: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/9.jpg)
AWS re:Invent 2016•Real-Time Data Exploration and Analytics with Amazon Elasticsearch Service and Kibana(BDM302)
https://www.youtube.com/watch?v=R40N9eZTaAA
![Page 10: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/10.jpg)
AWS re:Invent 2016•Real-Time Data Exploration and Analytics with Amazon Elasticsearch Service and Kibana(BDM302)• Apacheのログを使ってend-to-endでログ解析する⽅法を紹介• Amazon Kinesis Firehoseを使ってAmazon ESクラスタにデータを投⼊• インスタンスタイプ, ストレージオプション, shard数, インデックスのローテーション等のベスト・プラクティスを紹介• Kibanaのセットアップおよびカスタムダッシュボードウィジェットの作成⽅法• Deep Dive: Elasticsearch Query DSLやcustom/ad-hocレポートの⽣成⽅法の紹介 等
![Page 11: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/11.jpg)
テラバイト級のログデータをどうしていますか?
![Page 12: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/12.jpg)
今回のセッションでは以下のような構成をご紹介します
data source Amazon Kinesis Firehose Amazon Elasticsearch Service
Kibana
123 4
Query DSL5
![Page 13: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/13.jpg)
構築したアウトプットのイメージ
![Page 14: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/14.jpg)
Shard 1 Shard 2 Shard 3 Shard 4
index は document の集合。各ドキュメントは分割された shard に配置されます
Documents
Index
ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID
...
Indexing, compression
![Page 15: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/15.jpg)
index のクラスタへのデプロイメント
• Index 1– Shard 1– Shard 2– Shard 3
• Index 2– Shard 1– Shard 2– Shard 3
Amazon ES cluster
123
123
123
123
Primary Replica
1
3
3
1
Instance 1,Master
2
1
1
2
Instance 2
3
2
2
3
Instance 3
![Page 16: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/16.jpg)
How many instances?• index のサイズは、元の document の集合と同じになる場合が多い ※トークナイズの⽅法等にもよる• Indexを複製する場合は倍のサイズ
• ストレージのサイジング• ローカルのエフェメラルディスク、もしくは、インスタンスごとに512GBのAmazon Elastic Block Store(EBS)を選択
• 例: 2TBの元データの⽬安• 512GBのEBSでIndexを複製する場合は8インスタンス• i2.2xlargeのインデックスタイプを選択する場合はローカルのエフェメラルディスクを使えば4ノードでも事⾜りる → カジュアルな⽤途向き
![Page 17: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/17.jpg)
dedicated master ノードがないクラスタ
Amazon ES cluster
1
3
3
1
Instance 1,Master
2
1
1
2
Instance 2
3
2
2
3
Instance 3
![Page 18: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/18.jpg)
dedicated masterノードのあるクラスタ
Amazon ES cluster
1
3
3
1
Instance 1
2
1
1
2
Instance 2
3
2
2
3
Instance 3Dedicated master nodesData nodes: queries and updates
![Page 19: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/19.jpg)
Zone awareness を有効にした場合のクラスタ
Amazon ES cluster
1
3
Instance 1
2
1 2
Instance 2
3
2
1
Instance 3
Availability Zone 1 Availability Zone 2
2
1
Instance 4
3
3
![Page 20: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/20.jpg)
Amazon ES クラスタ構築のベストプラクティス
• Data nodes の数 = 必要なストレージ量 / ノード毎のストレージ• GP2 EBS volume の活⽤• 本番環境には 3 dedicated master ノード• Zone Awareness の有効化
![Page 21: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/21.jpg)
Amazon Elasticsearch Service overview
Amazon Route 53
Elastic LoadBalancingAWS
IAM
Amazon CloudWatch
Elasticsearch API
AWS CloudTrail
![Page 22: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/22.jpg)
Amazon Elasticsearch Service を使う利点
Easy to use
Open-source compatible
Secure
Highly available
AWS integrated
Scalable
![Page 23: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/23.jpg)
Kinesis Firehose
![Page 24: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/24.jpg)
Kinesis Firehose overview• Delivery Stream:
AWSのリソースを活⽤
• Destination:Amazon RedshiftAmazon S3Amazon ES
• Record:レコードをストリームにプッシュ設定したデスティネーションにデータをお届け
![Page 25: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/25.jpg)
Kinesis Firehose の デリバリーアーキテクチャ
intermediate Amazon S3 bucket
backup S3 bucket
source records
data sourcesource records
Amazon Elasticsearch
Service
Firehosedelivery stream
delivery
![Page 26: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/26.jpg)
[Coming soon!]Kinensis Firehose のデリバリーアーキテクチャwith transformations
intermediate Amazon S3
bucket
backup S3 bucket
source records
data source
source records
Amazon Elasticsearch
Service
Firehosedelivery stream transformed
records transformedrecords
transformation failuredelivery failure
※指定したLambda Functionで変換
![Page 27: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/27.jpg)
Kinesis Firehose features for ingest
Serverless scale Error handling S3 Backup
![Page 28: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/28.jpg)
Kinesis Firehose stream の作成
![Page 29: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/29.jpg)
Kinesis Firehose の ベストプラクティス• レイテンシーとトータルなスループットのバランスでbuffer sizeを決めるスループットを上げるには⼩さいbuffer sizeが有利だが、コンカレンシーに注意が必要
• index をローテーションさせるよくあるのは Daily でのローテーション
• デフォルトのストリームの制限stream limits: 2,000 transactions/second5,000 records/second, and 5 MB/second
![Page 30: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/30.jpg)
template および data のアップロード
![Page 31: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/31.jpg)
Shard数 = index サイズ / 各ノードのサイズindex を作成する際にShard数を設定
It dependsであるし、議論があるところではあるが”Less is more”
Write:該当ShardのノードのCPUを使う
Read:全てのShardのノードのCPUを使う
同時並⾏で複数のShardに多数の書き込むを⾏う場合は、クラスタ全体のCPUリソースを考慮すること
Amazon ES cluster
1
3
3
1
Instance 1,Master
2
1
1
2
Instance 2
3
2
2
3
Instance 3
![Page 32: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/32.jpg)
Mapping でデータのインデクシングをコントロール
• Kibanaを使った可視化は”not_analyzed”なテキストで良い
例えば、IPアドレスはドットで分割する必要ない
• Mappingのテンプレートは_template APIを使って定義
全ての新しいインデックスに適⽤される
• テンプレートはShard数の設定にも⽤いる
0 delete 1,3,51 get 2,3,4,62 head 1,7,93 post 2,84 put 24
IndexWriter
![Page 33: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/33.jpg)
Log データを検索ドキュメントに変換d104.aa.net - - [01/Jul/1995:00:00:15 -0400] "GET /images/KSC-logosmall.gifHTTP/1.0" 200 1204
{"status": 200, "ident": "-", "@timestamp": "1995-07-01T00:00:05", "request": "/images/KSC-logosmall.gif HTTP/1.0", "auth": "-", "host": "d104.aa.net", "verb": "GET", "time": "01/Jul/1995:00:00:15 -0400", "size": 1204}
![Page 34: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/34.jpg)
send_data メソッド
![Page 35: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/35.jpg)
Kinesis FirehoseへのLogデータ送信
![Page 36: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/36.jpg)
Kinesis FirehoseへのLogデータ送信のベストプラクティス• セッティング⽤にテンプレートを使う• Shard数を設定する• 1つのノードに1つのアクティブなshard• 可視化のユースケースでは全てのフィールドは”not_analyzed“で良い
![Page 37: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/37.jpg)
Analyze Apache Web Logs
![Page 38: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/38.jpg)
Amazon ES aggregations
• Buckets – ドキュメントをグループ化する際の項⽬•Metrics – 集計後のBucketsのデータ
Bucket: time
Met
ric:
coun
t
![Page 39: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/39.jpg)
Kibanaで可視化する際のベストプラクティス
• フィールドが not_analyzed であること
• 可視化はbucketsおよびmetricsベース
• Data Histogramには最初に x-axis を選択
![Page 40: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/40.jpg)
Run Elasticsearch in the AWS cloud with Amazon Elasticsearch Service
Use Kinesis Firehose to ingest data simply
Kibana for monitoring, Elasticsearch queries for deeper analysisAmazon
Elasticsearch Service
![Page 41: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/41.jpg)
Lucene/Solr Revolution 2016• PlayStation and Lucene - Indexing 1M documents per second
Alexander Filipchik, Sony Interactive Entertainment
http://www.slideshare.net/lucidworks/playstation-and-lucene-indexing-1m-documents-per-second-presented-by-alexander-filipchik-sony-interactive-entertainment
![Page 42: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/42.jpg)
Lucene/Solr Revolution 2016• SearchHub - LucidWorks Fusion: Solr & Spark
http://www.slideshare.net/lucidworks/searchhub-how-to-spend-your-summer-keeping-it-real-presented-by-grant-ingersoll-lucidworks
![Page 43: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/43.jpg)
Elastic{on} TOUR 東京2016• Elasticsearch 5 / Kibana 5• 2016年12⽉15⽇• 私は抽選の結果、⾒送りで参加できない為、是⾮シェアやフィードバックを〜
https://www.elastic.co/jp/elasticon/tour/2016/tokyo
![Page 44: Search Solutions on AWS](https://reader031.vdocuments.pub/reader031/viewer/2022020301/586f85f51a28ab54768b5355/html5/thumbnails/44.jpg)