Successfully reported this slideshow.
Your SlideShare is downloading. ×

Amazon ElastiCache(初心者向け 超速マスター編)JAWSUG大阪

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Amazon ElastiCache
しみず @shimy_net
2013 / 6 / 22初心者向け 超速マスター編
自己紹介
しみず @shimy_net
Webアーキテクト
アマゾン芸人
無駄に技術を使って
面白いことをする
本を執筆しました
http://goo.gl/QtaK6

YouTube videos are no longer supported on SlideShare

View original on YouTube

Loading in …3
×

Check these out next

1 of 32 Ad

More Related Content

Slideshows for you (20)

Similar to Amazon ElastiCache(初心者向け 超速マスター編)JAWSUG大阪 (20)

Advertisement

More from 崇之 清水 (20)

Recently uploaded (20)

Advertisement

Amazon ElastiCache(初心者向け 超速マスター編)JAWSUG大阪

  1. 1. Amazon ElastiCache しみず @shimy_net 2013 / 6 / 22初心者向け 超速マスター編
  2. 2. 自己紹介 しみず @shimy_net Webアーキテクト アマゾン芸人 無駄に技術を使って 面白いことをする
  3. 3. 本を執筆しました http://goo.gl/QtaK6
  4. 4. Amazon ElastiCache とは □ KVSキャッシュサービス ・memcached 1.4.5 互換 ・クラスタ構成、Auto-Discovery(Java, PHPクライアント提供) ・スケールイン/スケールアウト □ インストール・構築不要 ・AWS Management Console 、CLI または API からアクセス ・プロビジョニング、ソフトウェアのインストールや管理が不要 ・ソフトウェアの自動パッチ適用 ・インスタンスタイプを選択可能 □ 自動障害検出と復旧 ・キャッシュクラスタの状態を監視 ・CloudWatch、SNS と連携
  5. 5. まずはキャッシュを検索 ヒットしなければDBを検索 Amazon ElastiCache とは □ 目的と用途 ・アプリの高速化、データベースの負荷低減 ・セッションの管理 get(Key) Value select Value set(Key, Value) APP DB データ取得シーケンス
  6. 6. Amazon ElastiCache とは □ 構成 EC2 InstanceElastic Load Balancing Instance Cache Cluster Cache node Cache node CacheSecurityGroup Cache Parameter Group EC2SecurityGroup Cloud Watch
  7. 7. 開発・管理ツール □ AWS Management Console(Webブラウザ) □ Amazon ElastiCache Command Line Tools →http://aws.amazon.com/code/2310261897259567 □ AWS SDK for XXXX
  8. 8. やること □ Management Console から利用する ・Cache Cluster を作成 ・デプロイ方法 ・バージョン管理 ・新しい環境を作成する □ Eclipse から利用する(Java) ・デモンストレーション
  9. 9. Management Console から利用 ① ここからスタート ② ElastiCache を選択
  10. 10. Cache Cluster の作成 ③ Launch Cache Cluster をクリック
  11. 11. Cache Cluster の作成 ④ Cluster名 を指定 ⑤ インスタンスタイプ  を指定 ⑥ ノード数 を指定 ⑧ SNS による通知を指定 ⑦ AZ を指定 ※Multi-AZはできない
  12. 12. Cache Cluster の作成 ⑨ Security Group を選択 ※defaultを選択 ⑩ Parameter Group を指定
  13. 13. Cache Cluster の作成 ⑪ 完了
  14. 14. Endpoint の確認 Configuration Endpoint Node EndpointNode Endpoint
  15. 15. Endpoint の確認 □ Configuration Endpoint   AWSが提供する拡張クライアントから Auto Discovery で透過的に接続する □ Node Endpoint   各ノードに接続する node1 node2 Node1 Endpoint Node2 Endpoint ConfigurationEndpoint ElastiCache Cluster Client Node1 Endpoint Memcached Client node1
  16. 16. 分散ロジック Auto Discovery とは □ 分散するには Sharding や Consistent Hashing といった処理が必要 Cache ClusterApplication App Memcached Client node1 XXX node2 YYY node3 ZZZ get(Key) Value node1 node2 node3 node4 ノードが増えると リストを更新する必要がある ノードが増えると リストを更新する必要がある
  17. 17. Auto Discovery とは □ Auto Discovery でノード情報を自動取得 Cache ClusterApplication App ElastiCache Cluster Client get(Key) Value node1 node2 node3 node4 new Client() client configuration endpoint でクライアントを生成 node1, node2, node3 Resolve configuration endpoint Get cluster endpoints Polling Refresh nodes once per minute Consistent Hashing Memcached Protocol の拡張
  18. 18. Auto Discovery とは(原文) Connecting to Cache Nodes 1.  The application resolves the configuration endpoint's DNS name. Because the configuration endpoint maintains CNAME entries for all of the cache nodes, the DNS name resolves to one of the nodes; the client can then connect to that node. 2.  The client requests the configuration information for all of the other nodes. Since each node maintains configuration information for all of the nodes in the cluster, any node can pass configuration information to the client upon request. 3.  The client receives the current list of cache node hostnames and IP addresses. It can then connect to all of the other nodes in the cluster. Normal Cluster Operations 1.  The application issues a get request for a particular data item, identified by its key. 2.  The client uses a hashing algorithm against the key to determine which cache node contains the data item. 3.  The data item is requested from the appropriate node. 4.  The data item is returned to the application.
  19. 19. ElastiCache Cluster Client のダウンロード ① Download ElastiCache Cluster Client をクリック ② Download をクリック 提供クライアント一覧 Java PHP 5.3 (64bit Linux) PHP 5.3 (32bit Linux) PHP 5.4 (64bit Linux) PHP 5.4 (32bit Linux)
  20. 20. Cache Security Group の設定 □ Cache Security Group のため接続できない Cache Cluster Cache Parameter Group node1 node2 EC2 EC2SecurityGroup Node1 Endpoint Node2 Endpoint ConfigurationEndpoint CacheSecurityGroup Instance 接続できない接続できない
  21. 21. Cache Security Group の設定 □ EC2 Security Group を許可するように設定を変更する Cache Cluster Cache Parameter Group node1 node2 EC2 EC2SecurityGroup Node1 Endpoint Node2 Endpoint ConfigurationEndpoint CacheSecurityGroup Instance 設定を変更
  22. 22. Cache Security Group の設定 ③ Add をクリック ② 接続を許可したい EC2 Security Group を選択する ① Cache Security Group  をクリック 前項では defaultというSecurity Group を指定して Cache Cluster を作成しました
  23. 23. Cache Parameter Group の設定 □ パラメータ一覧 Cache Cluster node1 node2 Cache Parameter Group name value cas_disabled On/Off chunk_size 1-1024 chunk_size_growth_factor 1.01-100.00 error_on_memory_exhausted On/Off max_item_size 1024-134217728 maxconns_fast On/Off memcached_connections_over head 0-100000 slab_automove 0-2 slab_reassign On/Off
  24. 24. Cache Parameter Group の設定 ③ Edit Parameters をクリック ② Cache Parameter Group の1つを選択 ① Cache Parameter Group  をクリック デフォルトパラメータは 設定の変更ができない
  25. 25. Cache Parameter Group の設定 ④ 完了
  26. 26. Cache Cluster に接続 □ サンプルコード package com.amazon.elasticache; import java.io.IOException; import java.net.InetSocketAddress; import net.spy.memcached.MemcachedClient; public class AutoDiscoveryDemo { public static void main(String[] args) throws IOException { String configEndpoint = xxx.yyy.cfg.use1.cache.amazonaws.com"; Integer clusterPort = 11211; MemcachedClient client = new MemcachedClient( new InetSocketAddress(configEndpoint, clusterPort)); client.set( Key", 3600, Value"); client.get( Key ); } } Javaの例
  27. 27. やること □ Management Console から利用する ・Cache Cluster を作成 ・デプロイ方法 ・バージョン管理 ・新しい環境を作成する □ Eclipse から利用する(Java) ・デモンストレーション
  28. 28. デモンストレーション □ 利用ツール ・Eclipse 4.2 ・Seasar2   http://eclipse.seasar.org/updates/3.3/ ・AWS Toolkit for Eclipse   http://aws.amazon.com/jp/eclipse/ ・Sequel Pro 1.0.2
  29. 29. デモンストレーション □ 構成図 Auto scaling Group InstanceElastic Load Balancing CloudWatch AWS Elastic Beanstalk S3 Amazon SNS Availability Zone RDS DB Instance Instance war Eclipse デプロイ xxxx.elasticbeanstalk.com?id=1 1, YAMADA パラメータで渡し たidに対応するレ コードを表示する ID NAME 1  YAMADA 2  SUZUKI 3  MIZUNO
  30. 30. デモンストレーション □ 構成図 Auto scaling Group InstanceElastic Load Balancing CloudWatch AWS Elastic Beanstalk S3 Amazon SNS Availability Zone RDS DB Instance Availability Zone Instance ElastiCache war Eclipse デプロイ xxxx.elasticbeanstalk.com?id=1 1, YAMADA パラメータで渡し たidに対応するレ コードを表示する ID NAME 1  YAMADA 2  SUZUKI 3  MIZUNO
  31. 31. !     以上! ありがとうございました!

×