Site Reliability Engineering チームの Engineering Manager 尾形(@nobu666)です。10月11日から13日の 3日間、 Las Vegas で開催された Akamai Edge Conference 2017 に弊社の自主渡航奨励制度を利用して参加してきました。自主渡航奨励制度については後ほど説明させていただきます。

Akamai とは

そもそも Akamai って一体何だという方もいるかもしれないので簡単に説明しますと、Akamai Technologies という、ウェブサイトの閲覧を高速化したり、サーバの負荷を軽減するためのソリューションを主に提供している会社です。CDN(Contents Delivery Network) と言われています。世界のあらゆるところにコンテンツをキャッシュするサーバを配置し(その数はどんどん増え続けており、今は23万台を超えているそうです)、インターネット全体の通信の 15-30% を Akamai が支えているとも言われています。 SmartNews でも多くのコンテンツを Akamai のネットワークを通して配信しています。

Akamai Edge Conference 2017

Las Vegas というと、つい最近痛ましい事件が起きたことはみなさん記憶に新しいと思います。このタイミングで Las Vegas に行くのか!? という思いももちろんありましたが、実際に行ってみるとそれは杞憂でした。街の至る所に #VegasStrong というメッセージが出ており、その一点を除いてはまるで事件の影響を感じさせない活気に満ちていました。

さて肝心の Conference ですが、3日間で非常に多くの Session があり、それら一つ一つ紹介していくと大変なことになってしまうため、ざっとまとめだけ書こうと思います。

  • Akamai の注力していくこと
    • IoT
    • 今や車ですらインターネットに接続している
    • 自動車メーカーに特化した over-the-air technology を推進していく
      • ファームウェアの配信、Wi-Fi や携帯電話経由で車両へのナビゲーションや様々な情報を提供する。たとえば渋滞情報だったり天気の情報だったりをやり取りすることで、自動運転の制御にも役に立つ
    • セキュリティ
    • DDoS の規模は拡大の一途をたどっている
    • Bot管理
    • ここでいう bot とは悪意のある自動ログイン試行とかスクレイパーを指します
    • 要はこちらもセキュリティの一環
    • Mobile SDK を使用することで、スワイプやスクロールの仕方、端末の傾きなどからかなり正確に bot 判定可能だというデモをやっていました
    • モバイルアプリのパフォーマンス
    • 画像配信最適化
    • 人間が見ても劣化がわからないちょうどいいところを狙って、動的にサイズの最適化をしているようです
    • 4K VR/AR エンコーディングと配信
    • キーノートで動画のキャッシュをクライアント側で P2P でやり取りするデモをやっていて、これはかなり効果の高そうな印象を受けました
  • DevOps
    • 少し前からこういうサイトが作られており、OSS で CLI 作り始めたり、 Terraform / Varnish / Wordpress の integration を提供したりし始めています
    • 今更感がなくはないですが、ようやく Infrastructure as Code な感じが見えてきて個人的にはかなり嬉しいです。Luna ポータルからポチポチするお仕事にお疲れの方は試してみると良いと思います
    • しかしながら CLI のレスポンスが、進捗状況を表すテキストのあとに JSON が返ってきたりして、まだカオスな印象です(現地で担当の方に直接お伝えしたので、きっとそのうち修正される…と思います)
  • 登壇する Akamai 以外の会社は、既にサービスをグローバル展開しているような規模のとても大きなところであったり、一時的にでもサービス中断が起きると致命的な分野のところが多い印象を受けました
    • そういうこともあってか、 Security / DR / Reliability に関する Session が多いように思いました。いくつかこの手の Session を聞きましたが、ガチでやるのは弊社にはまだ早い…という感想です。
  • 上述したように最近 DevOps 推しですので、それに関する Session も多かったです。しかしながら、どちらかというと「スーツ向け」な内容のものが殆どであり、少々残念でした
  • いろいろな Session で Cloudlets (Akamai の Edge Server 上で何らかのコードを実行させる仕組み) を活用した事例が紹介されており、弊社では今まったく使っていないのですが、想像していたより使いみちがありそうかと思いました
    • うまく使えば Canary release を Akamai だけで制御できたりするっぽい(具体的に踏み込んだ話はなかったです)
    • AWS を multi region で運用して Cloudlets の ALB と GeoIP を組み合わせ、region まるごとダウンしてもユーザー影響がないようにするという仕組みを紹介しているところがありました

