AWS: ECS

ECS オートスケーリング 記事 Fargate で Amazon ECS サービスの自動スケーリングを設定する方法を教えてください。 AWS FargateでAutoScaleを試してみる Terraform の設定 オートスケーリングの設定をTerraformで記述する例を以下に示します。この例では、CPU使用率に基づいてECS Fargateサービスのタスク数を自動的にスケーリングするように設定します。 必要なリソース TerraformでECSサービスのオートスケーリングを設定するには、以下のリソースを定義します。 aws_appautoscaling_target: スケーリングの対象となるECSサービスとタスク数を指定します。 aws_appautoscaling_policy: 実際のスケーリングロジック(CPU使用率、目標値など)を定義します。 aws_cloudwatch_metric_alarm: (オプション) 詳細な条件でスケーリングを制御する場合に使用します。ターゲット追跡スケーリングポリシーは内部でこれを生成するため、通常は明示的に定義する必要はありません。 Terraform コード例 以下のコードブロックは、aws_ecs_serviceリソースで定義されたECSサービスに対して、CPU使用率が50%になるようにタスク数を調整するオートスケーリング設定の例です。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 # ECSサービスを定義 (この例では、既存サービスを想定) # resource "aws_ecs_service" "main" { # name = "my-ecs-service" # ... # } # 1. オートスケーリングの対象を定義 resource "aws_appautoscaling_target" "ecs_target" { service_namespace = "ecs" resource_id = "service/my-cluster/my-ecs-service" # サービス名に合わせて変更 scalable_dimension = "ecs:service:DesiredCount" min_capacity = 1 # 最小タスク数 max_capacity = 10 # 最大タスク数 } # 2. ターゲット追跡スケーリングポリシーを定義 resource "aws_appautoscaling_policy" "cpu_scaling_policy" { name = "cpu-utilization-scaling-policy" service_namespace = "ecs" resource_id = aws_appautoscaling_target.ecs_target.resource_id scalable_dimension = aws_appautoscaling_target.ecs_target.scalable_dimension policy_type = "TargetTrackingScaling" target_tracking_scaling_policy_configuration { predefined_metric_specification { predefined_metric_type = "ECSServiceAverageCPUUtilization" } target_value = 50.0 # CPU使用率の目標値(%) scale_in_cooldown = 300 # スケールイン(タスク減少)のクールダウン期間(秒) scale_out_cooldown = 60 # スケールアウト(タスク増加)のクールダウン期間(秒) } } コードの解説 aws_appautoscaling_target: ...

2021年6月4日 · 1 分

Django: asgiref

asgiref https://github.com/django/asgiref ASGI: ASGI is a standard for Python asynchronous web apps and servers to communicate with each other, and positioned as an asynchronous successor to WSGI. You can read more at https://asgi.readthedocs.io/en/latest/ This package includes ASGI base libraries, such as: Sync-to-async and async-to-sync function wrappers, asgiref.sync Server base classes, asgiref.server A WSGI-to-ASGI adapter, in asgiref.wsgi Function wrappers These allow you to wrap or decorate async or sync functions to call them from the other style (so you can call async functions from a synchronous thread, or vice-versa). ...

2021年6月2日 · 3 分

Python: singledispatch

singledispatch PEP 443 – Single-dispatch generic functions single-dispatch generic functions : form of generic programming 記事 Generic Function in Python with Singledispatch

2021年5月24日 · 1 分

Vue.js: 再描画

