Slide 1

Slide 1 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 1st July 2020 Kensuke Shimokawa AWS Lambda Provisioned Concurrency Dive Deep & Practice @_kensh

Slide 2

Slide 2 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Who am I? Name Kensuke Shimokawa Company Amazon Web Services Japan K.K. Role Serverless Specialist Solutions Architect @_kensh

Slide 3

Slide 3 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Table of contents • Day1 24th June • How to manage throttling • Day2 1st July • Provisioned Concurrency Dive Deep & Practice

Slide 4

Slide 4 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda Provisioned Concurrency の基本

Slide 5

Slide 5 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのインスタンスライフサイクル Cold Start コンテナ 生成 パッケージ ロード パッケージ 展開 ランタイム ・ 起動初期化 関数 ・ メソッド起動 デプロイ Warm Start https://d1.awsstatic.com/whitepapers/Overview-AWS-Lambda-Security.pdf

Slide 6

Slide 6 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Concurrency model 初期化処理 Cold Start Warm Start ハンドラー処理 ② ① ③

Slide 7

Slide 7 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Warm Start 事前暖機 Warm Start 初期化処理 ハンドラー処理

Slide 8

Slide 8 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Metrics Metrics 説明 ProvisionedConcurrencyInvocations プロビジョニングされた同時実行で関数コードが実行さ れる回数 ProvisionedConcurrencySpilloverInvocations プロビジョニングされたすべての同時実行が使用されて いるときに、標準同時実行で関数コードが実行される回 数。 ProvisionedConcurrentExecutions プロビジョニングされた同時実行でイベントを処理して いる関数インスタンスの数。プロビジョニングされた同 時実行数を割り当てたエイリアスまたはバージョンの呼 び出しごとに、Lambda は現在のカウントを出力します。 ProvisionedConcurrencyUtilization バージョンまたはエイリアスの場合、 ProvisionedConcurrentExecutions の値を、割り当て済み のプロビジョニングされた同時実行の合計量で割った値。 たとえば、.5 は、割り当て済みのプロビジョニングされ た同時実行数の 50% が使用中であることを示します。 https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html

Slide 9

Slide 9 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Concurrency time = 1.0 = 100% ProvisionedConcurrencyUtilization Provisioned Concurrency = 0.5 = 50%

Slide 10

Slide 10 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Concurrency time Provisioned Concurrency ProvisionedConcurrencyUtilization = 1.0 = 100%

Slide 11

Slide 11 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Concurrency time Provisioned Concurrency SpillOver = 溢れ出た部分 = On Demand ProvisionedConcurrencyUtilization = 1.0 = 100%

Slide 12

Slide 12 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Concurrency time Provisioned Concurrency SpillOver => ColdStart ProvisionedConcurrencyUtilization = 1.0 = 100% SpillOver => WarmStart ※Lambdaインスタンスが回収されず 再利用された場合

Slide 13

Slide 13 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Concurrency time Provisioned Concurrency SpillOver => ColdStart ProvisionedConcurrencyUtilization = 1.0 = 100% SpillOver = On Demand => WarmStart => ColdStart

Slide 14

Slide 14 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース

Slide 15

Slide 15 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース (Note) Provisioned Concurrencyのユースケースをこれから紹介しますが、Lambdaは、 Provisioned Concurrencyを利用しなくても、スケーラブルなフルマネージド サービスです。 まずは、シンプルさを大事にし、通常のLambdaのスケーラビリティでPoCして みることから始めてください。

Slide 16

Slide 16 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース • 予想できるスパイクへの対処 • Cold Startの抑制 • AWS Lambdaのバースト制限抑制

Slide 17

Slide 17 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース • 予想できるスパイクへの対処 • Cold Startの抑制 • AWS Lambdaのバースト制限抑制

Slide 18

Slide 18 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 予想できるスパイクへの対処 Concurrency time Provisioned Concurrency SpillOver

