Kentaro Miyake
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Topa'z下書き ## インフラ担当 インフラ担当のニッシー☆です。インフラ構成について説明します。 ### インフラ構成図 まずはこちらをご覧ください!(のちに1つずつ解説します) ![](https://i.imgur.com/fmhNUw2.jpg) ### 前提と背景 今回は新規に3つのアプリがあります。 - 歴代作品を展示する展示場アプリ - 新作アプリである「まさかり」アプリ - 「まさかり」アプリに必要なレガシーアプリ 展示場アプリとまさかりアプリはフロントはSPA、バックはコンテナアプリになっています。 レガシーアプリはEC2の上のdockerで動かすことになっていました。 ### ここがポイント - AWSのほとんどのリソースをIaCツールであるTerraformで用意しています - ElastiCacheやSecretsManagerはハッカソン中に初めて書きました - Terraformを用いている理由はハッカソンという短時間でもインフラ要件に対して高速で確実に応えるためです。CDKよりも早いことが多い所感です。 - 全てSSL化 - 以下はハッカソンで開発したフロントやバックエンドのホスト一覧です。SSL化はそれぞれのAWSリソース(CloudFront、Amplify、ALB、EC2)によってやり方が変わりますが、設定しました。 - Lambdaの関数URLには自動で付いています。 - 展示場 - Rust製wasmフロント - http://exhibition.yukinissie.com - Go製バックエンド。REST API、websocket添、redisクラスタ付き - https://location-provider.yukinissie.com - まさかり投げアプリ(新アプリ) - React SPA - https://masakari.yukinissie.com - Go製バックエンド。REST API、websocket添、redisクラスタ付き - https://masakari-backend.yukinissie.com - まさかり喰らいサイト - https://legacy-stack.yukinissie.com/ - メトリクス取得API(AWS Lambda 関数URL) - https://jqyf37xokyuyzxqharfzdelepq0lbrjw.lambda-url.ap-northeast-1.on.aws/ - 全ての環境にCI/CDが整えられています。 - GitHub Actionsに実装しています。 - 自動デプロイはインフラ屋の作業負荷を減らせて最高です。 - 実はElastiCache(Redis、Memcached)が冗長化のために複数台立っている - 趣味です - レガシースタック - CentOS 7! ### 詳細 #### 展示場スタック 下記図の黄色の部分が中心です。 ![](https://i.imgur.com/UX1ws2K.jpg) 展示場フロントエンドスタックとバックエンドスタックに別れています。 フロントエンドスタックはアプリがRust製WASMであるため、AmplifyのCI上ではビルドできないのでGitHub Actions上でビルドし、コンテンツの配信基盤はCloudFrontとS3で作りました。 CloudFront*S3の組み合わせの場合はCloudFrontのキャッシュパージをデプロイごとに行う必要がありますが、AWS SDKとLambda、それからS3のイベント通知の機能を組み合わせることで自動化させています。 バックエンドスタックはTerraformでFargateを組んでおりElastiCacheと通信できるようにしています。 WebSocketを実装したアプリが動くため、SSL化の要件に応えています。 ECSタスクのデプロイに[ecspresso](https://github.com/kayac/ecspresso)を用いています。詳細は省きますが、デプロイの自動化をする上でとても便利です。 #### まさかりアプリスタック 下記図の赤色の部分です。 ![](https://i.imgur.com/sGaRXI5.jpg) バックエンドスタックには展示場アプリと同様にTerraformでFargateを構築しています。違いとしてはタスク定義内にバックエンドのサイドカーとしてWorkerアプリが追加されていることと、ElastiCache for Memcachedが追加されていることです。 他にはSecrets ManagerからOpenAI APIのトークンを取得することもしました。 EC2メトリクスを取得するスタックにはRustとLambdaを用いています。 `cargo lambda deploy` するだけでRustアプリがLambdaにデプロイされるので感動します。 フロントスタックはAmplifyにデプロイしているだけなので省略します。 #### レガシースタック 下記図の青色の部分です。 ![](https://i.imgur.com/pyXyX17.png) レガシーとは何か考えた時に、少なくとも可用性や冗長性のないものだと考え、EC2一台構成で組むことにしました。現代ならLightsailで簡単に構築できますが、そのようなものは無いと仮定しています。 EC2そのものはコンソールから手動で起動させましたが、EC2内部はAnsibleでプロビジョニングしています。地味に初めての経験でした。 まさか、ハッカソン中にSSHしてOSのアップデートや手動SSL証明書発行等をするとは思っていませんでしたが、原点回帰です。最初のハッカソンではEC2一台構成でした。 CentOS 7を選んだことがこだわりです。 SSHしたり、`git pull`で同期したり、`docker compose up -d`で環境起動させたり、SELinuxを無効化させていたり、あえてツッコミどころたくさんな環境にしています。レガシーとは(哲学) 他にもやったことがある気がしますが深夜帯で頭が回っていませんのでこの辺で失礼します。ニッシー☆でした。 PS. レガシースタックのメトリクスはCloudWatch経由で最初は取得していましたが、自作メソッドでリアルタイムに取れるようにしました。https://legacy-stack.yukinissie.com/metrics/ ## 展示場LP担当 展示場LP担当(とEC2メトリクスAPI)のTanakaです。 今回のテーマがふきょうということで自分はRustを布教するためにRust(yew)でフロントエンド開発を行いました。 ### [yew](https://yew.rs/ja/) yewはRustのフロントエンドフレームワークでReactライクに開発することができます。(関数コンポーネントやhooksが使えます) Rustでフロントエンド開発を行うなら現状これが最善かなと個人的には思います。(最新のversion=0.20でSSRにも対応しました...!) スタイリングは周辺フレームワークが壊滅(数ヶ月更新されていない)状態なので無難にTailwind.cssを選択しました。 ### Rust Onlyでフロントエンドを書くメリット Rustで書けること。以上。 何を言っているのかわからないと思いますが現在それ以外ないというのが私の感想です。 Rustなので高パフォーマンス!というのはWASMにおいてはそうだったりそうでなかったりします。WASMからDOMを操作するコストが結構高いのでベンチマークもそんなにスコアがでなかったり・・・。 とはいえ今後改善されるようなので皆さんもRustでフロントエンドを書きましょう。 ### e2eテスト このアプリのe2eテストもRust([headless_chrome](https://crates.io/crates/headless_chrome))で書きました! PuppeteerのRust版みたいなものです。 今回は展示場ということで某すぺしゃるなちゃっと風で展示物を見て回ることができるようにしました。 チャットもできるのでわいわいしてください! ### メトリクス取得API `AWS SDK for Rust(CloudWatch)`を用いてCloudWatchに流れてきたEC2の`CPUUtilization`等を取得してJSONで返しています。 exampleコードが全然なくてどうやって取得するかわからなかったのですが、他言語と設計自体は一緒なので`AWS SDK for python`を参考にしてなんとかしました。 ----- 今回のネストが深いコードです。これ以上にネストが深いコードを書いた方はこっそり教えて下さい。 ![](https://i.imgur.com/44P8TDF.png) (Rust言語特有の所有権の関係でブロックを作ってcloneしまくらないといけないで仕方のないことなんです。(言い訳 ### キャラクター操作方法 - マウスでキャラをドラッグ - WASD or 矢印キー - 展示物をクリックでTopa'zのプロジェクトページが見れます - 展示物の場所に行き、Enterボタンを押すとその展示物のサイトにジャンプします # つくるものメモ ## 概要 - とりあえず今までの全部のサービスを動かす - 新作どうしよう? - ハックツハッカソンを布教しようぜ!!! - 圧倒的な技術力とテストコードとnewrelicを差し込んで ついでにマイクロサービス化! - 奇声 - オリジナルリポジトリ:https://github.com/hackz-hackathon-giganoto/team-a - フォーク先ディレクトリ:https://github.com/Carriage-Horse-Technologies/giganoto-kisei - デプロイ先:https://kisei.yukinissie.com - デスマTV - red - https://games.jyogi.net/ - 新作 - 各々のポートフォリオサイト(?) - その他展示したい物 - JR四国のHP ## (Rust製)フロント 展示用のLPをWASMのSSRでやってみるの世界 - ハッカソンの過去作品のところに行くとジャンプする(/<service_name>) - LPとかその他展示したい物は近づくとオーバーレイで表示 - で、新作よ イメージ図は明らかに3Dだけど、別に2Dもよくね? ![](https://i.imgur.com/2btm4SK.png) ↑Gatherみたいな感じのやつでキャラを動かして、展示場にする(布教は満たす) ステージの中心に新作を配置 マルチキャラクターに対応したい **自分以外のユーザーの座標位置を更新するイベント** ```json { "action":"UPDATE_CHARACTER_POS" "characters": [ { "pos_x":114.514, "pos_y":114.514, "url":"https://example.cloudfront.net/image/character_1.png" "user_id":"example-user-id" },.. ] } ``` **自分の位置をサーバーに通知するイベント** ```json { "action":"UPDATE_MY_POS", "pos_x":114.514, "pos_y":114.514, "user_id":"example-user-id" } ``` チャットのスキーマ ```json { "action":"CHAT_MESSAGE", "user_id":"examper-user-id", "message":"hogehoge" } ``` ![](https://i.imgur.com/Igdfehe.png) ## 新作 新作アイデア募集!!! 我々にしか作れないもの...? 何だろう? ## 新作を考えなきゃ とりあえず脳裏に浮かんだもの - エンディングロールを作りたい - ハッカソン的な文脈でのエンディング ## 新作 - まさかりを投げてサーバーに負荷を掛ける - お前の技術力はその程度か?(双方に対する煽り) - まさかりの強さ - 鋭い指摘をするほど投げる物が強くなる - サーバーから煽りが返ってくる - サーバーが死んだらフロント側で「返事がない、ただのしかばねのようだ」と返す ## まさかりの投げ方 1. チャットを投げる 2. GPT君からメッセージが返ってくる 3. みんなが投げたまさかりをブロードキャスト(どこかで聞いたアイデアだな) ## 表示するもの - チャットを投げるテキストボックス - 皆のチャットが流れる(まさかり) - まさかりゲージ(東方的なあれ) - 上側にGPT君のメッセージ 負荷を掛ける対象は展示会のインフラ群 -> 展示中のアプリを落とす ## 絶対に欲しい物 - [ ] サーバーが生きてるか死んでるかのステータスはほしい - [ ] CPU使用率,メモリ ## 取れたら欲しいもの - [ ] 分間どのくらいアクセスが来ているか これを各API毎に提供(パーセンテージ) ```jsonld= { metrics:[ { "name":"デスマTV", 'cpu':11.4514, 'memory':11.514, 'traffic':114514 }, { "name":"デスマTV", 'cpu':11.4514, 'memory':11.514, 'traffic':114514 },... ] } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully