Yuta Saito
    • 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
    # ISUCON 2021準備 競技開始後やることの流れ:https://isucon.net/archives/50697356.html 移植コンテストになりそう。 ## 参考 - 具体的にどのへんを見たら良いのか - https://matsuu.hatenablog.com/entry/2020/09/13/131145 - https://engineer.recruit-lifestyle.co.jp/techblog/2020-09-25-isucon10-qualify/ ## [ISUCON11 予選レギュレーション](https://isucon.net/archives/55854734.html) ### サーバー事項 > チームは AWS アカウントを各自で用意し、それを競技に利用する。選手は主催者より競技開始後に指定された AMI (Amazon Machine Image) を利用して Amazon EC2 上にサーバーを起動し、競技へ参加する。具体的なサーバー起動方法については当日マニュアルに記載される。 例年は主催者側がインスタンスを用意するらしいが、今年は自前で用意するらしい。インスタンスのリソース設定とかどうやって統一するんだろう。 例年の文言↓ > 選手は主催者が用意したインスタンスで Web アプリケーションを動作させ、競技へ参加する。インスタンスへの接続は踏み台サーバを経由したSSHで行う。 とりあえず、メンバーのSSH公開鍵を登録するスニペット ```bash curl https://github.com/kateinoigakukun.keys https://github.com/giginet.keys https://github.com/freddi-kit.keys >> .ssh/authorized_keys ``` ## 初手やること ### Swift固有のセットアップ 最近メンテされてないけど、swiftenvで入れるのがLinuxだと一番お手軽。 これを流し込むだけでOK ```bash git clone https://github.com/kylef/swiftenv.git ~/.swiftenv echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(swiftenv init -)"' >> ~/.bash_profile source ~/.bash_profile swiftenv install https://swift.org/builds/swift-5.5-branch/ubuntu2004/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-07-30-a/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-07-30-a-ubuntu20.04.tar.gz ``` ### プロファイリング設定 - [alp](https://github.com/tkuchiki/alp/): LTSV形式のアクセスログを分析して、遅いエンドポイントを探してくれるらしい。便利そう。 - NginxをLTSV形式でログ出すように設定する必要あり。 - Vapor側でもLTSV吐けるようにした - インストール : https://github.com/tkuchiki/alp/releases/download/v1.0.7/alp_linux_amd64.zip - [netdata](https://www.netdata.cloud/): 可視化ツール - [インストールガイド](https://learn.netdata.cloud/docs/agent/packaging/installer/methods/kickstart) - [MySQL plugin]( https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/mysql) - こういう設定を書くだけでいい感じに可視化してくれる。 ``` jobs: - name: local dsn: mysql://isucari:isucari@127.0.0.1:3306/isucari?charset=utf8 ``` ### スロークエリの解析設定 - `slow_query_log`あたりを設定するとスロークエリを報告してくれるらしい。https://dev.mysql.com/doc/refman/5.6/ja/slow-query-log.html - `/etc/mysql/mysql.conf.d/mysqld.cnf`の`slow_query_log`のセクションをコメントアウト外すだけでOK - `pt-query-digest` というツールでいい感じに解析できるらしい。 - インストールガイド: - [リポジトリ登録](https://www.percona.com/doc/percona-repo-config/percona-release.html#installation) - [本体インストール](https://www.percona.com/doc/percona-toolkit/LATEST/installation.html) ## 技術選定 ### フレームワーク - [amzn/smoke-framework](https://github.com/amzn/smoke-framework/blob/main/README.md) - [サンプル](https://github.com/amzn/smoke-framework-examples/tree/main/EmptyExampleService) - ざっと試してみたけど、Swaggerで自動生成することが前提の作りっぽい。 - 全部手書きするのは大変… - async/await APIがついてる。 - [vapor/vapor](https://github.com/vapor/vapor) - 現状デファクト - 最近開発が鈍化してる気がする… - async/await対応は未マージ - https://github.com/vapor/vapor/pull/2613 - このPRのブランチ使うのは割とアリかも。 ### SQLライブラリ - [vapor/fluent-kit](https://github.com/vapor/fluent-kit) - いわゆるORM。型安全にクエリが書ける。 - vaporグループが作ってるけど、vaporには依存してない。 - が、APIの型推論設計が微妙で、すぐ `ambiguous type` が出て、リズムよく書くのは難しい。 - あと、fluentのAPIで狙ったSQL文を生成させるのが難しい。 - [vapor/mysql-kit](https://github.com/vapor/mysql-kit) - もう少しlow-levelのMySQL操作ライブラリ。Fluentの下請け。 - libmysqlclientに依存しないので、非同期IOできる - 普通にSQLを書いて実行する感じ。 - `let rows = try mysql.simpleQuery("SELECT @@version;").wait()` - `Decodable`でSwiftの型にいい感じにマップできる。 - これで十分感はあるが、直接使ったことは無い。 ### Redisライブラリ - [Nathan Harris / RediStack · GitLab](https://gitlab.com/Mordil/RediStack) - 使ったこと無いけど、見た限り普通に使えそう。VaporのRedisサポートに使われてる。 ### テンプレートエンジン - [vapor/leaf-kit](https://github.com/vapor/leaf-kit) - エスケープの扱い周りがかなり微妙… - 生のSwift文字列 - Multiline String Literalで十分な気もする ## 練習環境 - [matsuu/aws-isucon: ISUCON過去問をAWS環境で構築するための一式](https://github.com/matsuu/aws-isucon) ### 反省点 - Xcodeのデバッガがnightly toolchainでうごかん - MySQLKitの挙動 - valuesのオーバーロード - Vaporの挙動 - ペイロードサイズの上限 - ~~デバッガちゃんと動くように直す~~ - ツールチェーンにそのバージョンのlldbが入ってないので無理だ。 ## Tips DYLD_LIBRARY_PATHでランタイムライブラリのロード優先度を変えると、macOSでもCLIからサーバー起動できる ` $ DYLD_LIBRARY_PATH=/Library/Developer/Toolchains/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-07-30-a.xctoolchain/usr/lib/swift/macosx/ /Users/katei/Library/Developer/Xcode/DerivedData/isucon10-derlfopajitqwqddkkovwzoytcxd/Build/Products/Debug/Run serve --port 1323 `

    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