Vue.js: DOMの再描画 Vue.jsでビューの変更がされないときに疑うこと+主な解決策方法 Vue.jsでビューの変更がされないときに疑うこと+主な解決策方法 List Rendering リストレンダリング The correct way to force Vue to re-render a component 配列: 配列自体を置き換えて変更すること オブジェクト Object.assign / スプレッド構文 など使って新しいオブジェクトで代入し直す key属性を使う DOMを再利用させないようにする v-if でゲートをかける true で再レンダリング nextTick で変更 1 2 3 this.$nextTick(() => { // do modify })

2021年5月22日 · 1 分

Laravel: マイグレーション

Laravel マイグレーション Laravel マイグレーションを1つずつ戻す 1 $ php artisan migrate:rollback --step=1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 MySQL [mysite]> select * from migrations; +----+--------------------------------------------------------------+-------+ | id | migration | batch | +----+--------------------------------------------------------------+-------+ | 1 | 2014_10_12_000000_create_users_table | 1 | | 2 | 2014_10_12_100000_create_password_resets_table | 1 | | 3 | 2019_08_19_000000_create_failed_jobs_table | 1 | | 4 | 2019_12_14_000001_create_personal_access_tokens_table | 1 | | 5 | 2021_01_27_074301_create_sessions_table | 1 | | 6 | 2021_02_03_055949_create_products_table | 1 | | 7 | 2021_02_03_060047_create_news_table | 1 | | 8 | 2021_02_08_024947_create_credit_cards_table | 1 | | 9 | 2021_02_08_025236_create_licenses_table | 1 | | 10 | 2021_02_08_060434_create_orders_table | 1 | | 11 | 2021_02_18_124506_create_options_table | 1 | | 12 | 2021_03_10_093455_update_string_fields_to_text | 2 | | 13 | 2021_04_09_123358_add_users_deleted_at_field | 3 | | 14 | 2021_04_09_123459_add_licenses_subscription_cancelled_fields | 3 | +----+--------------------------------------------------------------+-------+ 14 rows in set (0.002 sec) 1 % php artisan migrate:rollback --step=1 ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes Rolling back: 2021_04_09_123459_add_licenses_subscription_cancelled_fields Rolled back: 2021_04_09_123459_add_licenses_subscription_cancelled_fields (165.69ms) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 MySQL [mysite]> select * from migrations; +----+-------------------------------------------------------+-------+ | id | migration | batch | +----+-------------------------------------------------------+-------+ | 1 | 2014_10_12_000000_create_users_table | 1 | | 2 | 2014_10_12_100000_create_password_resets_table | 1 | | 3 | 2019_08_19_000000_create_failed_jobs_table | 1 | | 4 | 2019_12_14_000001_create_personal_access_tokens_table | 1 | | 5 | 2021_01_27_074301_create_sessions_table | 1 | | 6 | 2021_02_03_055949_create_products_table | 1 | | 7 | 2021_02_03_060047_create_news_table | 1 | | 8 | 2021_02_08_024947_create_credit_cards_table | 1 | | 9 | 2021_02_08_025236_create_licenses_table | 1 | | 10 | 2021_02_08_060434_create_orders_table | 1 | | 11 | 2021_02_18_124506_create_options_table | 1 | | 12 | 2021_03_10_093455_update_string_fields_to_text | 2 | | 13 | 2021_04_09_123358_add_users_deleted_at_field | 3 | +----+-------------------------------------------------------+-------+ 13 rows in set (0.002 sec)

2021年5月17日 · 2 分

Python:Exception

Python: Exception Python Exceptions: An Introduction 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 try: # 処理 linux_interaction() except AssertionError as error: # 例外 print(error) else: ## 例外がない場合 try: with open('file.log') as file: read_data = file.read() except FileNotFoundError as fnf_error: print(fnf_error) finally: # 最後に必ず実行 print('Cleaning up, irrespective of any exceptions.') Python Exception Base Classes 組み込み例外 8.6. ユーザー定義例外

2021年5月14日 · 1 分

Radio

Radio 曜日 Ch 時間 番組 月 J-Wave 22:00 - 24:00 SONAR MUSIC 月 NHK 24:00 - 24:50 夜のプレイリスト 火 J-Wave 22:00 - 24:00 SONAR MUSIC 火 NHK 24:00 - 24:50 夜のプレイリスト 水 J-Wave 22:00 - 24:00 SONAR MUSIC 水 NHK 24:00 - 24:50 夜のプレイリスト 木 J-Wave 22:00 - 24:00 SONAR MUSIC 木 NHK 24:00 - 24:50 夜のプレイリスト 金 InterFM 897 20:00 - 22:00 TOKYO SCENE 金 NHK 24:00 - 24:50 夜のプレイリスト 金 InterFM 897 24:00 - 25:00 beatDAYZ 土 Fm yokohama84.7 24:00 - 25:00 Bayside Reggae Lounge 日 J-Wave 20:00 - 21:00 Travelling without Moving Station Apple Music Radio BBC Sound nts worldwidefm soundcloud mixcloud

2021年5月10日 · 1 分

Django: Request.encodingについて

HttpRequest.encoding django.http.request.HttpRequest cgi.parse_header で、Content-Typeヘッダーから content_type と content_params(dict) を取得。 conent_paramsに charset が入っている可能性がある codecs.lookup を使って、charset の存在を確認。 存在したらHttpRequest.encodingプロパティに設定する 実態は, HttpRequest._encoding

2021年4月24日 · 1 分

DRF: CSVを送信するするときに WindowsだとBOMをつけないとExcelで文字化けする問題

BOM(byte order mark) ファイルの先頭3バイトが ‘EF BB BF’ の UTF-8 rest_framework_csv rendererで、 コンテキストの encoding を判定している encodingに utf-8-sig を 指定する viewset: get_renderer_context をオーバーライドする 1 2 3 4 5 6 7 8 9 10 11 def get_renderer_context(self): """(override)""" context = super().get_renderer_context() # ここで、以下の条件の時に utf-8-sigにセット # 1) text/csv を求めている # 2) utf-8 でエンコードが指定されている(デフォルト) if self.request.META.get('HTTP_ACCEPT', '').startswith('text/csv'): context['encoding'] = 'utf-8-sig' return context 記事 bom付きutf-8に変換するnkfコマンド PythonでUTF-8 with BOMを開く Declaring character encodings in HTML The byte-order mark (BOM) in HTML Accept-Encoding HttpRequest.META

2021年4月24日 · 1 分

XCode: A valid provisioning profile for this executable was not found

原因 時間がおかしい(有効期限切れ) Legacy Build System にする (File >Project Settings...>Build System) (今回はこれ) テスト実機端末のスキーマがおかしい(Products > Schema > Edit Schema で Run, Profile の Build Configuration を DEBUG にする) ~/Library/MobileDevice/Provisioning Profiles 1 2 3 4 % ls -l ~/Library/MobileDevice/Provisioning\ Profiles total 456 -rw-r--r-- 1 hdknr staff 10352 4 17 13:52 0179a51b-7303-4fef-b1a0-4a3cf541b737.mobileprovision ..... 記事 【Xcode】ビルドは成功するが、実機にインストールできない問題 エラー:A valid provisioning prof… の対処法 Unable to install iOS app on device. Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402653179 Easy fix! “A valid provisioning profile for this executable was not found” A valid provisioning profile for this executable was not found

2021年4月24日 · 1 分