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
    # Topazドラフト ## どんなサービス デスマ中のエンジニアを眺めながら金を落とす(予定)サービス ## 推しアイデア ## 作った背景 ## 推し技術 今回は短期間にメンバーの多くの技術スタックを総動員して実装を行いました。 ざっと、取り上げられるものだけでこれだけあります! - k8s - Amazon IVS - kotlin - Rust - React - WebSocket - CI/CD(ステージング・本番構成) 主な突っ込んで欲しいポイント - ハッカソンでステージング・本番を用意しちゃった - 謎にガチガチなインフラ構成 - ノリと勢いで投げ銭(お金じゃらじゃら機能)を追加 - よくわからないライブラリも気合で動かし切った限界開発力 - これまでのハッカソン資産を放棄し、kotlinで実装したバックエンド - ものの数日で社内ISUCONのプログラムをRustに移植した猛者 ## プロジェクト概要 ### インフラ #### ライブ動画配信基盤 アプリの要となる動画配信基盤にはパブリッククラウドのAWSが提供している[Amazon Interactive Video Service (IVS)](https://aws.amazon.com/jp/ivs/)を使いました。これを用いることで一対多のライブ配信を実現させています。このサービスを活用することでバックエンドのタスクを削減することができます。Amazon IVSは再生用のSDKが容易されており今回はそれを利用して実行しています。 #### CDNキャッシュパージの自動化 クライアントの提供にはCDNであるAmazon CloudFrontを用いています。また、CloudFrontのオリジンサーバーとしてAmazon S3を用いています。クライアントをS3にデプロイするたびにCloudFrontのキャッシュを削除する必要がありますが通常操作であるAWSの管理画面からいちいちパージをするのは開発サイクルの高速化にはボトルネックです。今回はAWS LambdaとAWS SDKを用いて自動化させました。S3のオブジェクトが更新されることをキッカケに、対応するCloudFrontのキャッシュ削除をリクエストするように構成しています。 #### バックエンドの基盤にAmazon EKSを使用 インフラにはAmazon Elastic Kubernetes Service (EKS) というマネージドなKubernetesサービスを用いました。使用きっかけは開発者の技術的興味によるものですが結果的には開発効率の向上に役立ちました。例えばnamespaceの活用により同じクラスター上に複数環境のコンテナをデプロイすることができたことやCDでデプロイした際に即時新しいイメージが適用されることが、開発速度を求められるハッカソンにはピッタリでした。 #### 本番環境とステージング環境の用意 いつもハッカソンでは発表直前に環境を壊してしまうのはよくあることです。本番と全く同じステージング環境を用意して本番が壊れること防止しています。これにより仮にステージングが壊れようともデモで恥をかくことはありません。安心してステージング環境を壊せます! #### CI/CDを構成 自動デプロイは最高です。それからフロントのlintチェックも行っています。今回は本番環境とステージング環境を用意しているのでその分だけGitHub Actionsのワークフローを用意しています。mainにプッシュするとステージングにtagでプッシュすると本番環境にデプロイされるようになっています。 以下はインフラ構成図です。 ![](https://i.imgur.com/oE0btMT.png) ### サーバーサイド サーバーサイドでは以下のAPIを提供しています。 - GitHub IssuesのStateからタスクの進捗率を計算するAPI - WebSocketを介したチャットサーバー 実装はKotlinで行い、Webフレームワークには純kotlin製のKtorを使用しています。 kotlinのwebフレームワークの代表例としてはSpringBootなどが挙げられますが、これらの比べシンプルでGo経験者でも比較的容易に実装できることから本フレームワークを採用しました。 チャットサーバーはパスパラメーターでチャットIDを付与し、同一IDを共有した人たちでブロードキャストが出来るようになっています。今回の実装ではフロントから送られたJSON形式のメッセージをそのままブロードキャストしています。メッセージオブジェクトのスキーマは以下のように定義しています。 ```json= { "id":"example-user-id" // フロントのユーザーを識別するID "text":"hogehoge" // 投稿データ "action":"SEND_MESSAGE" // actionタイプ(SEND_MONEY or SEND_MESSAGE) } ``` ### クライアント フロントアプリはReactで実装しました。以前まではReduxを使った状態管理を行なっていましたが、実装者の思想によりReactHooksを採用しています。 フロントアプリでは以下の機能を提供しています。 - 配信画面 - チャット機能 - 進捗表示機能 - (配信者専用)認証機能 配信部分のロジックはAWS IVSのライブラリを利用しています。チャットサーバーはブラウザAPIのWebSocketを用いてサーバーと通信を行なっています。テキスト投稿、投げ銭ボタン共にバックエンドのセクションで説明したJSONスキーマに従ってデータを投稿しています!なお、UIフレームワークにはBootstrapを採用しています。 ![](https://i.imgur.com/x2ri5mD.png) 今回、おまけで作った投げ銭機能について説明します。投げ銭機能はボタンを押すとジャラジャラとお金の音が鳴り、お金のアニメーションを動かすものです。アニメーションはCSSで実装しています。クライアントサイドで投げ銭をした時のサウンドと、誰かが投げ銭した時に連動して音が鳴る2つのパターンを用意しています。後者では投げ銭時にチャット基盤を通じてSEND_MONEYのアクションを発火し、アクセス時に生成される自身のランダムID以外の投稿時に音を鳴らすようにしています。こちらの機能は発表当日に突貫で作成したものなので、バグ等があった場合はご容赦ください。 <figure> <img src="https://i.imgur.com/3J3KSzl.png"> <figcaption>お金は配信者とあなたを幸せにする</figcaption> </figure> ### コンテンツ 今回の目が離せないコンテンツは....? メンターのcatatsuyさんが公開している社内ISUCONのプログラムをRustに移植しました!(オリジナルはこちら: https://github.com/catatsuy/private-isu) なお、ベンチマーカーですが、Rustの方が低いのはなぜでしょうか?データベースがボトルネックになっている...? ``` // Rust {"pass":true,"score":9214,"success":8877,"fail":0,"messages":[]} // golang {"pass":true,"score":9414,"success":9075,"fail":0,"messages":[]} ``` ## 最後に 私たちの技術スタックをアピールするために主だったものを全て書き連ねます。個々の理解の浅さには目を瞑ってください...🙇 - React - React Hooks - use-sound - WebSocket - Bootstrap -

    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