PHP on Lambda with Custom Runtimes - Ian Littman

Php

Learn how to run PHP on AWS Lambda with custom runtimes, including bootstrapping, layers, concurrency, and more, using Bref and CloudFormation.

Key takeaways
  • Custom Runtimes in Lambda: You can use a custom runtime in Lambda, which allows you to upload your own PHP runtime.
  • Bootstrapping: The bootstrapping process involves running a custom bootstrap file to set up the runtime.
  • Layers: You can create custom layers for your runtime, which can be used to share code between functions.
  • Function Concurrency: You can set the concurrency level for your Lambda functions, which determines how many requests can be handled simultaneously.
  • Cold Start: Lambda functions can have a cold start, where it takes some time for the function to spin up and start processing requests.
  • Initialization Phase: The initialization phase of a Lambda function can take longer than the execution phase.
  • Function Duration: The function duration is the time it takes for a Lambda function to complete its execution.
  • Runtime Environment: The runtime environment for Lambda functions is based on Amazon Linux 2.
  • PHP on Lambda: PHP can be run on Lambda, but it requires a custom runtime and bootstrapping.
  • Bref: Bref is a serverless PHP framework that allows you to run PHP on Lambda.
  • Layers: You can create custom layers for your PHP runtime using Bref.
  • CloudFormation: CloudFormation can be used to deploy Lambda functions and custom runtimes.
  • API Gateway: API Gateway can be used to integrate with Lambda functions and handle API requests.
  • SES Processing: SES processing can be used to process email messages in a Lambda function.
  • Database Integration: You can integrate with a database using a Lambda function.
  • Concurrent Invocations: Lambda functions can handle concurrent invocations, but it may take some time for the function to spin up.
  • Timeouts: You can set timeouts for Lambda functions to determine how long they can run before they timeout.
  • Error Handling: Error handling can be done using Lambda functions.
  • Logging: Logging can be done using CloudWatch logs.
  • PHP Version: You can specify the PHP version used in your Lambda function.
  • CPU Time: CPU time is charged per millisecond in Lambda.