by shigemk2

当面は技術的なことしか書かない

ECS Utlization Reservation

でタスクを実行することによって予約されるメモリの割合 クラスタ。 クラスタ メモリ予約 (このメトリックは、 ClusterName) は、 が予約されています Amazon ECS クラスター上のタスクを合計で割ったもの すべてのコンテナに登録されたメモリ量 クラスター内のインスタンス。のコンテナインスタンスのみ ACTIVE または DRAINING ステータスは メモリ予約メトリックス。このメトリックは、 の EC2 起動タイプ。

日本語訳が壊滅的にやばくて泣きそうになった。

The percentage of memory that is reserved by running tasks in the cluster. Cluster memory reservation (this metric can only be filtered by ClusterName) is measured as the total memory that is reserved by Amazon ECS tasks on the cluster, divided by the total amount of memory that was registered for all of the container instances in the cluster. Only container instances in ACTIVE or DRAINING status will affect memory reservation metrics. This metric is only used for tasks using the EC2 launch type.

こっちがほんちゃん。

Amazon ECS CloudWatch metrics - Amazon Elastic Container Service

タスクのスケールアウトにはUtilization(実際の使用率)をみてタスクの増減を決める。実際の使用率が高いと負荷も高まっているから。EC2のスケールアウトはReservation(予約率)を見てインスタンスの増減を決める。予約率が高まっているということは新しくタスク(コンテナ)も立ち上げられないから。UtilizationはCPUを見て、Reservationはメモリをみたほうがいいらしいけど知らない。

Amazon ECSのCloudWatchメトリクスとAutoScaling戦略 | Developers.IO

MyISAM InnoDB

マジモンの今更

  • MyISAM
    • 昔のデフォルト
    • テーブルごとに3種類のデータファイル 定義 インデックス レコード
    • トランザクション対応してない
    • ファイルへの書き込み
  • InnoDB
    • 今のデフォルト(5.5以降)
    • トランザクション対応
    • クラスター化されたインデックス
    • テーブルスペース

[ThinkIT] 第2回:MyISAMとInnoDB (3/3)

漢(オトコ)のコンピュータ道: MyISAMからInnoDBへ切り替えるときの注意点

MySQLによるデータウェアハウス構築 - Yahoo! JAPAN Tech Blog

MySQL :: MySQL 5.6 リファレンスマニュアル :: 14.1.1 デフォルトの MySQL ストレージエンジンとしての InnoDB

MySQL :: MySQL 5.6 リファレンスマニュアル :: MySQL 用語集

single-transaction

mysqldumpするときの小技

このオプションは、データのダンプ前に、トランザクション分離モードを REPEATABLE READ に設定し、START TRANSACTION SQL ステートメントをサーバーに送信します。これは、InnoDB などのトランザクションテーブルの場合にかぎって便利です。その場合、アプリケーションをブロックすることなく、START TRANSACTION が発行された時点のデータベースの一貫した状態をダンプするからです。

このオプションを使用する場合、一貫した状態でダンプされるのは InnoDB テーブルのみだということに留意してください。たとえば、このオプションの使用中にダンプされた MyISAM テーブルまたは MEMORY テーブルは状態が変化する可能性があります。
  • 稼働中のDBにこのオプションなしでmysqldumpするとwhen using LOCK TABLESエラーが出る
    • MyISAMでこれがでないのはMyISAMではトランザクション対応じゃないから

MySQL :: MySQL 5.6 リファレンスマニュアル :: 4.5.4 mysqldump — データベースバックアッププログラム

array_uintersect

https://www.php.net/manual/ja/function.array-uintersect.php

<?php
// 他の全ての引数に存在する array1 の値を全て有する配列を返す
// 比較関数は、最初の引数と二番目の引数の比較結果を返します。
// 最初の引数のほうが二番目の引数より大きい場合は正の数を、二番目の引数と等しい場合はゼロを、そして二番目の引数より小さい場合は負の数を返す必要があります。
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
$array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");

print_r(array_uintersect($array1, $array2, "strcasecmp"));
// Array
// (
//     [a] => green
//     [b] => brown
//     [0] => red
// )

https://www.php.net/manual/ja/function.strcasecmp.php

(バイナリセーフ比較 str1 が str2 より小さい場合は負、str1 が str2 より大きい場合は正、等しい場合は 0 を返します)

MySQL REFERENCES

ここが重要かもしれない。バージョンによっては機能したりしなかったりするらしいけど5.6でもマイナーバージョンによっては機能することもあるらしいからよくわからない

For storage engines other than InnoDB, it is possible when defining a column to use a REFERENCES tbl_name(col_name) clause, which has no actual effect, and serves only as a memo or comment to you that the column which you are currently defining is intended to refer to a column in another table

8.0

A foreign key constraint is not required merely to join two tables. For storage engines other than InnoDB, it is possible when defining a column to use a REFERENCES tbl_name(col_name) clause, which has no actual effect, and serves only as a memo or comment to you that the column which you are currently defining is intended to refer to a column in another table. It is extremely important to realize when using this syntax that:

5.7

A foreign key constraint is not required merely to join two tables. For storage engines other than InnoDB, it is possible when defining a column to use a REFERENCES tbl_name(col_name) clause, which has no actual effect, and serves only as a memo or comment to you that the column which you are currently defining is intended to refer to a column in another table. It is extremely important to realize when using this syntax that:

5.6

A foreign key constraint is not required merely to join two tables. For storage engines other than InnoDB, it is possible when defining a column to use a REFERENCES tbl_name(col_name) clause, which has no actual effect, and serves only as a memo or comment to you that the column which you are currently defining is intended to refer to a column in another table. It is extremely important to realize when using this syntax that:

MySQL :: MySQL 8.0 Reference Manual :: 6.2.2 Privileges Provided by MySQL

MySQL :: MySQL 8.0 Reference Manual :: 3.6.6 Using Foreign Keys