Slide 19

Slide 19 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 予想できるスパイクへの対処 Concurrency time Provisioned Concurrency SpillOver 11:45 12:00 12:15 ProvisionedConcurrencyUtilization = 1.0 = 100%

Slide 20

Slide 20 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 予想できるスパイクへの対処 Concurrency time Provisioned Concurrency 11:45 12:00 12:15 Amazon EventBridge ProvisionedConcurrencyUtilization = 0.8= 80% = 0.8= 80% スケールアウト スケールイン

Slide 21

Slide 21 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース • 予想できるスパイクへの対処 • Cold Startの抑制 • リクエスト数はそんなにないが、UXのために遅延を回避したい • AWS Lambdaのバースト制限抑制

Slide 22

Slide 22 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (認証認可トリガーなど) Concurrency time サインアップ前 Lambda トリガー Amazon Cognito User Pool サインアップ 承認要求 OK https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html

Slide 23

Slide 23 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (認証認可トリガーなど) Concurrency time サインアップ前 Lambda トリガー Amazon Cognito User Pool サインアップ 承認要求 OK ColdStart ※Lambdaインスタンスが回収され 再利用されなかった場合 https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html

Slide 24

Slide 24 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (認証認可トリガーなど) Concurrency time Provisioned Concurrency サインアップ前 Lambda トリガー Amazon Cognito User Pool サインアップ 承認要求 OK WarmStart https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html

Slide 25

Slide 25 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース • 予想できるスパイクへの対処 • Cold Startの抑制 • Java VMなど立ち上がると高速処理が期待できるruntimeを暖機 • AWS Lambdaのバースト制限抑制

Slide 26

Slide 26 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (リクエストの波があるJVMシステムなど) Concurrency time ColdStart ColdStart ColdStart 初期処理が重たいRuntimeは立ち上がりにColdStartを誘発

Slide 27

Slide 27 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (リクエストの波があるJVMシステムなど) Concurrency time Provisioned Concurrency WarmStart WarmStart WarmStart ProvisionedConcurrencyを使えば、ColdStartは抑制される

Slide 28

Slide 28 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (リクエストの波があるJVMシステムなど) Concurrency time Provisioned Concurrency WarmStart WarmStart WarmStart ProvisionedConcurrencyを使えば、ColdStartは抑制される 余分なConcurrency = コスト増大

Slide 29

Slide 29 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startの抑制 (リクエストの波があるJVMシステムなど) Concurrency time Provisioned Concurrency > 0.7 = 70% > 0.7 = 70% > 0.7 = 70% Amazon Application Auto Scalingを使って ProvisionedConcurrencyUtilizationに応じてスケール Amazon Application Auto Scaling

Slide 30

Slide 30 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Provisioned Concurrency Auto Scaling (AWS CDK) const target = new applicationautoscaling.ScalableTarget(this, 'ScalableTarget', { serviceNamespace: applicationautoscaling.ServiceNamespace.LAMBDA, maxCapacity: 100, minCapacity: 10, resourceId: `function:${handler.functionName}:${fnVer.version}`, scalableDimension: 'lambda:function:ProvisionedConcurrency', }) target.scaleToTrackMetric('PceTracking', { targetValue: 0.7, predefinedMetric: applicationautoscaling.PredefinedMetric .LAMBDA_PROVISIONED_CONCURRENCY_UTILIZATION, }) https://docs.aws.amazon.com/cdk/api/latest/docs/aws-applicationautoscaling-readme.html

Slide 31

