2 Lightning talks ⚡
(Aiming to be beginner friendly as possible)
- What is Serverless? (10 Minutes)
- What is bref php? (5 Minutes)
- Live demo ("What could go wrong™")
Let's add a user
login system 🎉
Let's add a user
login system 🎉
Let's add a user
login system 🎉
Great!
Lets now add a reporting page 🎉
Great!
Lets now add a reporting page 🎉
That's really good,
Can we now add Search?
That's really good,
Can we now add Search?
Awsome... Now can
you make that all
a bit more faster🏃
Awsome... Now can
you make that all
a bit more faster🏃
Can you push that report to this external service every hour?
Can you actually
push that report you generated hourly to this external service
That is perfect
thanks ❤️
See you in a bit!
That is perfect
thanks ❤️
See you in a bit!
Actually could you
just...
Actually could you
just...
Actually could you
just...
Your load can be inconsistent. Your resources cannot.
[Steam active user chart]
You can have too much
You can also have too little
Also give it a few years and you server will eventually look like this:
- Easier to scale (Just add a bigger server)
- Lower time investment into making infrastructure stack
- Fewer considerations need to be made about the application stack's hosting environment when writing the app.
However:
- The server is a single point of failure.
- Scaling options limited as there is eventually be limitations surrounding how much hardware the server can support
- Harder to isolate where issues might arise.
Time until ready
Size of server
Size of server
Time until ready
~ 10 Requests
per second
5 Minutes
~ 10 Requests
per second
5 Minutes
~ 5 Requests
per second
2 Minutes
~ 10 Requests
per second
5 Minutes
5< Requests
per second
1 Minute
A single
request
~ 250MS
A single
request
~ 250MS
A single
request
~ 250MS
"AWS Lambda is a compute service that lets you run code without provisioning or managing servers."
It effectively allows you to execute code based on a large list of events within the AWS ecosystem (Including network requests) without the need of worrying about the underlying infrastructure, scaling, availability, logging ect...
- It is a Lie, Serverless does actually involve running a server :( ... Just ones fully managed by AWS.
- It eliminates the need to maintain dedicated servers
- It should significantly reduce hosting costs in most cases
- It frees up engineering resources and moves the focus towards delivering business value
- It ensures the platform is highly available, automatically scales directly with demand.
- Wide range of supported events and well established ecosystem across multiple cloud providers
Metric | Amount | Per |
---|---|---|
Compute | $0.0000166667 | GB/s |
Requests Resources | $0.20 | Million Requests |
Data Transfer | ~ $0.108 | per GB Egress (To internet) |
Limitation | Maximum value |
---|---|
Concurrently running lambdas | 1000 per AWS Region (can be raised on request) |
Lambda Memory | 10GB (Hard limit) (6v cpus allocated by memory) |
Ephemeral Storage | 10GB |
Name | Description |
---|---|
Vendor Lock In | You are committed to the AWS Cloud while using Lambda. Moving away could be difficult |
Cold starts | Lambdas can be significantly slower on the first call made to them if they have not been invoked in a while (subsequent calls are faster) |
Vulnerable to Denial of wallet attacks | Given it is a Pay As You Go model the costs can become huge if limits are not set / costs not monitored. |
Scalable as the weakest link | Lambda adds scalability in the compute layer but not in the data layer. Non scaling data storage can still be overwhelmed (Though Serverless options exist Serverless Aurora, DynamoDB) |
If you load is very stable.
It is probably not all to problematic to leave a server running as is
However if you load is very unstable AWS Lambda can be a great option
Also if your load is very small / low volume it can be a great way to reduce hosting costs
Other circumstances where AWS Lambda can be useful
- Running business critical processes
- Running scheduled jobs (Especially computationally ones)
- Handling routes on the website that are disproportionately expensive to load
LOGO | What is it |
---|---|
PHP | |
Bref PHP | |
Serverless Framework | |
AWS Lambda | |
AWS Cloudformation |
LOGO | What is it |
---|---|
PHP | |
Bref PHP | |
Serverless Framework | |
AWS Lambda | |
AWS Cloudformation |
"AWS CloudFormation is an infrastructure as code (IaC) service that allows you to easily model, provision, and manage AWS and third-party resources."
AWSTemplateFormatVersion: '2010-09-09'
Description: Template for Lambda Sample.
Resources:
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName:
Fn::Sub: lambda-function-${EnvName}
Description: LambdaFunctioni of nodejs12.x.
Runtime: nodejs12.x
Code:
ZipFile:
"exports.handler = function(event, context){\n
var sample = sample;"
Handler: ${LambdaHandlerPath}
MemorySize: 128
Timeout: 10
Role:
Fn::GetAtt:
- LambdaRole
- Arn
Environment:
Variables:
ENV:
Fn::Sub: ${EnvName}
TZ: UTC
"AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers. You can trigger Lambda from over 200 AWS services and software as a service (SaaS) applications, and only pay for what you use. "
AWSTemplateFormatVersion: '2010-09-09'
Description: Template for Lambda Sample.
Resources:
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName:
Fn::Sub: lambda-function-${EnvName}
Description: LambdaFunctioni of nodejs12.x.
Runtime: nodejs12.x
Code:
ZipFile:
"exports.handler = function(event, context){\n
var sample = sample;"
Handler: ${LambdaHandlerPath}
MemorySize: 128
Timeout: 10
Role:
Fn::GetAtt:
- LambdaRole
- Arn
Environment:
Variables:
ENV:
Fn::Sub: ${EnvName}
TZ: UTC
"The Serverless Framework is a free and open-source web framework written using Node.js. Serverless is the first framework developed for building applications on AWS Lambda, a serverless computing platform provided by Amazon as a part of Amazon Web Services."
# Serverless.yml
service: Some Service
custom:
name: ${self:service}
stage: ${opt:stage, 'dev'}
provider:
name: aws
region: us-east-1
runtime: provided.al2
plugins:
- ./vendor/bref/bref
functions:
frontend:
handler: src/handler.php
description: 'Handles Requests'
timeout: 28
layers:
- ${bref:layer.php-80}
events:
- httpApi: '*'
"Bref (which means "brief" in french) is as an open source Composer package and helps you deploy PHP applications to AWS and run them on AWS Lambda."
[...]
"Bref uses the Serverless framework to configure and deploy serverless applications. Being the most popular tool, Serverless comes with a huge community, a lot of examples online and a simple configuration format."
🐘
Layer Name | Purpose |
---|---|
Web apps: php-xx-fpm | Uses a single Threaded version of PHP-FPM to process requests |
Event Driven: php-xx | Used in more conventional lambda applications and can be triggered by any event in the PHP ecosystem. |
Event Driven: php-console | Used for invoking PHP console commands on AWS Lambda |
Credits
Hosts / Sponsors
The joint works (For hosting)
Jump 24 (For sponsoring)
The Birmingham PHP Team (For organizing)
Usage Credits
Diagrams + Charts
https://diagrams.mingrammer.com/
https://plotly.com/
https://matplotlib.org/
Special Thanks
Jim Seconde
Credits
Hosts / Sponsors
The joint works (For hosting)
Jump 24 (For sponsoring)
The Birmingham PHP Team (For organizing)
Usage Credits
Diagrams + Charts
https://diagrams.mingrammer.com/
https://plotly.com/
https://matplotlib.org/
Special Thanks
Jim Seconde
Credits
Hosts / Sponsors
The joint works (For hosting)
Jump 24 (For sponsoring)
The Birmingham PHP Team (For organizing)
Usage Credits
diagrams.mingrammer.com
plotly.com
matplotlib.org
slides.com
Special Thanks
Jim Seconde
[Image : Andy Holmes]