akamai-cli

さて、割りとできたばかりの akamai-cli ですが、せっかくなので少しいじってみます。

準備

macOS の場合は brew で入れるのが手っ取り早いです。

$ brew install akamai
==> Downloading https://homebrew.bintray.com/bottles/akamai-0.4.1.sierra.bottle.tar.gz
Already downloaded: /Users/nobu666/Library/Caches/Homebrew/akamai-0.4.1.sierra.bottle.tar.gz
==> Pouring akamai-0.4.1.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/akamai/0.4.1: 5 files, 12MB
$ akamai help
Usage:
  akamai [global flags] command [command flags] [arguments...]

Built-In Commands:
  help
  list
  install
  uninstall
  update

Global Flags:
   --version, -v  print the version

Copyright (C) Akamai Technologies, Inc

使うには事前に Luna で Client を作っておく必要があります。今回は Property Manager の READ/WRITE をつけた Client を作成し、表示された token をコピーして ~/.edgerc を作成しました。以下のような感じです。

$ cat ~/.edgerc
[default]
host = akab-xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxx.luna.akamaiapis.net
client_token = akab-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
access_token = akab-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

akamai コマンド単体では何もできないので、必要なコマンドを plugin します。今回は Property Manager のコマンドを入れます。

$ akamai install property
Attempting to fetch command from https://github.com/akamai/cli-property.git...... [OK]
Installing...... [OK]
Available Commands:

  help
    Displays help information
  list
    Displays available commands
  install
    Fetch and install packages from a Git repository.
  uninstall
    Uninstall package containing <command>
  update
    Update one or more commands. If no command is specified, all commands are updated
  property
    Manage configurations for Akamai properties

See "akamai help [command]" for details.

Property

では Property を持ってきてみます。