Slide 31 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Provisioned Concurrency Auto Scaling (AWS SAM) MyScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: 100 MinCapacity: 10 ResourceId: !Sub function:${MyFunction}:live RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/[...]AWSServiceRoleForApplicationAutoScaling_LambdaConcurrency ScalableDimension: lambda:function:ProvisionedConcurrency ServiceNamespace: lambda DependsOn: MyFunctionAliaslive MyTargetTrackingScalingPolicy: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: utilization PolicyType: TargetTrackingScaling ScalingTargetId: !Ref MyScalableTarget TargetTrackingScalingPolicyConfiguration: TargetValue: 0.70 PredefinedMetricSpecification: PredefinedMetricType: LambdaProvisionedConcurrencyUtilization https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalabletarget.html https://aws.amazon.com/jp/blogs/aws/new-provisioned-concurrency-for-lambda-functions/

Slide 32

Slide 32 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency ユースケース • 予想できるスパイクへの対処 • Cold Startの抑制 • AWS Lambdaのバースト制限抑制 • https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/invocation-scaling.html

Slide 33

Slide 33 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Tokyo 1000

Slide 34

Slide 34 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Tokyo 1000 バーストでスケール

Slide 35

Slide 35 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Tokyo 1000 500/分でスケール バーストでスケール この制限されたスケールを緩和したい

Slide 36

Slide 36 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Tokyo 1000 500/分でスケール バーストでスケール この制限されたスケールを緩和したい ColdStart これも緩和したい

Slide 37

Slide 37 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Warmかつ、バーストでスケール Provisioned Concurrency WarmStart

Slide 38

Slide 38 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaのバースト制限抑制 Concurrency time バースト制限 アカウント同時実行数 (リミット制限緩和後) 1500 Provisioned Concurrency WarmStart レイテンシーが改善

Slide 39

Slide 39 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Practice

Slide 40

Slide 40 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Practice • デプロイに関するプラクティス • 実装に関するプラクティス • デザインパターンに関するプラクティス

Slide 41

Slide 41 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Practice • デプロイに関するプラクティス • 実装に関するプラクティス • デザインパターンに関するプラクティス

Slide 42

Slide 42 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned ConcurrencyのLambda Version指定について • Provisioned Concurrencyを利用するには、 Lambda関数のversion、または、aliasを発行 し指定する必要がある。 • Provisioningするversionはaliasが参照してい るversionを含めて、関数内で重複はできな い。 funcA (Provisioned Pool) prod(V5) V6 dev(V7) Lambda Instance

Slide 43

Slide 43 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned ConcurrencyのLambda Version指定について • Provisioned Concurrencyを利用するには、 Lambda関数のversion、または、aliasを発行 し指定する必要がある。 • Provisioningするversionはaliasが参照してい るversionを含めて、関数内で重複はできな い。 • ひとつのaliasに複数versionを梱包できる。 • 加重をかけることによりトラフィック の流れをコントロール可能 funcA (Provisioned Pool) funcB (Provisioned Pool) prod(V5) V6 dev(V7) Lambda Instance prod(V3, V4) dev(V6)

Slide 44

Slide 44 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned ConcurrencyのLambda Version指定について • Amazon API Gatewayの設定として、Lambda 関数プロキシ統合にターゲット関数を設定 • funcA:${stageVariables.alias} • AWS Lambda関数の設定として、aliasごとの リソースポリシー設定でAPI Gatewayからの 実行を許可 funcA (Provisioned Pool) prod(V5) V6 dev(V7) Endpoint Endpoint prod dev Amazon API Gateway

Slide 45

Slide 45 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned ConcurrencyのLambda Version指定について • Amazon API Gatewayのリクエストは加重に 合わせて、Lambda Versionにルーティングさ れる。 • prodでは60%がV3へ、残りの40%が V4に流れる funcB (Provisioned Pool) Endpoint Endpoint prod dev Amazon API Gateway prod(V3, V4) dev(V6)

Slide 46

Slide 46 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aliasの参照Versionを更新したら Invocations time alias更新(prod = V3→V4) V3 (provisioned) V4 (on demand) V4 (provisioned) WarmStart WarmStart aliasを更新するとトラフィック は突如、新versionにシフトする ProvisionedConcurrencyInvocations Invocations

