2020年5月2日土曜日

AWS 構成を変更

Is it possible to kill/stop a running lambda function?

 1)You cannot kill a running lambda function. Though there is another way by which you can set concurrency limit to 0. This will stop it from starting any more executions.
$ aws lambda put-function-concurrency --function-name my-function --reserved-concurrent-executions 0

これだと、全てのインスタンスで止まってしまいます。緊急停止用途と理解します。

2)That's not what we should use lambda for

Ideally each lambda function should be only one function. A real one function of the programming language. Which not loop or even have state. And it should be able to run in parallel. This is functional paradigm

If you need to have state, use step function to call lambda. Even you just need to loop for pulling task but if it can take times longer than 1 minute you should use step function. All lambda function should be able to let itself die in 1 minute and so you could maintain that it will have only one of it alive in each minute

If you really need to ensure that it must have only one of it in each minute. You could use dynamodb or any other state keeper as a mutex, to let every lambda check that should it end itself when the mutex id was changed. Not that it will always have one lambda but it let old lambda kill itself when it know it not needed

なるほど、lambdaは、Stateレスが前提なのですね。
現状のエンジンをそのままLambda化するのは、難しそうだということが理解できました。

STEP FUNCTIONを使って、API化することは技術的には可能でしょうが、そのための開発負荷が半端ではなくなってしまいます。オーバヘッドも無視できないですし、本筋以外での課金は、避けたいです。

そこで、APIGateWayを通さずに直接に、直接にユーザがLambdaを呼ぶ方法に改めたいと思います。当然のことながら、顧客もAWSアカウントを持つ必要がありますが、元々持っているならば障害にはなりません。

0 件のコメント:

コメントを投稿