{"id":30093,"date":"2026-01-13T08:52:17","date_gmt":"2026-01-12T23:52:17","guid":{"rendered":"https:\/\/www.skyarch.net\/blog\/?p=30093"},"modified":"2025-12-23T15:31:44","modified_gmt":"2025-12-23T06:31:44","slug":"ecs-fargate%e3%81%a7%e8%b2%a0%e8%8d%b7%e3%83%86%e3%82%b9%e3%83%88%e3%83%84%e3%83%bc%e3%83%ablocust%e3%82%92%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6api%e3%81%ab%e8%b2%a0%e8%8d%b7%e3%82%92%e3%81%8b%e3%81%91","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/ecs-fargate%e3%81%a7%e8%b2%a0%e8%8d%b7%e3%83%86%e3%82%b9%e3%83%88%e3%83%84%e3%83%bc%e3%83%ablocust%e3%82%92%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6api%e3%81%ab%e8%b2%a0%e8%8d%b7%e3%82%92%e3%81%8b%e3%81%91\/","title":{"rendered":"ECS Fargate\u3067\u8ca0\u8377\u30c6\u30b9\u30c8\u30c4\u30fc\u30ebLocust\u3092\u52d5\u304b\u3057\u3066API\u306b\u8ca0\u8377\u3092\u304b\u3051\u3066\u307f\u305f"},"content":{"rendered":"<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>\u696d\u52d9\u3067\u8ca0\u8377\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u300cLocust\u300d\u3092\u4f7f\u3046\u6a5f\u4f1a\u304c\u3042\u308a\u3001AWS ECS Fargate\u4e0a\u3067Locust\u3092\u52d5\u304b\u3057\u3066\u3001API\u306b\u8ca0\u8377\u3092\u304b\u3051\u308b\u691c\u8a3c\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>Locust\u3092\u4f7f\u3048\u3070Python\u3067\u7c21\u5358\u306b\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u30b7\u30ca\u30ea\u30aa\u3092\u66f8\u3051\u308b\u3093\u3067\u3059\u3002<br \/>\n\u3055\u3089\u306bECS Fargate\u3067\u52d5\u304b\u3059\u3053\u3068\u3067\u3001\u30b5\u30fc\u30d0\u30fc\u7ba1\u7406\u4e0d\u8981\u3067\u5927\u898f\u6a21\u306a\u8ca0\u8377\u30c6\u30b9\u30c8\u3082\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u79c1\u3082\u521d\u3081\u3066\u4f7f\u3063\u3066\u307f\u305f\u306e\u3067\u3001\u4e00\u3064\u4e00\u3064\u4e01\u5be7\u306b\u89e3\u8aac\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#overview\">\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/a><\/li>\n<li><a href=\"#architecture\">\u69cb\u6210\u6982\u8981<\/a><\/li>\n<li><a href=\"#api-setup\">API Gateway + Lambda \u306e\u6e96\u5099<\/a><\/li>\n<li><a href=\"#locust-scenario\">Locust\u30c6\u30b9\u30c8\u30b7\u30ca\u30ea\u30aa\u306e\u4f5c\u6210<\/a><\/li>\n<li><a href=\"#docker-setup\">Docker\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210<\/a><\/li>\n<li><a href=\"#ecs-setup\">ECS\u74b0\u5883\u306e\u69cb\u7bc9<\/a><\/li>\n<li><a href=\"#load-test\">\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u5b9f\u884c<\/a><\/li>\n<li><a href=\"#test-results\">\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u7d50\u679c\u78ba\u8a8d<\/a><\/li>\n<li><a href=\"#matome\">\u307e\u3068\u3081<\/a><\/li>\n<\/ul>\n<p><a id=\"overview\"><\/a><\/p>\n<h2>\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/h2>\n<ul>\n<li>Locust\u3068\u306f\u4f55\u304b<\/li>\n<li>ECS Fargate\u3067\u8ca0\u8377\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u30e1\u30ea\u30c3\u30c8<\/li>\n<li>Docker\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210\u65b9\u6cd5<\/li>\n<li>ECS\u3067\u306e\u5b9f\u884c\u65b9\u6cd5<\/li>\n<li>\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u7d50\u679c\u306e\u898b\u65b9<\/li>\n<\/ul>\n<h3>\u524d\u63d0\u6761\u4ef6<\/h3>\n<ul>\n<li>AWS\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u6301\u3063\u3066\u3044\u308b<\/li>\n<li>Docker\u306e\u57fa\u672c\u7684\u306a\u77e5\u8b58\u304c\u3042\u308b<\/li>\n<li>Python\u306e\u57fa\u790e\u77e5\u8b58\u304c\u3042\u308b\uff08\u8aad\u3081\u308c\u3070OK\uff09<\/li>\n<\/ul>\n<h3>Locust\u3068\u306f\uff1f<\/h3>\n<p>Locust\u306f\u3001Python\u3067\u66f8\u304b\u308c\u305f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u8ca0\u8377\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<h3>Locust\u306e\u7279\u5fb4<\/h3>\n<ul>\n<li><strong>Python\u3067\u66f8\u3051\u308b<\/strong>: \u8907\u96d1\u306a\u30b7\u30ca\u30ea\u30aa\u3082Python\u30b3\u30fc\u30c9\u3067\u8868\u73fe\u3067\u304d\u308b<\/li>\n<li><strong>WebUI\u304c\u4f7f\u3044\u3084\u3059\u3044<\/strong>: \u30d6\u30e9\u30a6\u30b6\u304b\u3089\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u72b6\u6cc1\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u78ba\u8a8d\u3067\u304d\u308b<\/li>\n<li><strong>\u5206\u6563\u5b9f\u884c\u304c\u53ef\u80fd<\/strong>: \u8907\u6570\u306e\u30ef\u30fc\u30ab\u30fc\u3067\u5927\u898f\u6a21\u306a\u8ca0\u8377\u30c6\u30b9\u30c8\u304c\u3067\u304d\u308b<\/li>\n<li><strong>\u8efd\u91cf<\/strong>: 1\u53f0\u306e\u30de\u30b7\u30f3\u3067\u6570\u5343\u30e6\u30fc\u30b6\u30fc\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3067\u304d\u308b<\/li>\n<\/ul>\n<h3>\u306a\u305cECS Fargate\u3067\u52d5\u304b\u3059\u306e\u304b\uff1f<\/h3>\n<h4>\u30e1\u30ea\u30c3\u30c8<\/h4>\n<ol>\n<li><strong>\u30b5\u30fc\u30d0\u30fc\u7ba1\u7406\u4e0d\u8981<\/strong>: EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u7ba1\u7406\u304c\u4e0d\u8981<\/li>\n<li><strong>\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb<\/strong>: \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30bf\u30b9\u30af\u6570\u3092\u5897\u3084\u305b\u308b<\/li>\n<li><strong>\u30b3\u30b9\u30c8\u52b9\u7387<\/strong>: \u4f7f\u3063\u305f\u5206\u3060\u3051\u306e\u8ab2\u91d1<\/li>\n<li><strong>\u518d\u73fe\u6027<\/strong>: Docker\u30a4\u30e1\u30fc\u30b8\u3067\u74b0\u5883\u3092\u56fa\u5b9a\u3067\u304d\u308b<\/li>\n<\/ol>\n<p><a id=\"architecture\"><\/a><\/p>\n<h2>\u69cb\u6210<\/h2>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/LOCUST-1.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/LOCUST-1-1024x277.png\" alt=\"\" \/><\/a>\n<p><a id=\"api-setup\"><\/a><\/p>\n<h2>\u30c6\u30b9\u30c8\u5bfe\u8c61API\u306e\u6e96\u5099\uff08API Gateway + Lambda\uff09<\/h2>\n<p>\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u5bfe\u8c61\u3068\u306a\u308bAPI\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<h3>Lambda\u95a2\u6570\u3068API Gateway\u306e\u4f5c\u6210<\/h3>\n<p>Lambda\u95a2\u6570\u3068API Gateway\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<h4>Lambda\u95a2\u6570\u306e\u6e96\u5099<\/h4>\n<pre class=\"lang:python decode:true\" title=\"lambda_function.py\">\nimport json\n\ndef lambda_handler(event, context):\n    # HTTP API v2\u306e\u5834\u5408\u306e\u30d1\u30b9\u53d6\u5f97\n    path = event.get('rawPath', event.get('path', ''))\n    method = event.get('requestContext', {}).get('http', {}).get('method', event.get('httpMethod', ''))\n\n    # CORS\u30d8\u30c3\u30c0\u30fc\n    headers = {\n        'Content-Type': 'application\/json',\n        'Access-Control-Allow-Origin': '*',\n        'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n        'Access-Control-Allow-Headers': 'Content-Type, Authorization'\n    }\n\n    # OPTIONS\u30ea\u30af\u30a8\u30b9\u30c8\uff08CORS preflight\uff09\n    if method == 'OPTIONS':\n        return {\n            'statusCode': 200,\n            'headers': headers,\n            'body': ''\n        }\n\n    # \u30eb\u30fc\u30c8\u30d1\u30b9\n    if path == '\/' and method == 'GET':\n        return {\n            'statusCode': 200,\n            'headers': headers,\n            'body': json.dumps({'message': 'API is running', 'endpoints': ['\/api\/users']})\n        }\n\n    # \u30e6\u30fc\u30b6\u30fc\u4e00\u89a7\u53d6\u5f97\n    if path == '\/api\/users' and method == 'GET':\n        return {\n            'statusCode': 200,\n            'headers': headers,\n            'body': json.dumps([\n                {'id': 1, 'name': 'User 1', 'email': 'user1@example.com'},\n                {'id': 2, 'name': 'User 2', 'email': 'user2@example.com'}\n            ])\n        }\n\n    # \u30e6\u30fc\u30b6\u30fc\u8a73\u7d30\u53d6\u5f97\n    if path.startswith('\/api\/users\/') and method == 'GET':\n        user_id = path.split('\/')[-1]\n        try:\n            return {\n                'statusCode': 200,\n                'headers': headers,\n                'body': json.dumps({\n                    'id': int(user_id),\n                    'name': f'User {user_id}',\n                    'email': f'user{user_id}@example.com'\n                })\n            }\n        except ValueError:\n            return {\n                'statusCode': 400,\n                'headers': headers,\n                'body': json.dumps({'error': 'Invalid user ID'})\n            }\n\n    # \u30e6\u30fc\u30b6\u30fc\u4f5c\u6210\n    if path == '\/api\/users' and method == 'POST':\n        try:\n            body = json.loads(event.get('body', '{}'))\n            return {\n                'statusCode': 201,\n                'headers': headers,\n                'body': json.dumps({\n                    'id': 999,\n                    'name': body.get('name'),\n                    'email': body.get('email')\n                })\n            }\n        except json.JSONDecodeError:\n            return {\n                'statusCode': 400,\n                'headers': headers,\n                'body': json.dumps({'error': 'Invalid JSON'})\n            }\n\n    # \u30c7\u30d0\u30c3\u30b0\u60c5\u5831\u3092\u542b\u3080404\u30ec\u30b9\u30dd\u30f3\u30b9\n    return {\n        'statusCode': 404,\n        'headers': headers,\n        'body': json.dumps({\n            'error': 'Not Found',\n            'debug': {\n                'path': path,\n                'method': method,\n                'event_keys': list(event.keys())\n            }\n        })\n    }\n<\/pre>\n<h4>API Gateway\u306e\u6e96\u5099<\/h4>\n<h5>\u65b9\u6cd51: SAM\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528<\/h5>\n<pre class=\"lang:yaml decode:true\" title=\"template.yaml\">\nAWSTemplateFormatVersion: '2010-09-09'\nTransform: AWS::Serverless-2016-10-31\nDescription: 'API Gateway + Lambda for Locust Load Test'\n\nResources:\n  ApiFunction:\n    Type: AWS::Serverless::Function\n    Properties:\n      FunctionName: locust-test-api\n      Runtime: python3.9\n      Handler: lambda_function.lambda_handler\n      CodeUri: .\/\n      Timeout: 30\n      Events:\n        ApiEvent:\n          Type: HttpApi\n          Properties:\n            Path: \/{proxy+}\n            Method: ANY\n        RootEvent:\n          Type: HttpApi\n          Properties:\n            Path: \/\n            Method: ANY\n\nOutputs:\n  ApiEndpoint:\n    Value: !Sub 'https:\/\/${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com'\n    Description: API Gateway endpoint URL\n<\/pre>\n<h5>\u30c7\u30d7\u30ed\u30a4<\/h5>\n<pre class=\"lang:bash decode:true\">\n# S3\u30d0\u30b1\u30c3\u30c8\u4f5c\u6210\nBUCKET_NAME=\"locust-deploy-$(date +%s)\"\naws s3 mb s3:\/\/$BUCKET_NAME\n\n# \u30d1\u30c3\u30b1\u30fc\u30b8\u5316\naws cloudformation package \\\n  --template-file template.yaml \\\n  --s3-bucket $BUCKET_NAME \\\n  --output-template-file packaged-template.yaml\n\n# \u30c7\u30d7\u30ed\u30a4\naws cloudformation deploy \\\n  --template-file packaged-template.yaml \\\n  --stack-name locust-test-api \\\n  --capabilities CAPABILITY_IAM\n\n# S3\u30d0\u30b1\u30c3\u30c8\u524a\u9664\naws s3 rb s3:\/\/$BUCKET_NAME --force\n<\/pre>\n<h5>\u65b9\u6cd52: CloudFormation\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528<\/h5>\n<pre class=\"lang:yaml decode:true\" title=\"api-gateway.yaml\">\nAWSTemplateFormatVersion: '2010-09-09'\nDescription: 'API Gateway + Lambda for Locust Load Test'\n\nResources:\n  ApiFunction:\n    Type: AWS::Lambda::Function\n    Properties:\n      FunctionName: locust-test-api\n      Runtime: python3.9\n      Handler: index.lambda_handler\n      Code:\n        ZipFile: |\n          # Lambda\u95a2\u6570\u306e\u30b3\u30fc\u30c9\u3092\u3053\u3053\u306b\u8a18\u8f09\uff08\u4e0a\u8a18\u306elambda_function.py\u306e\u5185\u5bb9\uff09\n      Role: !GetAtt LambdaExecutionRole.Arn\n      Timeout: 30\n\n  LambdaExecutionRole:\n    Type: AWS::IAM::Role\n    Properties:\n      AssumeRolePolicyDocument:\n        Version: '2012-10-17'\n        Statement:\n          - Effect: Allow\n            Principal:\n              Service: lambda.amazonaws.com\n            Action: sts:AssumeRole\n      ManagedPolicyArns:\n        - arn:aws:iam::aws:policy\/service-role\/AWSLambdaBasicExecutionRole\n\n  ApiGateway:\n    Type: AWS::ApiGatewayV2::Api\n    Properties:\n      Name: locust-test-api\n      ProtocolType: HTTP\n\n  ApiIntegration:\n    Type: AWS::ApiGatewayV2::Integration\n    Properties:\n      ApiId: !Ref ApiGateway\n      IntegrationType: AWS_PROXY\n      IntegrationUri: !GetAtt ApiFunction.Arn\n      PayloadFormatVersion: '2.0'\n\n  ApiRouteProxy:\n    Type: AWS::ApiGatewayV2::Route\n    Properties:\n      ApiId: !Ref ApiGateway\n      RouteKey: 'ANY \/{proxy+}'\n      Target: !Join ['\/', ['integrations', !Ref ApiIntegration]]\n\n  ApiRouteRoot:\n    Type: AWS::ApiGatewayV2::Route\n    Properties:\n      ApiId: !Ref ApiGateway\n      RouteKey: 'ANY \/'\n      Target: !Join ['\/', ['integrations', !Ref ApiIntegration]]\n\n  ApiStage:\n    Type: AWS::ApiGatewayV2::Stage\n    Properties:\n      ApiId: !Ref ApiGateway\n      StageName: $default\n      AutoDeploy: true\n\n  LambdaPermission:\n    Type: AWS::Lambda::Permission\n    Properties:\n      FunctionName: !Ref ApiFunction\n      Action: lambda:InvokeFunction\n      Principal: apigateway.amazonaws.com\n      SourceArn: !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGateway}\/*'\n\nOutputs:\n  ApiEndpoint:\n    Value: !GetAtt ApiGateway.ApiEndpoint\n    Description: API Gateway endpoint URL\n<\/pre>\n<h5>\u30c7\u30d7\u30ed\u30a4<\/h5>\n<pre class=\"lang:bash decode:true\">\n# \u76f4\u63a5\u30c7\u30d7\u30ed\u30a4\naws cloudformation deploy \\\n  --template-file api-gateway.yaml \\\n  --stack-name locust-test-api \\\n  --capabilities CAPABILITY_IAM\n<\/pre>\n<h4>\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8URL\u306e\u53d6\u5f97<\/h4>\n<pre class=\"lang:bash decode:true\">\naws cloudformation describe-stacks \\\n  --stack-name locust-test-api \\\n  --query 'Stacks[0].Outputs[?OutputKey==<code>ApiEndpoint<\/code>].OutputValue' \\\n  --output text\n<\/pre>\n<p>\u51fa\u529b\u4f8b: <code>https:\/\/abc123.execute-api.ap-northeast-1.amazonaws.com<\/code><\/p>\n<p><a id=\"locust-scenario\"><\/a><\/p>\n<h2>Locust\u30c6\u30b9\u30c8\u30b7\u30ca\u30ea\u30aa\u306e\u4f5c\u6210<\/h2>\n<p>\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u30b7\u30ca\u30ea\u30aa\u3092Python\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n<code>locustfile_api_test.py<\/code>\u3092\u4f5c\u6210<\/p>\n<pre class=\"lang:python decode:true\" title=\"locustfile_api_test.py\">\nfrom locust import HttpUser, task, between\n\nclass APIUser(HttpUser):\n    wait_time = between(1, 3)\n\n    @task(3)\n    def get_users(self):\n        \"\"\"\u30e6\u30fc\u30b6\u30fc\u4e00\u89a7\u53d6\u5f97API\"\"\"\n        self.client.get(\"\/api\/users\")\n\n    @task(2)\n    def get_user_detail(self):\n        \"\"\"\u30e6\u30fc\u30b6\u30fc\u8a73\u7d30\u53d6\u5f97API\"\"\"\n        self.client.get(\"\/api\/users\/1\")\n\n    @task(1)\n    def create_user(self):\n        \"\"\"\u30e6\u30fc\u30b6\u30fc\u4f5c\u6210API\"\"\"\n        self.client.post(\"\/api\/users\", json={\n            \"name\": \"Test User\",\n            \"email\": \"test@example.com\"\n        })\n<\/pre>\n<h3>\u30dd\u30a4\u30f3\u30c8\u89e3\u8aac<\/h3>\n<ul>\n<li><code>HttpUser<\/code>: HTTP\/HTTPS\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u57fa\u5e95\u30af\u30e9\u30b9<\/li>\n<li><code>@task(\u6570\u5024)<\/code>: \u8ca0\u8377\u30c6\u30b9\u30c8\u3067\u5b9f\u884c\u3059\u308b\u30bf\u30b9\u30af\u3092\u5b9a\u7fa9\u3002\u6570\u5024\u306f\u5b9f\u884c\u983b\u5ea6\u306e\u91cd\u307f\uff083:2:1\u306e\u6bd4\u7387\u3067\u5b9f\u884c\uff09<\/li>\n<li><code>wait_time<\/code>: \u30ea\u30af\u30a8\u30b9\u30c8\u9593\u306e\u5f85\u6a5f\u6642\u9593\uff08\u5b9f\u969b\u306e\u30e6\u30fc\u30b6\u30fc\u884c\u52d5\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30c8\uff09<\/li>\n<li><code>on_start<\/code>: \u5404\u30e6\u30fc\u30b6\u30fc\u306e\u521d\u671f\u5316\u51e6\u7406\uff08\u5f8c\u8ff0\uff09<\/li>\n<\/ul>\n<h4>on_start\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066<\/h4>\n<p>\u4eca\u56de\u306e\u30b7\u30ca\u30ea\u30aa\u3067\u306f\u4f7f\u7528\u3057\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u8a8d\u8a3c\u304c\u5fc5\u8981\u306aAPI\u3092\u30c6\u30b9\u30c8\u3059\u308b\u5834\u5408\u306b\u91cd\u8981\u3067\u3059\u3002<\/p>\n<p><strong>\u4f7f\u7528\u4f8b\uff1a\u30ed\u30b0\u30a4\u30f3\u8a8d\u8a3c\u304c\u5fc5\u8981\u306a\u5834\u5408<\/strong><\/p>\n<pre class=\"lang:python decode:true\">\nclass APIUser(HttpUser):\n    wait_time = between(1, 3)\n\n    def on_start(self):\n        \"\"\"\u5404\u30e6\u30fc\u30b6\u30fc\u306e\u521d\u671f\u5316\u51e6\u7406\uff08\u6700\u521d\u306b1\u56de\u3060\u3051\u5b9f\u884c\uff09\"\"\"\n        # \u30ed\u30b0\u30a4\u30f3\u3057\u3066\u30c8\u30fc\u30af\u30f3\u3092\u53d6\u5f97\n        response = self.client.post(\"\/api\/login\", json={\n            \"username\": \"testuser\",\n            \"password\": \"password123\"\n        })\n        self.token = response.json()[\"token\"]\n\n    @task\n    def get_protected_resource(self):\n        \"\"\"\u8a8d\u8a3c\u304c\u5fc5\u8981\u306aAPI\u3092\u547c\u3073\u51fa\u3059\"\"\"\n        self.client.get(\"\/api\/protected\", headers={\n            \"Authorization\": f\"Bearer {self.token}\"\n        })\n<\/pre>\n<p><strong>on_start\u306e\u7528\u9014<\/strong><\/p>\n<ul>\n<li>\u30ed\u30b0\u30a4\u30f3\u51e6\u7406<\/li>\n<li>\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97<\/li>\n<li>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u6e96\u5099<\/li>\n<li>\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u521d\u671f\u5316<\/li>\n<\/ul>\n<p><a id=\"docker-setup\"><\/a><\/p>\n<h2>Docker\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210<\/h2>\n<p>\u6b21\u306b\u3001Locust\u3092\u52d5\u304b\u3059Docker\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n<code>Dockerfile<\/code>\u3092\u4f5c\u6210<\/p>\n<pre class=\"lang:dockerfile decode:true\" title=\"Dockerfile\">\nFROM python:3.12-slim\n\nWORKDIR \/app\n\nCOPY requirements.txt .\nRUN pip install --no-cache-dir -r requirements.txt\n\nCOPY locustfile_api_test.py .\n\nENTRYPOINT [\"locust\", \"-f\", \"locustfile_api_test.py\"]\n<\/pre>\n<p><code>requirements.txt<\/code>\u3092\u4f5c\u6210<\/p>\n<pre class=\"lang:text decode:true\" title=\"requirements.txt\">\nlocust\n<\/pre>\n<h3>\u30ed\u30fc\u30ab\u30eb\u3067\u306e\u52d5\u4f5c\u78ba\u8a8d<\/h3>\n<p>ECS\u306b\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u524d\u306b\u3001\u30ed\u30fc\u30ab\u30eb\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:bash decode:true\">\n# Docker\u30a4\u30e1\u30fc\u30b8\u3092\u30d3\u30eb\u30c9\ndocker build -t locust-api-test .\n\n# \u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\uff08WebUI\u30e2\u30fc\u30c9\uff09\n# \u4f5c\u6210\u3057\u305fAPI Gateway\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8URL\u3092\u6307\u5b9a\ndocker run -p 8089:8089 locust-api-test --host=https:\/\/abc123.execute-api.ap-northeast-1.amazonaws.com\n\n# \u30d6\u30e9\u30a6\u30b6\u3067 http:\/\/localhost:8089 \u306b\u30a2\u30af\u30bb\u30b9\n<\/pre>\n<p>WebUI\u304c\u8868\u793a\u3055\u308c\u305f\u3089\u6210\u529f\u3067\u3059\uff01<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-webui.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-webui-1024x432.png\" alt=\"\" \/><\/a><\/p>\n<h3>ECR\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5<\/h3>\n<pre class=\"lang:bash decode:true\">\n# ECR\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\naws ecr create-repository --repository-name locust-api-test\n\n# ECR\u306b\u30ed\u30b0\u30a4\u30f3\naws ecr get-login-password --region ap-northeast-1 | \\\n  docker login --username AWS --password-stdin \u30a2\u30ab\u30a6\u30f3\u30c8ID.dkr.ecr.ap-northeast-1.amazonaws.com\n\n# \u30a4\u30e1\u30fc\u30b8\u306b\u30bf\u30b0\u3092\u4ed8\u3051\u308b\ndocker tag locust-api-test:latest \\\n  \u30a2\u30ab\u30a6\u30f3\u30c8ID.dkr.ecr.ap-northeast-1.amazonaws.com\/locust-api-test:latest\n\n# \u30d7\u30c3\u30b7\u30e5\ndocker push \u30a2\u30ab\u30a6\u30f3\u30c8ID.dkr.ecr.ap-northeast-1.amazonaws.com\/locust-api-test:latest\n<\/pre>\n<h3>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u8a2d\u5b9a<\/h3>\n<p>Locust WebUI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u30dd\u30fc\u30c8<\/th>\n<th>\u30d7\u30ed\u30c8\u30b3\u30eb<\/th>\n<th>\u9001\u4fe1\u5143<\/th>\n<th>\u7528\u9014<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>8089<\/td>\n<td>TCP<\/td>\n<td>\u81ea\u5206\u306eIP\/32<\/td>\n<td>WebUI<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u26a0\ufe0f <strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u6ce8\u610f<\/strong><\/p>\n<ul>\n<li>\u672c\u756a\u74b0\u5883\u3067\u306f\u3001\u5fc5\u305a\u7279\u5b9a\u306eIP\u30a2\u30c9\u30ec\u30b9\u306b\u5236\u9650\u3057\u3066\u304f\u3060\u3055\u3044<\/li>\n<li>\u793e\u5185\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u306e\u5834\u5408\u306f\u3001\u4f1a\u793e\u306eIP\u30ec\u30f3\u30b8\u3092\u6307\u5b9a\u3057\u307e\u3057\u3087\u3046<\/li>\n<\/ul>\n<p><a id=\"ecs-setup\"><\/a><\/p>\n<h2>ECS\u74b0\u5883\u306e\u69cb\u7bc9<\/h2>\n<h3>ECS\u30bf\u30b9\u30af\u5b9a\u7fa9\u306e\u4f5c\u6210<\/h3>\n<p><code>task-definition.json<\/code>\u3092\u4f5c\u6210<\/p>\n<pre class=\"lang:json decode:true\" title=\"task-definition.json\">\n{\n  \"family\": \"locust-api-test\",\n  \"networkMode\": \"awsvpc\",\n  \"requiresCompatibilities\": [\"FARGATE\"],\n  \"cpu\": \"1024\",\n  \"memory\": \"2048\",\n  \"executionRoleArn\": \"arn:aws:iam::\u30a2\u30ab\u30a6\u30f3\u30c8ID:role\/ecsTaskExecutionRole\",\n  \"containerDefinitions\": [\n    {\n      \"name\": \"locust-master\",\n      \"image\": \"\u30a2\u30ab\u30a6\u30f3\u30c8ID.dkr.ecr.ap-northeast-1.amazonaws.com\/locust-api-test:latest\",\n      \"essential\": true,\n      \"portMappings\": [\n        {\n          \"containerPort\": 8089,\n          \"protocol\": \"tcp\"\n        }\n      ],\n      \"command\": [\n        \"--host=\u53d6\u5f97\u3057\u305fAPI Gateway\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8URL\",\n        \"--web-host=0.0.0.0\",\n        \"--loglevel=INFO\"\n      ],\n      \"environment\": [\n        {\n          \"name\": \"PYTHONUNBUFFERED\",\n          \"value\": \"1\"\n        }\n      ],\n      \"logConfiguration\": {\n        \"logDriver\": \"awslogs\",\n        \"options\": {\n          \"awslogs-group\": \"\/ecs\/locust-api-test\",\n          \"awslogs-region\": \"ap-northeast-1\",\n          \"awslogs-stream-prefix\": \"locust\"\n        }\n      }\n    }\n  ]\n}\n<\/pre>\n<pre class=\"lang:bash decode:true\">\n# \u30bf\u30b9\u30af\u5b9a\u7fa9\u3092\u767b\u9332\naws ecs register-task-definition --cli-input-json file:\/\/task-definition.json\n\n# \u30af\u30e9\u30b9\u30bf\u30fc\u4f5c\u6210\naws ecs create-cluster --cluster-name locust-test-cluster\n\n# \u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\naws ecs create-service \\\n  --cluster locust-test-cluster \\\n  --service-name locust-api-test \\\n  --task-definition locust-api-test \\\n  --desired-count 1 \\\n  --launch-type FARGATE \\\n  --network-configuration \"awsvpcConfiguration={subnets=[subnet-xxxxx],securityGroups=[sg-xxxxx],assignPublicIp=ENABLED}\"\n<\/pre>\n<p>ECS Fargate\u3067Locust\u3092\u52d5\u304b\u3059\u6e96\u5099\u304c\u51fa\u6765\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-api-test.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-api-test-1024x418.png\" alt=\"\" \/><\/a><\/p>\n<p><a id=\"load-test\"><\/a><\/p>\n<h2>\u8ca0\u8377\u30c6\u30b9\u30c8\u306e\u5b9f\u884c<\/h2>\n<h3>WebUI\u3092\u4f7f\u3063\u305f\u5b9f\u884c<\/h3>\n<ol>\n<li>ECS\u30bf\u30b9\u30af\u306e\u30d1\u30d6\u30ea\u30c3\u30afIP\u3092\u78ba\u8a8d<\/li>\n<li>\u30d6\u30e9\u30a6\u30b6\u3067 <code>http:\/\/ECS\u306e\u30d1\u30d6\u30ea\u30c3\u30afIP\u30a2\u30c9\u30ec\u30b9:8089<\/code> \u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u4ee5\u4e0b\u3092\u5165\u529b:\n<ul>\n<li><strong>Number of users<\/strong>: 100\uff08\u540c\u6642\u63a5\u7d9a\u30e6\u30fc\u30b6\u30fc\u6570\uff09<\/li>\n<li><strong>Spawn rate<\/strong>: 10\uff081\u79d2\u3042\u305f\u308a\u306b\u8ffd\u52a0\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u6570\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\u300cStart swarming\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<\/ol>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-webui-ecs-1.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-webui-ecs-1-1024x479.png\" alt=\"\" \/><\/a>\n<h3>\u30d8\u30c3\u30c9\u30ec\u30b9\u30e2\u30fc\u30c9\uff08WebUI\u306a\u3057\uff09\u3067\u306e\u5b9f\u884c<\/h3>\n<p>\u81ea\u52d5\u5316\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u30d8\u30c3\u30c9\u30ec\u30b9\u30e2\u30fc\u30c9\u304c\u4fbf\u5229\u3067\u3059\u3002<br \/>\n\u30bf\u30b9\u30af\u5b9a\u7fa9\u306ecommand\u3092\u4ee5\u4e0b\u306b\u5909\u66f4:<\/p>\n<pre class=\"lang:default decode:true\">\n\"command\": [\n  \"--headless\",\n  \"--host=https:\/\/\u53d6\u5f97\u3057\u305fAPI Gateway\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8URL\",\n  \"-u\", \"100\",\n  \"-r\", \"10\",\n  \"-t\", \"5m\"\n]\n<\/pre>\n<ul>\n<li><code>-u<\/code>: \u30e6\u30fc\u30b6\u30fc\u6570<\/li>\n<li><code>-r<\/code>: \u5897\u52a0\u7387\uff08spawn rate\uff09<\/li>\n<li><code>-t<\/code>: \u30c6\u30b9\u30c8\u5b9f\u884c\u6642\u9593<\/li>\n<\/ul>\n<p><a id=\"test-results\"><\/a><\/p>\n<h2>\u8ca0\u8377\u30c6\u30b9\u30c8\u7d50\u679c\u78ba\u8a8d<\/h2>\n<p>\u8ca0\u8377\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u305f\u7d50\u679c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7d50\u679c\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-test-1.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-test-1-1024x302.png\" alt=\"\" \/><\/a><br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-test-2.png\"><img decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2025\/12\/locust-test-2-1024x670.png\" alt=\"\" \/><\/a><\/p>\n<p>\u8ca0\u8377\u8a66\u9a13\u306e\u7d50\u679c\u3092\u3001\u50d5\u306e\u826f\u304d\u76f8\u68d2\u306e\u3001Amazon Q\u306b\u5206\u6790\u3057\u3066\u3082\u3089\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3>\u8ca0\u8377\u30c6\u30b9\u30c8\u7d50\u679c\u5206\u6790\u30ec\u30dd\u30fc\u30c8<\/h3>\n<hr \/>\n<h4>\ud83d\udcca \u7dcf\u5408\u8a55\u4fa1: A+ (\u512a\u79c0)<\/h4>\n<table>\n<thead>\n<tr>\n<th>\u6307\u6a19<\/th>\n<th>\u7d50\u679c<\/th>\n<th>\u8a55\u4fa1<\/th>\n<th>\u57fa\u6e96<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u5931\u6557\u7387<\/strong><\/td>\n<td>0%<\/td>\n<td>\ud83d\udfe2 \u512a\u79c0<\/td>\n<td>&lt; 1%<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5e73\u5747\u5fdc\u7b54\u6642\u9593<\/strong><\/td>\n<td>25.96ms<\/td>\n<td>\ud83d\udfe2 \u512a\u79c0<\/td>\n<td>&lt; 100ms<\/td>\n<\/tr>\n<tr>\n<td><strong>95\u30d1\u30fc\u30bb\u30f3\u30bf\u30a4\u30eb<\/strong><\/td>\n<td>41ms<\/td>\n<td>\ud83d\udfe2 \u512a\u79c0<\/td>\n<td>&lt; 500ms<\/td>\n<\/tr>\n<tr>\n<td><strong>\u30b9\u30eb\u30fc\u30d7\u30c3\u30c8<\/strong><\/td>\n<td>51.6 RPS<\/td>\n<td>\ud83d\udfe2 \u9ad8\u6027\u80fd<\/td>\n<td>-<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\ud83d\udd0d \u8a73\u7d30\u5206\u6790<\/h4>\n<h5>\u30c6\u30b9\u30c8\u7d50\u679c\u30b5\u30de\u30ea\u30fc<\/h5>\n<table>\n<thead>\n<tr>\n<th>Type<\/th>\n<th>Name<\/th>\n<th># Requests<\/th>\n<th># Fails<\/th>\n<th>Median (ms)<\/th>\n<th>95%ile (ms)<\/th>\n<th>99%ile (ms)<\/th>\n<th>Average (ms)<\/th>\n<th>Min (ms)<\/th>\n<th>Max (ms)<\/th>\n<th>Average size (bytes)<\/th>\n<th>Current RPS<\/th>\n<th>Current Failures\/s<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>GET<\/td>\n<td>\/api\/users<\/td>\n<td>1,269<\/td>\n<td>0<\/td>\n<td>23<\/td>\n<td>42<\/td>\n<td>64<\/td>\n<td>25.61<\/td>\n<td>16<\/td>\n<td>318<\/td>\n<td>118<\/td>\n<td>27<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>POST<\/td>\n<td>\/api\/users<\/td>\n<td>440<\/td>\n<td>0<\/td>\n<td>22<\/td>\n<td>40<\/td>\n<td>75<\/td>\n<td>26.09<\/td>\n<td>17<\/td>\n<td>300<\/td>\n<td>61<\/td>\n<td>9.5<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>\/api\/users\/1<\/td>\n<td>814<\/td>\n<td>0<\/td>\n<td>22<\/td>\n<td>41<\/td>\n<td>72<\/td>\n<td>26.43<\/td>\n<td>16<\/td>\n<td>377<\/td>\n<td>57<\/td>\n<td>15.1<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td><strong>Aggregated<\/strong><\/td>\n<td><strong>-<\/strong><\/td>\n<td><strong>2,523<\/strong><\/td>\n<td><strong>0<\/strong><\/td>\n<td><strong>22<\/strong><\/td>\n<td><strong>41<\/strong><\/td>\n<td><strong>66<\/strong><\/td>\n<td><strong>25.96<\/strong><\/td>\n<td><strong>16<\/strong><\/td>\n<td><strong>377<\/strong><\/td>\n<td><strong>88.38<\/strong><\/td>\n<td><strong>51.6<\/strong><\/td>\n<td><strong>0<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>1. \u5fdc\u7b54\u6642\u9593\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/h5>\n<ul>\n<li><strong>\u4e2d\u592e\u5024<\/strong>: 22ms (50%\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u304c22ms\u4ee5\u5185)<\/li>\n<li><strong>95\u30d1\u30fc\u30bb\u30f3\u30bf\u30a4\u30eb<\/strong>: 41ms (95%\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u304c41ms\u4ee5\u5185)<\/li>\n<li><strong>99\u30d1\u30fc\u30bb\u30f3\u30bf\u30a4\u30eb<\/strong>: 66ms (99%\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u304c66ms\u4ee5\u5185)<\/li>\n<li><strong>\u6700\u5927\u5024<\/strong>: 377ms (\u4e00\u6642\u7684\u306a\u30b9\u30d1\u30a4\u30af\u3042\u308a)<\/li>\n<\/ul>\n<h5>2. \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u5225\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/h5>\n<pre><code>GET \/api\/users     : 25.61ms\u5e73\u5747 (1,269\u30ea\u30af\u30a8\u30b9\u30c8) - 27 RPS\nPOST \/api\/users    : 26.09ms\u5e73\u5747 (440\u30ea\u30af\u30a8\u30b9\u30c8)  - 9.5 RPS\nGET \/api\/users\/1   : 26.43ms\u5e73\u5747 (814\u30ea\u30af\u30a8\u30b9\u30c8)  - 15.1 RPS<\/code><\/pre>\n<p><strong>\u7d50\u679c<\/strong>: \u5168\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3067\u4e00\u8cab\u3057\u305f\u9ad8\u6027\u80fd\u3092\u5b9f\u73fe<\/p>\n<h5>3. \u30b9\u30eb\u30fc\u30d7\u30c3\u30c8\u5206\u6790<\/h5>\n<ul>\n<li><strong>\u7dcfRPS<\/strong>: 51.6 req\/s<\/li>\n<li><strong>\u7dcf\u30ea\u30af\u30a8\u30b9\u30c8\u6570<\/strong>: 2,523<\/li>\n<li><strong>\u5b9f\u884c\u6bd4\u7387<\/strong>: GET:POST:GET\u8a73\u7d30 \u2248 3:1:2 (\u8a2d\u8a08\u901a\u308a)<\/li>\n<li><strong>\u30c7\u30fc\u30bf\u8ee2\u9001<\/strong>: \u5e73\u574788.38 bytes\/request<\/li>\n<\/ul>\n<h4>\ud83c\udfaf \u30d9\u30f3\u30c1\u30de\u30fc\u30af\u6bd4\u8f03<\/h4>\n<table>\n<thead>\n<tr>\n<th>\u9805\u76ee<\/th>\n<th>\u4eca\u56de\u7d50\u679c<\/th>\n<th>\u4e00\u822c\u7684\u306a\u76ee\u6a19<\/th>\n<th>\u9054\u6210\u7387<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5fdc\u7b54\u6642\u9593<\/td>\n<td>25.96ms<\/td>\n<td>&lt; 200ms<\/td>\n<td>\u2705 <strong>87%\u6539\u5584<\/strong><\/td>\n<\/tr>\n<tr>\n<td>95%ile<\/td>\n<td>41ms<\/td>\n<td>99.9%<\/td>\n<td>\u2705 <strong>100%\u9054\u6210<\/strong><\/td>\n<\/tr>\n<tr>\n<td>\u5931\u6557\u7387<\/td>\n<td>0%<\/td>\n<td>&lt; 1%<\/td>\n<td>\u2705 <strong>\u5b8c\u5168\u6210\u529f<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\ud83d\udcc8 \u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u4e88\u6e2c<\/h4>\n<p>\u73fe\u5728\u306e\u6027\u80fd\u304b\u3089\u63a8\u5b9a\u3055\u308c\u308b\u51e6\u7406\u80fd\u529b\uff1a<\/p>\n<ul>\n<li><strong>1\u5206\u9593<\/strong>: \u7d043,100\u30ea\u30af\u30a8\u30b9\u30c8<\/li>\n<li><strong>1\u6642\u9593<\/strong>: \u7d04186,000\u30ea\u30af\u30a8\u30b9\u30c8  <\/li>\n<li><strong>1\u65e5<\/strong>: \u7d04450\u4e07\u30ea\u30af\u30a8\u30b9\u30c8<\/li>\n<li><strong>\u6708\u9593<\/strong>: \u7d041.35\u5104\u30ea\u30af\u30a8\u30b9\u30c8<\/li>\n<\/ul>\n<h4>\u26a0\ufe0f \u6ce8\u610f\u70b9\u3068\u6539\u5584\u63d0\u6848<\/h4>\n<h5>1. \u6700\u5927\u5fdc\u7b54\u6642\u9593\u306e\u30b9\u30d1\u30a4\u30af<\/h5>\n<p><strong>\u554f\u984c<\/strong>: 377ms\u306e\u6700\u5927\u5fdc\u7b54\u6642\u9593<\/p>\n<ul>\n<li><strong>\u539f\u56e0<\/strong>: Lambda\u51b7\u5374\u8d77\u52d5\u306e\u53ef\u80fd\u6027<\/li>\n<li><strong>\u5bfe\u7b56<\/strong>:\n<ul>\n<li>Provisioned Concurrency\u8a2d\u5b9a<\/li>\n<li>\u30e1\u30e2\u30ea\u5897\u52a0 (128MB \u2192 256MB)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>2. \u8ca0\u8377\u30ec\u30d9\u30eb<\/h5>\n<p><strong>\u73fe\u72b6<\/strong>: \u6bd4\u8f03\u7684\u8efd\u3044\u8ca0\u8377\u3067\u306e\u7d50\u679c<\/p>\n<ul>\n<li><strong>\u63d0\u6848<\/strong>: \u3088\u308a\u9ad8\u8ca0\u8377\u3067\u306e\u30c6\u30b9\u30c8\u5b9f\u65bd\n<pre><code>Users: 100-500\nDuration: 10-30\u5206\nRamp-up: \u6bb5\u968e\u7684\u8ca0\u8377\u5897\u52a0<\/code><\/pre>\n<\/li>\n<\/ul>\n<h5>3. \u76e3\u8996\u5f37\u5316<\/h5>\n<p><strong>\u63a8\u5968\u8a2d\u5b9a<\/strong>:<\/p>\n<ul>\n<li>CloudWatch \u30e1\u30c8\u30ea\u30af\u30b9\u8ffd\u52a0<\/li>\n<li>X-Ray \u30c8\u30ec\u30fc\u30b7\u30f3\u30b0\u6709\u52b9\u5316<\/li>\n<li>\u30ab\u30b9\u30bf\u30e0\u30e1\u30c8\u30ea\u30af\u30b9\u8a2d\u5b9a<\/li>\n<\/ul>\n<h4>\ud83d\ude80 \u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/h4>\n<h5>\u77ed\u671f\u7684\u6539\u5584 (1-2\u9031\u9593)<\/h5>\n<ol>\n<li>\n<p><strong>Lambda\u6700\u9069\u5316<\/strong><\/p>\n<ul>\n<li>\u30e1\u30e2\u30ea\u8a2d\u5b9a: 128MB \u2192 256MB<\/li>\n<li>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8: 30\u79d2 \u2192 15\u79d2<\/li>\n<li>\u74b0\u5883\u5909\u6570\u6700\u9069\u5316<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9ad8\u8ca0\u8377\u30c6\u30b9\u30c8\u5b9f\u65bd<\/strong><\/p>\n<ul>\n<li>\u540c\u6642\u30e6\u30fc\u30b6\u30fc\u6570: 100-500<\/li>\n<li>\u5b9f\u884c\u6642\u9593: 30\u5206<\/li>\n<li>\u6bb5\u968e\u7684\u8ca0\u8377\u5897\u52a0<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h5>\u4e2d\u671f\u7684\u6539\u5584 (1-2\u30f6\u6708)<\/h5>\n<ol>\n<li><strong>Provisioned Concurrency\u5c0e\u5165<\/strong><\/li>\n<li><strong>API Gateway \u30ad\u30e3\u30c3\u30b7\u30e5\u8a2d\u5b9a<\/strong><\/li>\n<li><strong>CloudFront\u5c0e\u5165\u691c\u8a0e<\/strong><\/li>\n<\/ol>\n<h5>\u9577\u671f\u7684\u6539\u5584 (3-6\u30f6\u6708)<\/h5>\n<ol>\n<li><strong>\u5206\u6563\u8ca0\u8377\u30c6\u30b9\u30c8\u74b0\u5883\u69cb\u7bc9<\/strong><\/li>\n<li><strong>CI\/CD\u7d71\u5408<\/strong><\/li>\n<li><strong>\u81ea\u52d5\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u76e3\u8996<\/strong><\/li>\n<\/ol>\n<h4>\ud83c\udf89 \u7d50\u8ad6<\/h4>\n<p><strong>API Gateway + Lambda\u69cb\u6210\u306f\u512a\u79c0\u306a\u7d50\u679c<\/strong>\u3092\u793a\u3057\u307e\u3057\u305f<\/p>\n<p>\u2705 <strong>100%\u6210\u529f\u7387<\/strong> - \u5b8c\u5168\u306a\u53ef\u7528\u6027\u3092\u5b9f\u73fe<br \/>\n\u2705 <strong>25.96ms\u5e73\u5747\u5fdc\u7b54<\/strong> - \u975e\u5e38\u306b\u9ad8\u901f\u306a\u30ec\u30b9\u30dd\u30f3\u30b9<br \/>\n\u2705 <strong>51.6 RPS<\/strong> - \u9ad8\u3044\u30b9\u30eb\u30fc\u30d7\u30c3\u30c8\u3092\u9054\u6210<br \/>\n\u2705 <strong>\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9<\/strong> - \u7ba1\u7406\u4e0d\u8981\u3067\u904b\u7528\u30b3\u30b9\u30c8\u524a\u6e1b<\/p>\n<p>\u3053\u306e\u7d50\u679c\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u3082\u9ad8\u3044\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u4fe1\u983c\u6027\u3092\u5b9f\u73fe\u3067\u304d\u308b\u3053\u3068\u3092\u8a3c\u660e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>\ud83d\udccb \u30a2\u30af\u30b7\u30e7\u30f3\u30a2\u30a4\u30c6\u30e0<\/h4>\n<table>\n<thead>\n<tr>\n<th>\u512a\u5148\u5ea6<\/th>\n<th>\u30a2\u30af\u30b7\u30e7\u30f3<\/th>\n<th>\u62c5\u5f53<\/th>\n<th>\u671f\u9650<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9ad8<\/td>\n<td>Lambda \u30e1\u30e2\u30ea\u5897\u52a0<\/td>\n<td>DevOps<\/td>\n<td>1\u9031\u9593<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8<\/td>\n<td>\u9ad8\u8ca0\u8377\u30c6\u30b9\u30c8\u5b9f\u65bd<\/td>\n<td>QA<\/td>\n<td>2\u9031\u9593<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d<\/td>\n<td>Provisioned Concurrency\u691c\u8a0e<\/td>\n<td>Architecture<\/td>\n<td>1\u30f6\u6708<\/td>\n<\/tr>\n<tr>\n<td>\u4f4e<\/td>\n<td>\u76e3\u8996\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u4f5c\u6210<\/td>\n<td>DevOps<\/td>\n<td>2\u30f6\u6708<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>\u3068\u3001Amazon Q\u306f\u5206\u6790\u3057\u3066\u304f\u308c\u307e\u3057\u305f\uff01<\/p>\n<h2>\u3053\u3093\u306a\u6642\u306f...\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<h3>\u30bf\u30b9\u30af\u304c\u8d77\u52d5\u3057\u306a\u3044<\/h3>\n<ul>\n<li>CloudWatch Logs\u3067\u30a8\u30e9\u30fc\u3092\u78ba\u8a8d<\/li>\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d<\/li>\n<li>ECR\u30a4\u30e1\u30fc\u30b8\u306e\u30d7\u30eb\u306b\u5931\u6557\u3057\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d<\/li>\n<\/ul>\n<h3>API\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u5c4a\u304b\u306a\u3044<\/h3>\n<ul>\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u8a2d\u5b9a\uff08VPC\u3001\u30b5\u30d6\u30cd\u30c3\u30c8\uff09\u3092\u78ba\u8a8d<\/li>\n<li>NAT\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\uff08\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b5\u30d6\u30cd\u30c3\u30c8\u306e\u5834\u5408\uff09<\/li>\n<li>API\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u3067ECS\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef<\/li>\n<\/ul>\n<h3>\u5fdc\u7b54\u6642\u9593\u304c\u9045\u3044<\/h3>\n<ul>\n<li>ECS\u30bf\u30b9\u30af\u306eCPU\/\u30e1\u30e2\u30ea\u3092\u5897\u3084\u3059<\/li>\n<li>Worker\u3092\u8ffd\u52a0\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5206\u6563<\/li>\n<li>API\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u8a2d\u5b9a\u3092\u78ba\u8a8d<\/li>\n<\/ul>\n<p><a id=\"matome\"><\/a><\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>ECS Fargate\u3067\u8ca0\u8377\u30c6\u30b9\u30c8\u30c4\u30fc\u30ebLocust\u3092\u52d5\u304b\u3057\u3066\u3001API\u306b\u8ca0\u8377\u3092\u304b\u3051\u308b\u65b9\u6cd5\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h3>\u304a\u3055\u3089\u3044<\/h3>\n<p>\u2705 Locust\u306fPython\u3067\u7c21\u5358\u306b\u8ca0\u8377\u30c6\u30b9\u30c8\u30b7\u30ca\u30ea\u30aa\u3092\u66f8\u3051\u308b<br \/>\n\u2705 ECS Fargate\u3067\u30b5\u30fc\u30d0\u30fc\u7ba1\u7406\u4e0d\u8981\u3067\u5b9f\u884c\u3067\u304d\u308b<br \/>\n\u2705 WebUI\u3067\u7d50\u679c\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u78ba\u8a8d\u3067\u304d\u308b<\/p>\n<h3>\u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/h3>\n<ul>\n<li>Locust\u306e\u5206\u6563\u5b9f\u884c\u6a5f\u80fd\uff08Master-Worker\u69cb\u6210\uff09\u3067\u8ca0\u8377\u8a66\u9a13\u3057\u3066\u307f\u308b<\/li>\n<li>\u3088\u308a\u8907\u96d1\u306a\u30b7\u30ca\u30ea\u30aa\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b<\/li>\n<li>CloudWatch Metrics\u3068\u9023\u643a\u3057\u3066\u76e3\u8996\u3092\u5f37\u5316<\/li>\n<li>\u30ab\u30b9\u30bf\u30e0\u30ec\u30dd\u30fc\u30c8\u306e\u4f5c\u6210<\/li>\n<\/ul>\n<p>\u8ca0\u8377\u30c6\u30b9\u30c8\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u6027\u80fd\u3092\u628a\u63e1\u3057\u3001\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u3092\u767a\u898b\u3059\u308b\u305f\u3081\u306b\u91cd\u8981\u3067\u3059\u3002\u305c\u3072\u3001\u3053\u306e\u8a18\u4e8b\u3092\u53c2\u8003\u306b\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff01<br \/>\n\u6b21\u56de\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001Master-Worker\u69cb\u6210\u306e\u691c\u8a3c\u3092\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u53c2\u8003\u30ea\u30f3\u30af<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.locust.io\/\">Locust\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\n<li><a href=\"https:\/\/aws.amazon.com\/fargate\/\">AWS ECS Fargate<\/a><\/li>\n<li><a href=\"https:\/\/aws.amazon.com\/ecr\/\">AWS ECR<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u696d\u52d9\u3067\u8ca0\u8377\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u300cLocust\u300d\u3092\u4f7f\u3046\u6a5f\u4f1a\u304c\u3042\u308a\u3001AWS ECS Fargate\u4e0a\u3067Locust\u3092\u52d5\u304b\u3057\u3066\u3001API\u306b\u8ca0\u8377\u3092\u304b\u3051\u308b\u691c\u8a3c\u3092\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002 Locust\u3092\u4f7f\u3048\u3070Python\u3067\u7c21\u5358\u306b\u8ca0\u8377\u30c6\u30b9\u30c8\u306e&#8230;<\/p>\n","protected":false},"author":212,"featured_media":30263,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/www.skyarch.net\/blog\/?p=30093","footnotes":""},"categories":[20,515,1,26],"tags":[],"class_list":{"0":"post-30093","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-fargate","9":"category-1","10":"category-26","11":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/30093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/212"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=30093"}],"version-history":[{"count":27,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/30093\/revisions"}],"predecessor-version":[{"id":30365,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/30093\/revisions\/30365"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/30263"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=30093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=30093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=30093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}