Slide 47

Slide 47 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aliasの参照Versionを更新したら Invocations time V3 (provisioned) aliasを更新するとトラフィック は突如、新versionにシフトする => ColdStartを誘発する V4 (on demand) V4 (provisioned) ColdStart WarmStart WarmStart これを緩和したい alias更新(prod = V3→V4) ProvisionedConcurrencyInvocations Invocations

Slide 48

Slide 48 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. alias トラフィック シフティング • AWS SAM を使用してサーバーレスアプリケーションを作成する場合、 CodeDeploy が組み込まれているため、Lambda を安全にデプロイできます。 https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/automating-updates-to-serverless-apps.html funcB: Type: AWS::Serverless::Function Properties: Runtime: python3.8 Handler: index.handler AutoPublishAlias: !Ref Stage DeploymentPreference: Enabled: true Type: Linear10PercentEvery1Minute

Slide 49

Slide 49 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aliasの参照Versionを更新したら with AWS SAM Invocations time V3 (provisioned) トラフィックを段階的に新versionに シフトする => ColdStartを抑制する V3 & V4 (deploying) V4 (provisioned) WarmStart WarmStart WarmStart alias更新(prod = V3→V4 ) 10% ProvisionedConcurrencyInvocations Invocations 20% 90% 80% 30% 100%

Slide 50

Slide 50 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Practice • デプロイに関するプラクティス • 実装に関するプラクティス • デザインパターンに関するプラクティス

Slide 51

Slide 51 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cold Startを緩和する実装 (全てのRuntime共通) • ハンドラー外で • 初期化処理を実装 • 必須処理やObject生成処理など • ただしリクエスト独立性が必要 • 外部接続処理を実装(AWSサービスやAWS外のリソースに接続) • DBコネクション • TLSハンドシェイク • 接続先のタイムアウトにも注意 • ハンドラー内で • Globalに初期化データがあれば流用、なければ再作成しGlobalに格納 • コネクションタイムアウトなどに対応

Slide 52

Slide 52 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Java についてのTips for Cold Start • Static Blockで処理 • クラスロード、インスタンス化などをハンドラー外に書く • リフレクション、動的オブジェクト生成、Proxyオブジェクトは避ける private static Map headers = new HashMap<>(); static { headers.put("Content-Type", "application/json"); headers.put("X-Custom-Header", "application/json"); }

Slide 53

Slide 53 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Python についてのTips for Cold Start • import は、ハンドラー外で実行 • デコレータはシンプルに実装 • Fat-Heavy デコレータにしない • 関心ごとの分離は良いが、無関心にデコレーションしない • 慣用デコレーションは必要の有無を確認する

Slide 54

Slide 54 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Node.js についてのTips for Cold Start • CallBackをGlobalでコールした場合、Handler実行が始まってからも処理を継 続する場合がある(非同期) • Globalでのawait つまり、Top-level `await`が現状不可のため、 Globalでの初期化処理は同期的な処理系を採用する必要がある

Slide 55

Slide 55 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency Practice • デプロイに関するプラクティス • 実装に関するプラクティス • デザインパターンに関するプラクティス

Slide 56

Slide 56 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Concurrency Quotaの共有範囲 • Concurrency Quotaは、アカウント、リージョン単位で共有される。 • デフォルトでConcurrency Quotaは1000 • Provisioned Concurrencyの設定値もこの共有の考えに従う • 900(デフォルト=1000-100)まで、Provisioned Concurrencyが設定可能 な場合、この900を複数の関数で分け合う必要がある

Slide 57

Slide 57 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 暖機したいAPI Provisioned Concurrency割り当て可能: 900 Endpoint Lambda function 900 provisioned

Slide 58

Slide 58 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 暖機したいAPIが複数ある場合 Provisioned Concurrency割り当て可能: 900 要件: 両APIとも600 rpsを満たしたい Endpoint Lambda function 300 Endpoint Lambda function 600 Duration (Warm) provisioned 500 ms(P99) 1000 ms(P99)