$ akamai property retrieve --section default --propver 3 ogata-test --file /tmp/ogata-test
Retrieving ogata-test
... retrieved rules formats: 1277.969ms
... searching propertyName for ogata-test
... getting info for prp_300844
Retrieving ogata-test v3
... retrieving property (ogata-test) v3
... retrieving: 2761.439ms
Writing ogata-test rules to /tmp/ogata-test
$ cat /tmp/ogata-test
{
  "accountId": "act_F-AC-xxxxxxx",
  "contractId": "ctr_3-xxxxxx",
  "groupId": "grp_62179",
  "propertyId": "prp_300844",
  "propertyName": "ogata-test",
  "propertyVersion": 3,
  "etag": "3db43b7f491ea88eae444294ed4bf7c647406e9c",
  "rules": {
    "name": "default",
<snip>
  "ruleFormat": "latest"
}

JSON を編集して Cache の TTL を 変更して更新します。

$ diff -u /tmp/ogata-test.org /tmp/ogata-test
--- /tmp/ogata-test.org	2017-10-25 15:53:43.000000000 +0900
+++ /tmp/ogata-test	2017-10-25 15:48:21.000000000 +0900
@@ -124,7 +124,7 @@
         "options": {
           "behavior": "EXPIRES",
           "mustRevalidate": false,
-          "defaultTtl": "10s"
+          "defaultTtl": "60s"
         }
       },
       {
$ akamai property update --section default  ogata-test --file /tmp/ogata-test
Updating property ogata-test
... retrieved rules formats: 1240.564ms
... searching propertyName for ogata-test
... getting info for prp_300844
Updating [object Object]
... copy property ([object Object]) v3
... copy: 724.924ms
Retrieving ogata-test v4
... retrieving property (ogata-test) v4
... retrieving: 2150.355ms
... updating property ([object Object]) v4
... updating: 7022.754ms
Update Complete
Update: 0.22831666666666667 mins

念のため Luna で確認してみると更新されています。

では Activate します。

$ akamai property activate --section default --propver 4 --network STAG ogata-test
Activating ogata-test on STAG
... retrieved rules formats: 1191.545ms
... searching propertyName for ogata-test
... getting info for prp_300844
Activating ogata-test to STAGING
... activating property (ogata-test) v4 on STAGING
... activating: 6812.443ms
... automatically acknowledging 2 warnings!
Warnings: This property is using `latest` rule format, which is designed to reflect interface changes immediately. We suggest converting the property to a stable rule format such as `v2017-06-19` to minimize the risk of interface changes breaking your API client program.
Warnings: A different user last saved the configuration file.  If you are unsure of the changes, please cancel and return to edit.
... activating property (ogata-test) v4 on STAGING
... activating: 9015.764ms
... waiting 30s
... waiting 30s
... waiting 30s
Activation Complete
Activation: 1.9043666666666668 mins
$ akamai property activate --section default --propver 4 --network PROD ogata-test
Activating ogata-test on PROD
... retrieved rules formats: 901.398ms
... searching propertyName for ogata-test
... getting info for prp_300844
Activating ogata-test to PRODUCTION
... activating property (ogata-test) v4 on PRODUCTION
... activating: 4093.291ms
... automatically acknowledging 2 warnings!
Warnings: This property is using `latest` rule format, which is designed to reflect interface changes immediately. We suggest converting the property to a stable rule format such as `v2017-06-19` to minimize the risk of interface changes breaking your API client program.
Warnings: A different user last saved the configuration file.  If you are unsure of the changes, please cancel and return to edit.
... activating property (ogata-test) v4 on PRODUCTION
... activating: 7888.852ms
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
... waiting 30s
Activation Complete
Activation: 8.731766666666665 mins

できました。behavior を追加したりするのはこの形式だと厳しいと思いますが、例に上げたようなちょっとした設定の変更や、Property の新規作成時にテンプレートとして事前に Property を作っておき、そこから clone して必要な部分だけ設定を変えるということは自動化できそうです。 Property ごとの JSON を repository で管理し、 push されたら Jenkins などで Akamai staging で activate -> RunScope などでチェック -> production で activate という流れを作るのも簡単ですね。ただこのコマンドには Property の list を持ってくる機能がないため、 Property をたくさん管理している場合、最初に全部持ってくるところが非常に面倒でした。これからの開発に期待ですね。

自主渡航奨励制度

さて最後に、冒頭で紹介した弊社の 自主渡航奨励制度 について説明させてください。

半年に1回1週間、業務上の用事がなくても、弊社の San Francisco オフィスや New York オフィスを気軽に訪問してリモート作業したり、現地スタートアップを訪問したり、イベントなどに参加したりできる制度です。オフィス訪問に限らず、海外のカンファレンスや学会への自主的な参加も奨励しています。その際の航空券費・交通費・宿泊費・通信費・海外渡航保険・カンファレンス等参加費を会社で負担しています(一応上限の金額は決まっています)。特に当社エンジニアメンバーの制度利用率は高く、WWDC や Google I/O など有名テックイベントから、機械学習のカンファレンス、シリコンバレーやアジアのスタートアップ視察などなど大変人気の制度です。

スマートニュースでは「世界中の良質な情報を必要な人に送り届ける」というミッションを掲げています。それを真の意味で実現するには、グローバルで成功するための肌感覚を持つことが絶対に欠かせません。全メンバーがいつでもそういった視点を持ち、経験を積むための努力を様々な形で支援するための環境作りこそ、スマートニュースが大切にしている価値観のひとつ。前例の無い制度で、前例の無い大きな価値を世界に届けて行きたいですね。