ボクココ

個人開発に関するテックブログ

Amazon Lambda の使い時について翻訳メモ

今作のAWSサービスの中でもっとも注目されているサービスの中の一つである、Amazon Lambdaについて。

これをいつ使うべきかについては公式ドキュメントにがっつり書いてあったので引用しよう。

When should I use AWS Lambda?

AWS Lambdaをいつ使いべきか?

  • The Amazon Elastic Compute Cloud (Amazon EC2) web service offers flexibility and a wide range of EC2 instance types to choose from. It gives you the option to customize operating systems, network and security settings, and the entire software stack, but you are responsible for provisioning capacity, monitoring fleet health and performance, and using Availability Zones for fault tolerance. EC2は高度な柔軟性と幅広いインスタンスタイプの選択を可能とする。OSやネットワーク、セキュリティ設定やソフトウェア選択のカスタマイズ性を得られるが、パフォーマンス監視やフォールトトレランスのための仕組みを自分で用意する必要がある。

  • Elastic Beanstalk offers an easy-to-use service for deploying and scaling applications onto Amazon EC2 in which you retain ownership and full control over the underlying EC2 instances. Elastic BeanstalkはEC2のオーナー権限とフルアクセスを持ちつつアプリケーションのデプロイとスケーリングを簡単にする方法を提供する。

AWS Lambda is a great alternative to using these other AWS compute services if you can write your application code in languages supported by AWS Lambda, and run within the standard runtime environment and resources provided by the service. AWS Lambdaは、もしあなたが特定のサポートされた言語のコード(Node.js or Java)を書くことができるなら、その他の AWSのEC2やBeanstalkなどの素晴らしい代替サービスとなる。AWS Lambda上で提供される実行環境とリソースの上で動くアプリケーションを実行することができる。

The higher-level abstraction that AWS Lambda offers is the convenience of your being responsible only for your code. AWS Lambda manages the compute fleet that offers a balance of memory, CPU, network and other resources.This is in exchange for flexibility, which means you cannot log in to compute instances, customize the operating system or language runtime.These constraints enable AWS Lambda to perform operational and administrative activities on your behalf, including provisioning capacity, monitoring fleet health, applying security patches, deploying your code, running a web service front end, and monitoring and logging your functions あなたはコードにだけ集中することができる。AWS Lambdaがメモリのバランス、CPU,ネットワークやその他のリソースを管理してくれる。柔軟性の代わりあなたは実行環境にログインすることはできないし、OSや言語の実行環境をカスタマイズすることはできない。これらの制約がAWS Lambdaの監視やセキュリティパッチ、デプロイ、ログ処理などを可能にしている。

これを調べるにあたった経緯

最近 Amazon API Gateway っていうもうひとつ注目すべきサービスが出てきて、Lambdaと組み合わせてサーバー立てずにサービス作ろうって流れがある。その一例がjaws-stack/JAWS · GitHubだ。

私のそもそものLambdaのイメージが、"AWS内のイベントが起きた時にそれがトリガとなって実行できるもの"という認識だった。そのためWebアプリサーバーとしてのLambdaの使い方は本来の使い方とはちょっと違うのではないのかな?と思ったというわけである。

結局のところ、Lambdaは色んな使い方できるよとしか書いてなかったので、新しいWebアプリ作成のためにLambdaを使うのは全然アリのようである。