Slide 59

Slide 59 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 暖機したい関数が直列で複数ある場合 Provisioned Concurrency割り当て可能: 900 要件: 両関数とも600 tpsを満たしたい Endpoint Lambda function 300 600 Duration (Warm) provisioned 500 ms(P99) 1000 ms(P99) Lambda function

Slide 60

Slide 60 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 暖機したいAPIが多数ある場合 Provisioned Concurrency割り当て可能: 900 Provisioned Concurrency利用なら Dispatch Patternなど(後ほど説明)

Slide 61

Slide 61 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 暖機したいAPIが多数ある場合 Provisioned Concurrency割り当て可能: 900 (重要) システム全体アーキテクチャとして暖機APIが多数の場合 アーキテクチャデザインを見直すことも視野に入れる • 基本的な関数コードのチューニング • 非同期にできるか検討 • リージョン、アカウント分離 • Service Quota 緩和 • AWS Fargateなどのコンテナ化検討 Provisioned Concurrencyに頼らない

Slide 62

Slide 62 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Provisioned Concurrency割り当て可能: 900 Dispatch Pattern で実装として対応 900 provisioned 言語関数実装 def func1 def func3 def func2 def funcN dispatcher Dispatch Pattern - 複数関数を共通Quota消費で暖機

Slide 63

Slide 63 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Dispatch Pattern - 複数関数を共通Quota消費で暖機 Provisioned Concurrency割り当て可能: 900 Dispatch Pattern で実装として対応 900 provisioned 言語関数実装 def func1 def func3 def func2 def funcN dispatcher Monolambdas モノリスに回帰するので 本当にアーキテクチャ回避できないか検討

Slide 64

Slide 64 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. private static Map functions = new HashMap<>(); static { functions.put(0, App::lambda_a); functions.put(1, App::lambda_b); } public static Object lambda_a (final Object event, final Context context) { return new GatewayResponse("{\"message\":\"this is a.\"}", headers, 200); } public static Object lambda_b (final Object event, final Context context) { return new GatewayResponse("{\"message\":\"this is b.\"}", headers, 200); } public Object handler(final Object event, final Context context) { Integer dispatch = router(event); Function function = functions.get(dispatch); return function.invoke(event, context); } Monolambdas(モノラムダ) かつて個々のLambda関数であった機能を 言語内関数に移植 Dispatch Pattern - 複数関数を共通Quota消費で暖機 (Javaの例)

Slide 65

Slide 65 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ • まずはProvisioned Concurrencyを利用しなくても通常のLambdaのフルマネー ジドなスケーラビリティでアーキテクティングしてみる • どうしても暖機が必要なケースや、スパイクするイベントに対応が必要な場 合にProvisioned Concurrencyを部分利用する • (アーキテクチャやコードチューニングの免罪符ではない) • 多くの関数を暖機する必要がある場合、それに至ったアーキテクチャに無理 がないか検討した上で、Quotaの制限に対応するためにアカウント/リージョ ンを分けたりQuotaの制限緩和を実施する

Slide 66

Slide 66 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you ! @_kensh

Slide 67

Slide 67 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Appendix

Slide 68

Slide 68 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaの制限 (追加) Metrics 説明 リージョンあたりの呼び出し頻度 (リクエスト数/秒) 10 倍の同時実行数の制限 (同期的 – すべてのリソース) 10 倍の同時実行数の制限 ( 非同期的 – AWS以外のソース) 無制限 (非同期的 – AWS サービスのソース) 関数のバージョンまたはエイリアスあたりの 呼び出し頻度 (リクエスト数/秒) 10 x 割り当て済みのプロビジョニングされた同時実行数 この制限は、プロビジョニングされた同時実行数を使用 する関数にのみ適用されます。