├── laravel ├── public │ ├── favicon.ico │ └── index.php ├── database │ ├── .gitignore │ ├── seeders │ │ └── DatabaseSeeder.php │ └── factories │ │ └── UserFactory.php ├── storage │ ├── logs │ │ └── .gitignore │ ├── app │ │ ├── public │ │ │ └── .gitignore │ │ └── .gitignore │ └── framework │ │ ├── sessions │ │ └── .gitignore │ │ ├── testing │ │ └── .gitignore │ │ ├── views │ │ └── .gitignore │ │ ├── cache │ │ ├── data │ │ │ └── .gitignore │ │ └── .gitignore │ │ └── .gitignore ├── bootstrap │ ├── cache │ │ └── .gitignore │ ├── providers.php │ └── app.php ├── Dockerfile ├── app │ ├── Http │ │ └── Controllers │ │ │ └── Controller.php │ ├── Providers │ │ └── AppServiceProvider.php │ └── Models │ │ └── User.php ├── routes │ ├── console.php │ └── web.php ├── .gitignore ├── artisan ├── config │ ├── services.php │ ├── filesystems.php │ ├── mail.php │ ├── cache.php │ ├── queue.php │ ├── auth.php │ ├── app.php │ ├── logging.php │ ├── database.php │ └── session.php ├── .env.example ├── .env.production ├── serverless.yml ├── composer.json └── resources │ └── views │ └── welcome.blade.php ├── fpm ├── index.php ├── Dockerfile ├── composer.json └── serverless.yml ├── .gitignore ├── function ├── Dockerfile ├── index.php ├── composer.json └── serverless.yml ├── Makefile ├── benchmark-http.sh ├── benchmark-function.sh ├── benchmark-coldstarts.sh └── README.md /laravel/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /laravel/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /fpm/index.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote')->hourly(); 9 | -------------------------------------------------------------------------------- /laravel/.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .phpunit.result.cache 11 | Homestead.json 12 | Homestead.yaml 13 | auth.json 14 | npm-debug.log 15 | yarn-error.log 16 | /.fleet 17 | /.idea 18 | /.vscode 19 | -------------------------------------------------------------------------------- /laravel/routes/web.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 14 | 15 | exit($status); 16 | -------------------------------------------------------------------------------- /laravel/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 18 | -------------------------------------------------------------------------------- /laravel/database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | 18 | User::factory()->create([ 19 | 'name' => 'Test User', 20 | 'email' => 'test@example.com', 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /laravel/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 9 | web: __DIR__.'/../routes/web.php', 10 | commands: __DIR__.'/../routes/console.php', 11 | health: '/up', 12 | ) 13 | ->withMiddleware(function (Middleware $middleware) { 14 | // 15 | }) 16 | ->withExceptions(function (Exceptions $exceptions) { 17 | // 18 | })->create(); 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Deploy all the lambdas 2 | deploy: deploy-function deploy-fpm deploy-laravel 3 | deploy-function: 4 | cd function && serverless deploy && serverless info 5 | deploy-fpm: 6 | cd fpm && serverless deploy && serverless info 7 | deploy-laravel: 8 | cd laravel && serverless deploy && serverless info 9 | 10 | bench-cold-starts: 11 | ./benchmark-coldstarts.sh 12 | bench-function: 13 | ./benchmark-function.sh 14 | bench-http: 15 | ./benchmark-http.sh 16 | 17 | # Set things up 18 | setup: 19 | cd function && composer update --no-dev --classmap-authoritative 20 | cd fpm && composer update --no-dev --classmap-authoritative 21 | cd laravel && composer update --no-dev --classmap-authoritative \ 22 | && php artisan config:clear \ 23 | && rm -f .env && cp .env.production .env \ 24 | && docker run --rm -it -v $$PWD:/var/task --entrypoint php bref/php-83:2 artisan optimize 25 | docker pull bref/php-83:2 26 | docker pull bref/php-83-fpm:2 27 | 28 | .PHONY: setup 29 | -------------------------------------------------------------------------------- /laravel/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'slack' => [ 28 | 'notifications' => [ 29 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 30 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 31 | ], 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /laravel/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | protected $fillable = [ 20 | 'name', 21 | 'email', 22 | 'password', 23 | ]; 24 | 25 | /** 26 | * The attributes that should be hidden for serialization. 27 | * 28 | * @var array 29 | */ 30 | protected $hidden = [ 31 | 'password', 32 | 'remember_token', 33 | ]; 34 | 35 | /** 36 | * Get the attributes that should be cast. 37 | * 38 | * @return array 39 | */ 40 | protected function casts(): array 41 | { 42 | return [ 43 | 'email_verified_at' => 'datetime', 44 | 'password' => 'hashed', 45 | ]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /laravel/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /laravel/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_TIMEZONE=UTC 6 | APP_URL=http://localhost 7 | 8 | APP_LOCALE=en 9 | APP_FALLBACK_LOCALE=en 10 | APP_FAKER_LOCALE=en_US 11 | 12 | APP_MAINTENANCE_DRIVER=file 13 | APP_MAINTENANCE_STORE=database 14 | 15 | BCRYPT_ROUNDS=12 16 | 17 | LOG_CHANNEL=stack 18 | LOG_STACK=single 19 | LOG_DEPRECATIONS_CHANNEL=null 20 | LOG_LEVEL=debug 21 | 22 | DB_CONNECTION=sqlite 23 | # DB_HOST=127.0.0.1 24 | # DB_PORT=3306 25 | # DB_DATABASE=laravel 26 | # DB_USERNAME=root 27 | # DB_PASSWORD= 28 | 29 | SESSION_DRIVER=database 30 | SESSION_LIFETIME=120 31 | SESSION_ENCRYPT=false 32 | SESSION_PATH=/ 33 | SESSION_DOMAIN=null 34 | 35 | BROADCAST_CONNECTION=log 36 | FILESYSTEM_DISK=local 37 | QUEUE_CONNECTION=database 38 | 39 | CACHE_STORE=database 40 | CACHE_PREFIX= 41 | 42 | MEMCACHED_HOST=127.0.0.1 43 | 44 | REDIS_CLIENT=phpredis 45 | REDIS_HOST=127.0.0.1 46 | REDIS_PASSWORD=null 47 | REDIS_PORT=6379 48 | 49 | MAIL_MAILER=log 50 | MAIL_HOST=127.0.0.1 51 | MAIL_PORT=2525 52 | MAIL_USERNAME=null 53 | MAIL_PASSWORD=null 54 | MAIL_ENCRYPTION=null 55 | MAIL_FROM_ADDRESS="hello@example.com" 56 | MAIL_FROM_NAME="${APP_NAME}" 57 | 58 | AWS_ACCESS_KEY_ID= 59 | AWS_SECRET_ACCESS_KEY= 60 | AWS_DEFAULT_REGION=us-east-1 61 | AWS_BUCKET= 62 | AWS_USE_PATH_STYLE_ENDPOINT=false 63 | 64 | VITE_APP_NAME="${APP_NAME}" 65 | -------------------------------------------------------------------------------- /benchmark-http.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | for value in {1..500} 6 | do 7 | # HTTP application 8 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/128 > /dev/null & 9 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/512 > /dev/null & 10 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024 > /dev/null & 11 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1769 > /dev/null & 12 | wait 13 | 14 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/128-arm > /dev/null & 15 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/512-arm > /dev/null & 16 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024-arm > /dev/null & 17 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1769-arm > /dev/null & 18 | wait 19 | 20 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024-container > /dev/null & 21 | wait 22 | 23 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024 > /dev/null & 24 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024-arm > /dev/null & 25 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024-container > /dev/null & 26 | wait 27 | 28 | sleep 1 29 | done 30 | -------------------------------------------------------------------------------- /laravel/.env.production: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=production 3 | APP_KEY=base64:E+encJrg6dTOlxvvwmI081w7fiESSe8uljgzcOeU2HM= 4 | APP_DEBUG=false 5 | APP_TIMEZONE=UTC 6 | APP_URL=http://localhost 7 | 8 | APP_LOCALE=en 9 | APP_FALLBACK_LOCALE=en 10 | APP_FAKER_LOCALE=en_US 11 | 12 | APP_MAINTENANCE_DRIVER=file 13 | APP_MAINTENANCE_STORE=database 14 | 15 | BCRYPT_ROUNDS=12 16 | 17 | LOG_CHANNEL=stack 18 | LOG_STACK=single 19 | LOG_DEPRECATIONS_CHANNEL=null 20 | LOG_LEVEL=debug 21 | 22 | DB_CONNECTION=sqlite 23 | # DB_HOST=127.0.0.1 24 | # DB_PORT=3306 25 | # DB_DATABASE=laravel 26 | # DB_USERNAME=root 27 | # DB_PASSWORD= 28 | 29 | SESSION_DRIVER=cookie 30 | SESSION_LIFETIME=120 31 | SESSION_ENCRYPT=false 32 | SESSION_PATH=/ 33 | SESSION_DOMAIN=null 34 | 35 | BROADCAST_CONNECTION=log 36 | FILESYSTEM_DISK=local 37 | QUEUE_CONNECTION=database 38 | 39 | CACHE_STORE=database 40 | CACHE_PREFIX= 41 | 42 | MEMCACHED_HOST=127.0.0.1 43 | 44 | REDIS_CLIENT=phpredis 45 | REDIS_HOST=127.0.0.1 46 | REDIS_PASSWORD=null 47 | REDIS_PORT=6379 48 | 49 | MAIL_MAILER=log 50 | MAIL_HOST=127.0.0.1 51 | MAIL_PORT=2525 52 | MAIL_USERNAME=null 53 | MAIL_PASSWORD=null 54 | MAIL_ENCRYPTION=null 55 | MAIL_FROM_ADDRESS="hello@example.com" 56 | MAIL_FROM_NAME="${APP_NAME}" 57 | 58 | AWS_ACCESS_KEY_ID= 59 | AWS_SECRET_ACCESS_KEY= 60 | AWS_DEFAULT_REGION=us-east-1 61 | AWS_BUCKET= 62 | AWS_USE_PATH_STYLE_ENDPOINT=false 63 | 64 | VITE_APP_NAME="${APP_NAME}" 65 | -------------------------------------------------------------------------------- /benchmark-function.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # PHP functions 6 | for value in {1..500} 7 | do 8 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-128 /dev/null > /dev/null & 9 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-512 /dev/null > /dev/null & 10 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-1024 /dev/null > /dev/null & 11 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-1769 /dev/null > /dev/null & 12 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-1024-container /dev/null > /dev/null & 13 | wait 14 | 15 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-128-arm /dev/null > /dev/null & 16 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-512-arm /dev/null > /dev/null & 17 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-1024-arm /dev/null > /dev/null & 18 | aws lambda invoke --invocation-type RequestResponse --region us-east-2 --function-name bref2-bench-function-dev-1769-arm /dev/null > /dev/null & 19 | wait 20 | 21 | sleep 1 22 | done 23 | -------------------------------------------------------------------------------- /laravel/serverless.yml: -------------------------------------------------------------------------------- 1 | service: bref2-bench-laravel 2 | 3 | provider: 4 | name: aws 5 | region: us-east-2 6 | versionFunctions: false 7 | environment: 8 | APP_ENV: production 9 | APP_KEY: 'base64:E+encJrg6dTOlxvvwmI081w7fiESSe8uljgzcOeU2HM=' 10 | SESSION_DRIVER: cookie 11 | tracing: 12 | lambda: true 13 | logs: 14 | httpApi: 15 | format: '{ "requestId": "$context.requestId", "routeKey": "$context.routeKey", "requestTime": "$context.requestTime", "integrationLatency": "$context.integrationLatency" }' 16 | ecr: 17 | images: 18 | laravel: 19 | path: ./ 20 | 21 | plugins: 22 | - ./vendor/bref/bref 23 | 24 | functions: 25 | 1024: 26 | handler: public/index.php 27 | memorySize: 1024 28 | runtime: php-83-fpm 29 | events: 30 | - httpApi: 'GET /1024' 31 | # Invoke every hour to trigger cold starts 32 | - schedule: 33 | rate: rate(1 hour) 34 | input: 35 | warmer: true 36 | 37 | 1024-arm: 38 | handler: public/index.php 39 | memorySize: 1024 40 | architecture: arm64 41 | runtime: php-83-fpm 42 | events: 43 | - httpApi: 'GET /1024-arm' 44 | # Invoke every hour to trigger cold starts 45 | - schedule: 46 | rate: rate(1 hour) 47 | input: 48 | warmer: true 49 | 50 | 1024-container: 51 | image: 52 | name: laravel 53 | memorySize: 1024 54 | events: 55 | - httpApi: 'GET /1024-container' 56 | # Invoke every hour to trigger cold starts 57 | - schedule: 58 | rate: rate(1 hour) 59 | input: 60 | warmer: true 61 | 62 | package: 63 | patterns: 64 | - '!node_modules/**' 65 | - '!public/storage' 66 | - '!database/*.sqlite' 67 | - '!resources/css/**' 68 | - '!resources/js/**' 69 | - '!storage/**' 70 | - '!tests/**' 71 | -------------------------------------------------------------------------------- /laravel/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /function/serverless.yml: -------------------------------------------------------------------------------- 1 | service: bref2-bench-function 2 | 3 | provider: 4 | name: aws 5 | region: us-east-2 6 | versionFunctions: false 7 | tracing: 8 | lambda: true 9 | logs: 10 | httpApi: 11 | format: '{ "requestId": "$context.requestId", "routeKey": "$context.routeKey", "requestTime": "$context.requestTime", "integrationLatency": "$context.integrationLatency" }' 12 | ecr: 13 | images: 14 | function: 15 | path: ./ 16 | 17 | plugins: 18 | - ./vendor/bref/bref 19 | 20 | functions: 21 | 128: 22 | handler: index.php 23 | memorySize: 128 24 | runtime: php-83 25 | events: 26 | # Invoke every hour to trigger cold starts 27 | - schedule: 28 | rate: rate(1 hour) 29 | 512: 30 | handler: index.php 31 | memorySize: 512 32 | runtime: php-83 33 | events: 34 | # Invoke every hour to trigger cold starts 35 | - schedule: 36 | rate: rate(1 hour) 37 | 1024: 38 | handler: index.php 39 | memorySize: 1024 40 | runtime: php-83 41 | events: 42 | # Invoke every hour to trigger cold starts 43 | - schedule: 44 | rate: rate(1 hour) 45 | 1769: 46 | handler: index.php 47 | memorySize: 1769 48 | runtime: php-83 49 | events: 50 | # Invoke every hour to trigger cold starts 51 | - schedule: 52 | rate: rate(1 hour) 53 | 54 | 128-arm: 55 | handler: index.php 56 | memorySize: 128 57 | architecture: arm64 58 | runtime: php-83 59 | events: 60 | # Invoke every hour to trigger cold starts 61 | - schedule: 62 | rate: rate(1 hour) 63 | 512-arm: 64 | handler: index.php 65 | memorySize: 512 66 | architecture: arm64 67 | runtime: php-83 68 | events: 69 | # Invoke every hour to trigger cold starts 70 | - schedule: 71 | rate: rate(1 hour) 72 | 1024-arm: 73 | handler: index.php 74 | memorySize: 1024 75 | architecture: arm64 76 | runtime: php-83 77 | events: 78 | # Invoke every hour to trigger cold starts 79 | - schedule: 80 | rate: rate(1 hour) 81 | 1769-arm: 82 | handler: index.php 83 | memorySize: 1769 84 | architecture: arm64 85 | runtime: php-83 86 | events: 87 | # Invoke every hour to trigger cold starts 88 | - schedule: 89 | rate: rate(1 hour) 90 | 91 | 1024-container: 92 | image: 93 | name: function 94 | memorySize: 1024 95 | events: 96 | # Invoke every hour to trigger cold starts 97 | - schedule: 98 | rate: rate(1 hour) 99 | -------------------------------------------------------------------------------- /laravel/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": ["laravel", "framework"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.2", 9 | "bref/bref": "^2.1", 10 | "bref/laravel-bridge": "^2.3", 11 | "laravel/framework": "^11.0", 12 | "laravel/tinker": "^2.9" 13 | }, 14 | "require-dev": { 15 | "fakerphp/faker": "^1.23", 16 | "laravel/pint": "^1.13", 17 | "laravel/sail": "^1.26", 18 | "mockery/mockery": "^1.6", 19 | "nunomaduro/collision": "^8.0", 20 | "phpunit/phpunit": "^11.0.1", 21 | "spatie/laravel-ignition": "^2.4" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "App\\": "app/", 26 | "Database\\Factories\\": "database/factories/", 27 | "Database\\Seeders\\": "database/seeders/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Tests\\": "tests/" 33 | } 34 | }, 35 | "replace": { 36 | "paragonie/random_compat": "*", 37 | "paragonie/sodium_compat": "*", 38 | "symfony/polyfill-ctype": "*", 39 | "symfony/polyfill-iconv": "*", 40 | "symfony/polyfill-intl-grapheme": "*", 41 | "symfony/polyfill-intl-icu": "*", 42 | "symfony/polyfill-intl-idn": "*", 43 | "symfony/polyfill-intl-normalizer": "*", 44 | "symfony/polyfill-mbstring": "*", 45 | "symfony/polyfill-php56": "*", 46 | "symfony/polyfill-php70": "*", 47 | "symfony/polyfill-php71": "*", 48 | "symfony/polyfill-php72": "*", 49 | "symfony/polyfill-php73": "*", 50 | "symfony/polyfill-php74": "*", 51 | "symfony/polyfill-php80": "*", 52 | "symfony/polyfill-php81": "*", 53 | "symfony/polyfill-php82": "*", 54 | "symfony/polyfill-php83": "*" 55 | }, 56 | "scripts": { 57 | "pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices", 58 | "post-autoload-dump": [ 59 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 60 | "@php artisan package:discover --ansi" 61 | ], 62 | "post-update-cmd": [ 63 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 64 | ], 65 | "post-root-package-install": [ 66 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 67 | ], 68 | "post-create-project-cmd": [ 69 | "@php artisan key:generate --ansi", 70 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 71 | "@php artisan migrate --graceful --ansi" 72 | ] 73 | }, 74 | "extra": { 75 | "laravel": { 76 | "dont-discover": [] 77 | }, 78 | "aws/aws-sdk-php": [ 79 | "Sqs" 80 | ] 81 | }, 82 | "config": { 83 | "optimize-autoloader": true, 84 | "preferred-install": "dist", 85 | "sort-packages": true, 86 | "allow-plugins": { 87 | "pestphp/pest-plugin": true, 88 | "php-http/discovery": true 89 | } 90 | }, 91 | "minimum-stability": "stable", 92 | "prefer-stable": true 93 | } 94 | -------------------------------------------------------------------------------- /laravel/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "log", "array", "failover", "roundrobin" 34 | | 35 | */ 36 | 37 | 'mailers' => [ 38 | 39 | 'smtp' => [ 40 | 'transport' => 'smtp', 41 | 'url' => env('MAIL_URL'), 42 | 'host' => env('MAIL_HOST', '127.0.0.1'), 43 | 'port' => env('MAIL_PORT', 2525), 44 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 45 | 'username' => env('MAIL_USERNAME'), 46 | 'password' => env('MAIL_PASSWORD'), 47 | 'timeout' => null, 48 | 'local_domain' => env('MAIL_EHLO_DOMAIN'), 49 | ], 50 | 51 | 'ses' => [ 52 | 'transport' => 'ses', 53 | ], 54 | 55 | 'postmark' => [ 56 | 'transport' => 'postmark', 57 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 58 | // 'client' => [ 59 | // 'timeout' => 5, 60 | // ], 61 | ], 62 | 63 | 'sendmail' => [ 64 | 'transport' => 'sendmail', 65 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 66 | ], 67 | 68 | 'log' => [ 69 | 'transport' => 'log', 70 | 'channel' => env('MAIL_LOG_CHANNEL'), 71 | ], 72 | 73 | 'array' => [ 74 | 'transport' => 'array', 75 | ], 76 | 77 | 'failover' => [ 78 | 'transport' => 'failover', 79 | 'mailers' => [ 80 | 'smtp', 81 | 'log', 82 | ], 83 | ], 84 | 85 | 'roundrobin' => [ 86 | 'transport' => 'roundrobin', 87 | 'mailers' => [ 88 | 'ses', 89 | 'postmark', 90 | ], 91 | ], 92 | 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Global "From" Address 98 | |-------------------------------------------------------------------------- 99 | | 100 | | You may wish for all emails sent by your application to be sent from 101 | | the same address. Here you may specify a name and address that is 102 | | used globally for all emails that are sent by your application. 103 | | 104 | */ 105 | 106 | 'from' => [ 107 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 108 | 'name' => env('MAIL_FROM_NAME', 'Example'), 109 | ], 110 | 111 | ]; 112 | -------------------------------------------------------------------------------- /laravel/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'database'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => env('DB_CACHE_TABLE', 'cache'), 44 | 'connection' => env('DB_CACHE_CONNECTION'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | ], 47 | 48 | 'file' => [ 49 | 'driver' => 'file', 50 | 'path' => storage_path('framework/cache/data'), 51 | 'lock_path' => storage_path('framework/cache/data'), 52 | ], 53 | 54 | 'memcached' => [ 55 | 'driver' => 'memcached', 56 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 57 | 'sasl' => [ 58 | env('MEMCACHED_USERNAME'), 59 | env('MEMCACHED_PASSWORD'), 60 | ], 61 | 'options' => [ 62 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 63 | ], 64 | 'servers' => [ 65 | [ 66 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 67 | 'port' => env('MEMCACHED_PORT', 11211), 68 | 'weight' => 100, 69 | ], 70 | ], 71 | ], 72 | 73 | 'redis' => [ 74 | 'driver' => 'redis', 75 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 76 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 77 | ], 78 | 79 | 'dynamodb' => [ 80 | 'driver' => 'dynamodb', 81 | 'key' => env('AWS_ACCESS_KEY_ID'), 82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 85 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 86 | ], 87 | 88 | 'octane' => [ 89 | 'driver' => 'octane', 90 | ], 91 | 92 | ], 93 | 94 | /* 95 | |-------------------------------------------------------------------------- 96 | | Cache Key Prefix 97 | |-------------------------------------------------------------------------- 98 | | 99 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 100 | | stores, there might be other applications using the same cache. For 101 | | that reason, you may prefix every cache key to avoid collisions. 102 | | 103 | */ 104 | 105 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /fpm/serverless.yml: -------------------------------------------------------------------------------- 1 | service: bref2-bench-fpm 2 | 3 | provider: 4 | name: aws 5 | region: us-east-2 6 | versionFunctions: false 7 | tracing: 8 | lambda: true 9 | logs: 10 | httpApi: 11 | format: '{ "requestId": "$context.requestId", "routeKey": "$context.routeKey", "requestTime": "$context.requestTime", "integrationLatency": "$context.integrationLatency" }' 12 | ecr: 13 | images: 14 | fpm: 15 | path: ./ 16 | 17 | plugins: 18 | - ./vendor/bref/bref 19 | 20 | functions: 21 | 128: 22 | handler: index.php 23 | memorySize: 128 24 | runtime: php-83-fpm 25 | events: 26 | - httpApi: 'GET /128' 27 | # Invoke every hour to trigger cold starts 28 | - schedule: 29 | rate: rate(1 hour) 30 | input: 31 | warmer: true 32 | 512: 33 | handler: index.php 34 | memorySize: 512 35 | runtime: php-83-fpm 36 | events: 37 | - httpApi: 'GET /512' 38 | # Invoke every hour to trigger cold starts 39 | - schedule: 40 | rate: rate(1 hour) 41 | input: 42 | warmer: true 43 | 1024: 44 | handler: index.php 45 | memorySize: 1024 46 | runtime: php-83-fpm 47 | events: 48 | - httpApi: 'GET /1024' 49 | # Invoke every hour to trigger cold starts 50 | - schedule: 51 | rate: rate(1 hour) 52 | input: 53 | warmer: true 54 | 1769: 55 | handler: index.php 56 | memorySize: 1769 57 | runtime: php-83-fpm 58 | events: 59 | - httpApi: 'GET /1769' 60 | # Invoke every hour to trigger cold starts 61 | - schedule: 62 | rate: rate(1 hour) 63 | input: 64 | warmer: true 65 | 66 | 128-arm: 67 | handler: index.php 68 | memorySize: 128 69 | architecture: arm64 70 | runtime: php-83-fpm 71 | events: 72 | - httpApi: 'GET /128-arm' 73 | # Invoke every hour to trigger cold starts 74 | - schedule: 75 | rate: rate(1 hour) 76 | input: 77 | warmer: true 78 | 512-arm: 79 | handler: index.php 80 | memorySize: 512 81 | architecture: arm64 82 | runtime: php-83-fpm 83 | events: 84 | - httpApi: 'GET /512-arm' 85 | # Invoke every hour to trigger cold starts 86 | - schedule: 87 | rate: rate(1 hour) 88 | input: 89 | warmer: true 90 | 1024-arm: 91 | handler: index.php 92 | memorySize: 1024 93 | architecture: arm64 94 | runtime: php-83-fpm 95 | events: 96 | - httpApi: 'GET /1024-arm' 97 | # Invoke every hour to trigger cold starts 98 | - schedule: 99 | rate: rate(1 hour) 100 | input: 101 | warmer: true 102 | 1769-arm: 103 | handler: index.php 104 | memorySize: 1769 105 | architecture: arm64 106 | runtime: php-83-fpm 107 | events: 108 | - httpApi: 'GET /1769-arm' 109 | # Invoke every hour to trigger cold starts 110 | - schedule: 111 | rate: rate(1 hour) 112 | input: 113 | warmer: true 114 | 115 | 1024-container: 116 | image: 117 | name: fpm 118 | memorySize: 1024 119 | events: 120 | - httpApi: 'GET /1024-container' 121 | # Invoke every hour to trigger cold starts 122 | - schedule: 123 | rate: rate(1 hour) 124 | input: 125 | warmer: true 126 | -------------------------------------------------------------------------------- /laravel/config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'database'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection options for every queue backend 24 | | used by your application. An example configuration is provided for 25 | | each backend supported by Laravel. You're also free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'connection' => env('DB_QUEUE_CONNECTION'), 40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'), 41 | 'queue' => env('DB_QUEUE', 'default'), 42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), 43 | 'after_commit' => false, 44 | ], 45 | 46 | 'beanstalkd' => [ 47 | 'driver' => 'beanstalkd', 48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'), 50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 51 | 'block_for' => 0, 52 | 'after_commit' => false, 53 | ], 54 | 55 | 'sqs' => [ 56 | 'driver' => 'sqs', 57 | 'key' => env('AWS_ACCESS_KEY_ID'), 58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 60 | 'queue' => env('SQS_QUEUE', 'default'), 61 | 'suffix' => env('SQS_SUFFIX'), 62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 63 | 'after_commit' => false, 64 | ], 65 | 66 | 'redis' => [ 67 | 'driver' => 'redis', 68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 69 | 'queue' => env('REDIS_QUEUE', 'default'), 70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 71 | 'block_for' => null, 72 | 'after_commit' => false, 73 | ], 74 | 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Job Batching 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following options configure the database and table that store job 83 | | batching information. These options can be updated to any database 84 | | connection and table which has been defined by your application. 85 | | 86 | */ 87 | 88 | 'batching' => [ 89 | 'database' => env('DB_CONNECTION', 'sqlite'), 90 | 'table' => 'job_batches', 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Failed Queue Jobs 96 | |-------------------------------------------------------------------------- 97 | | 98 | | These options configure the behavior of failed queue job logging so you 99 | | can control how and where failed jobs are stored. Laravel ships with 100 | | support for storing failed jobs in a simple file or in a database. 101 | | 102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null" 103 | | 104 | */ 105 | 106 | 'failed' => [ 107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 108 | 'database' => env('DB_CONNECTION', 'sqlite'), 109 | 'table' => 'failed_jobs', 110 | ], 111 | 112 | ]; 113 | -------------------------------------------------------------------------------- /benchmark-coldstarts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Before running this script make sure the lambdas were deployed (to ensure we get cold starts) 6 | 7 | # Launch many invocations in parallel to trigger as many cold starts as possible 8 | 9 | for value in {1..20} 10 | do 11 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-128 /dev/null & 12 | done 13 | wait # Wait for all invocations to finish 14 | for value in {1..20} 15 | do 16 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-512 /dev/null & 17 | done 18 | wait # Wait for all invocations to finish 19 | for value in {1..20} 20 | do 21 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-1024 /dev/null & 22 | done 23 | wait # Wait for all invocations to finish 24 | for value in {1..20} 25 | do 26 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-1769 /dev/null & 27 | done 28 | wait # Wait for all invocations to finish 29 | 30 | for value in {1..20} 31 | do 32 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-128-arm /dev/null & 33 | done 34 | wait # Wait for all invocations to finish 35 | for value in {1..20} 36 | do 37 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-512-arm /dev/null & 38 | done 39 | wait # Wait for all invocations to finish 40 | for value in {1..20} 41 | do 42 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-1024-arm /dev/null & 43 | done 44 | wait # Wait for all invocations to finish 45 | for value in {1..20} 46 | do 47 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-1769-arm /dev/null & 48 | done 49 | wait # Wait for all invocations to finish 50 | 51 | for value in {1..20} 52 | do 53 | aws lambda invoke --invocation-type Event --region us-east-2 --function-name bref2-bench-function-dev-1024-container /dev/null & 54 | done 55 | wait # Wait for all invocations to finish 56 | 57 | # HTTP application 58 | for value in {1..20} 59 | do 60 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/128 > /dev/null & 61 | done 62 | wait 63 | echo "." 64 | 65 | for value in {1..20} 66 | do 67 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/512 > /dev/null & 68 | done 69 | wait 70 | echo "." 71 | 72 | for value in {1..20} 73 | do 74 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024 > /dev/null & 75 | done 76 | wait 77 | echo "." 78 | 79 | for value in {1..20} 80 | do 81 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1769 > /dev/null & 82 | done 83 | wait 84 | echo "." 85 | 86 | for value in {1..20} 87 | do 88 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/128-arm > /dev/null & 89 | done 90 | wait 91 | echo "." 92 | 93 | for value in {1..20} 94 | do 95 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/512-arm > /dev/null & 96 | done 97 | wait 98 | echo "." 99 | 100 | for value in {1..20} 101 | do 102 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024-arm > /dev/null & 103 | done 104 | wait 105 | echo "." 106 | 107 | for value in {1..20} 108 | do 109 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1769-arm > /dev/null & 110 | done 111 | wait 112 | echo "." 113 | 114 | for value in {1..20} 115 | do 116 | curl --silent https://4qv4pt37t4.execute-api.us-east-2.amazonaws.com/1024-container > /dev/null & 117 | done 118 | wait 119 | echo "." 120 | 121 | # Laravel 122 | for value in {1..20} 123 | do 124 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024 > /dev/null & 125 | done 126 | wait 127 | echo "." 128 | for value in {1..20} 129 | do 130 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024-arm > /dev/null & 131 | done 132 | wait 133 | echo "." 134 | for value in {1..20} 135 | do 136 | curl --silent https://2ssqzwaiek.execute-api.us-east-2.amazonaws.com/1024-container > /dev/null & 137 | done 138 | wait 139 | echo "." 140 | -------------------------------------------------------------------------------- /laravel/config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => env('AUTH_GUARD', 'web'), 18 | 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | which utilizes session storage plus the Eloquent user provider. 29 | | 30 | | All authentication guards have a user provider, which defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | system used by the application. Typically, Eloquent is utilized. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication guards have a user provider, which defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | system used by the application. Typically, Eloquent is utilized. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | providers to represent the model / table. These providers may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => env('AUTH_MODEL', App\Models\User::class), 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | These configuration options specify the behavior of Laravel's password 80 | | reset functionality, including the table utilized for token storage 81 | | and the user provider that is invoked to actually retrieve users. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'), 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | window expires and users are asked to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800), 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /laravel/config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => (bool) env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | the application so that it's available within Artisan commands. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. The timezone 64 | | is set to "UTC" by default as it is suitable for most use cases. 65 | | 66 | */ 67 | 68 | 'timezone' => env('APP_TIMEZONE', 'UTC'), 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by Laravel's translation / localization methods. This option can be 77 | | set to any locale for which you plan to have translation strings. 78 | | 79 | */ 80 | 81 | 'locale' => env('APP_LOCALE', 'en'), 82 | 83 | 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 84 | 85 | 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Encryption Key 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This key is utilized by Laravel's encryption services and should be set 93 | | to a random, 32 character string to ensure that all encrypted values 94 | | are secure. You should do this prior to deploying the application. 95 | | 96 | */ 97 | 98 | 'cipher' => 'AES-256-CBC', 99 | 100 | 'key' => env('APP_KEY'), 101 | 102 | 'previous_keys' => [ 103 | ...array_filter( 104 | explode(',', env('APP_PREVIOUS_KEYS', '')) 105 | ), 106 | ], 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Maintenance Mode Driver 111 | |-------------------------------------------------------------------------- 112 | | 113 | | These configuration options determine the driver used to determine and 114 | | manage Laravel's "maintenance mode" status. The "cache" driver will 115 | | allow maintenance mode to be controlled across multiple machines. 116 | | 117 | | Supported drivers: "file", "cache" 118 | | 119 | */ 120 | 121 | 'maintenance' => [ 122 | 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 123 | 'store' => env('APP_MAINTENANCE_STORE', 'database'), 124 | ], 125 | 126 | ]; 127 | -------------------------------------------------------------------------------- /laravel/config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => env('LOG_DEPRECATIONS_TRACE', false), 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Laravel 45 | | utilizes the Monolog PHP logging library, which includes a variety 46 | | of powerful log handlers and formatters that you're free to use. 47 | | 48 | | Available Drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", "custom", "stack" 50 | | 51 | */ 52 | 53 | 'channels' => [ 54 | 55 | 'stack' => [ 56 | 'driver' => 'stack', 57 | 'channels' => explode(',', env('LOG_STACK', 'single')), 58 | 'ignore_exceptions' => false, 59 | ], 60 | 61 | 'single' => [ 62 | 'driver' => 'single', 63 | 'path' => storage_path('logs/laravel.log'), 64 | 'level' => env('LOG_LEVEL', 'debug'), 65 | 'replace_placeholders' => true, 66 | ], 67 | 68 | 'daily' => [ 69 | 'driver' => 'daily', 70 | 'path' => storage_path('logs/laravel.log'), 71 | 'level' => env('LOG_LEVEL', 'debug'), 72 | 'days' => env('LOG_DAILY_DAYS', 14), 73 | 'replace_placeholders' => true, 74 | ], 75 | 76 | 'slack' => [ 77 | 'driver' => 'slack', 78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 79 | 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), 80 | 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 81 | 'level' => env('LOG_LEVEL', 'critical'), 82 | 'replace_placeholders' => true, 83 | ], 84 | 85 | 'papertrail' => [ 86 | 'driver' => 'monolog', 87 | 'level' => env('LOG_LEVEL', 'debug'), 88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 89 | 'handler_with' => [ 90 | 'host' => env('PAPERTRAIL_URL'), 91 | 'port' => env('PAPERTRAIL_PORT'), 92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 93 | ], 94 | 'processors' => [PsrLogMessageProcessor::class], 95 | ], 96 | 97 | 'stderr' => [ 98 | 'driver' => 'monolog', 99 | 'level' => env('LOG_LEVEL', 'debug'), 100 | 'handler' => StreamHandler::class, 101 | 'formatter' => env('LOG_STDERR_FORMATTER'), 102 | 'with' => [ 103 | 'stream' => 'php://stderr', 104 | ], 105 | 'processors' => [PsrLogMessageProcessor::class], 106 | ], 107 | 108 | 'syslog' => [ 109 | 'driver' => 'syslog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), 112 | 'replace_placeholders' => true, 113 | ], 114 | 115 | 'errorlog' => [ 116 | 'driver' => 'errorlog', 117 | 'level' => env('LOG_LEVEL', 'debug'), 118 | 'replace_placeholders' => true, 119 | ], 120 | 121 | 'null' => [ 122 | 'driver' => 'monolog', 123 | 'handler' => NullHandler::class, 124 | ], 125 | 126 | 'emergency' => [ 127 | 'path' => storage_path('logs/laravel.log'), 128 | ], 129 | 130 | ], 131 | 132 | ]; 133 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Benchmarks for [Bref](https://github.com/brefphp/bref) running on AWS Lambda. 2 | 3 | ## Scenarios 4 | 5 | - PHP function: a simple PHP function, see `function/index.php` 6 | - HTTP application: a simple PHP web page that returns `Hello world`, see `fpm/index.php` 7 | 8 | ## Median (warm) execution time 9 | 10 | Average execution time for a lambda that doesn't do anything. 11 | 12 | Number of samples: 900 13 | 14 | ### Bref 2.x (PHP 8.3) 15 | 16 | | Memory | 128 | 512 | 1024 | 1769 | 17 | |------------------------------|------:|-----:|-----:|-----:| 18 | | PHP function | 200ms | 35ms | 19ms | 17ms | 19 | | PHP function (BREF_LOOP_MAX) | | | 1ms | 1ms | 20 | | HTTP application | 2ms | 2ms | 2ms | 2ms | 21 | | Laravel | | | 9ms | | 22 | 23 | ### Bref 2.x ARM (PHP 8.3) 24 | 25 | | Memory | 128 | 512 | 1024 | 1769 | 26 | |------------------------------|------:|-----:|-----:|-----:| 27 | | PHP function | 170ms | 27ms | 17ms | 17ms | 28 | | PHP function (BREF_LOOP_MAX) | | | 1ms | 1ms | 29 | | HTTP application | 2ms | 2ms | 2ms | 2ms | 30 | | Laravel | | | 10ms | | 31 | 32 | For comparison on a 512M Digital Ocean droplet we get 1ms for "HTTP application" and 6ms for Symfony. 33 | 34 | ## CPU performance 35 | 36 | The more RAM, the more CPU power is allocated to the lambda. This is clearly visible when running [PHP's official `bench.php` script](https://github.com/php/php-src/blob/master/Zend/bench.php). 37 | 38 | | Memory | 128 | 512 | 1024 | 1769 | 39 | |-------------|-----:|-----:|------:|------:| 40 | | `bench.php` | 5.7s | 1.4s | 0.65s | 0.33s | 41 | 42 | For comparison `bench.php` runs in 1.3s on a 512M Digital Ocean droplet, in 0.8s on a 2.8Ghz i7 and in 0.6s on a 3.2Ghz i5. 43 | 44 | ## Cold starts 45 | 46 | Number of samples: 20 47 | 48 | High level learnings: 49 | 50 | - Don't use less than 512M of memory 51 | - Cold starts are not faster on ARM, they are same or slightly slower 52 | - Containers have the fastest cold starts 53 | - When using containers, you need to warm up the first requests following a deployment 54 | 55 | Comparison (1024M): 56 | 57 | | | x86 container | x86 layer | ARM layer | 58 | |--------------------|--------------:|----------:|----------:| 59 | | HTTP (duration) | 180ms | 340ms | 315ms | 60 | | HTTP (latency) | 350ms | 580ms | 630ms | 61 | | Laravel (duration) | 850ms | 1510ms | 1220ms | 62 | | Function | 160ms | 260ms | 235ms | 63 | 64 | ### Bref 2.x containers (PHP 8.3) 65 | 66 | Note: the first cold starts are much slower (see https://aaronstuyvenberg.com/posts/containers-on-lambda), e.g. 5s, because the container cache is warming up. In production warm up Lambda after deploying. 67 | 68 | Function duration: 69 | 70 | | Memory | 1024 | 71 | |------------------|------:| 72 | | PHP function | 160ms | 73 | | HTTP application | 180ms | 74 | | Laravel | 850ms | 75 | 76 | Total latency (measured from API Gateway or X-Ray): 77 | 78 | | Memory | 1024 | 79 | |------------------|------:| 80 | | PHP function | | 81 | | HTTP application | 350ms | 82 | | Laravel | | 83 | 84 | ### Bref 2.x (PHP 8.3) 85 | 86 | Function duration: 87 | 88 | | Memory | 128 | 512 | 1024 | 1769 | 89 | |------------------|------:|------:|-------:|------:| 90 | | PHP function | 530ms | 290ms | 260ms | 250ms | 91 | | HTTP application | 500ms | 365ms | 340ms | 340ms | 92 | | Laravel | | | 1060ms | | 93 | 94 | Total latency (measured from API Gateway or X-Ray): 95 | 96 | | Memory | 128 | 512 | 1024 | 1769 | 97 | |------------------|------:|------:|-------:|------:| 98 | | PHP function | 700ms | 430ms | 440ms | 410ms | 99 | | HTTP application | 800ms | 640ms | 580ms | 640ms | 100 | | Laravel | | | 1640ms | | 101 | 102 | ### Bref 2.x ARM (PHP 8.3) 103 | 104 | Function duration: 105 | 106 | | Memory | 128 | 512 | 1024 | 1769 | 107 | |------------------|------:|------:|-------:|------:| 108 | | PHP function | 480ms | 260ms | 235ms | 230ms | 109 | | HTTP application | 430ms | 320ms | 315ms | 310ms | 110 | | Laravel | | | 1040ms | | 111 | 112 | Total latency (measured from API Gateway or X-Ray): 113 | 114 | | Memory | 128 | 512 | 1024 | 1769 | 115 | |------------------|------:|------:|-------:|------:| 116 | | PHP function | 670ms | 470ms | 430ms | 430ms | 117 | | HTTP application | 670ms | 630ms | 650ms | 570ms | 118 | | Laravel | | | 1530ms | | 119 | 120 | Measuring cold starts in CloudWatch Logs Insights: 121 | 122 | ``` 123 | filter @type = “REPORT” and @initDuration > 0 124 | | stats 125 | count(@type) as count, 126 | min(@billedDuration) as min, 127 | avg(@billedDuration) as avg, 128 | pct(@billedDuration, 50) as p50, 129 | max(@billedDuration) as max 130 | by @log 131 | | sort @log 132 | ``` 133 | 134 | ## Reproducing 135 | 136 | You will need [to install dependencies of Bref](https://bref.sh/docs/installation.html). Then: 137 | 138 | - clone the repository 139 | - `make setup` 140 | - `make deploy` 141 | 142 | Then run the `make bench-*` commands. 143 | -------------------------------------------------------------------------------- /laravel/config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'sqlite'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Database Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Below are all of the database connections defined for your application. 27 | | An example configuration is provided for each database system which 28 | | is supported by Laravel. You're free to add / remove connections. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sqlite' => [ 35 | 'driver' => 'sqlite', 36 | 'url' => env('DB_URL'), 37 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 38 | 'prefix' => '', 39 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'url' => env('DB_URL'), 45 | 'host' => env('DB_HOST', '127.0.0.1'), 46 | 'port' => env('DB_PORT', '3306'), 47 | 'database' => env('DB_DATABASE', 'laravel'), 48 | 'username' => env('DB_USERNAME', 'root'), 49 | 'password' => env('DB_PASSWORD', ''), 50 | 'unix_socket' => env('DB_SOCKET', ''), 51 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 52 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 53 | 'prefix' => '', 54 | 'prefix_indexes' => true, 55 | 'strict' => true, 56 | 'engine' => null, 57 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 58 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 59 | ]) : [], 60 | ], 61 | 62 | 'mariadb' => [ 63 | 'driver' => 'mariadb', 64 | 'url' => env('DB_URL'), 65 | 'host' => env('DB_HOST', '127.0.0.1'), 66 | 'port' => env('DB_PORT', '3306'), 67 | 'database' => env('DB_DATABASE', 'laravel'), 68 | 'username' => env('DB_USERNAME', 'root'), 69 | 'password' => env('DB_PASSWORD', ''), 70 | 'unix_socket' => env('DB_SOCKET', ''), 71 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 72 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 73 | 'prefix' => '', 74 | 'prefix_indexes' => true, 75 | 'strict' => true, 76 | 'engine' => null, 77 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 78 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 79 | ]) : [], 80 | ], 81 | 82 | 'pgsql' => [ 83 | 'driver' => 'pgsql', 84 | 'url' => env('DB_URL'), 85 | 'host' => env('DB_HOST', '127.0.0.1'), 86 | 'port' => env('DB_PORT', '5432'), 87 | 'database' => env('DB_DATABASE', 'laravel'), 88 | 'username' => env('DB_USERNAME', 'root'), 89 | 'password' => env('DB_PASSWORD', ''), 90 | 'charset' => env('DB_CHARSET', 'utf8'), 91 | 'prefix' => '', 92 | 'prefix_indexes' => true, 93 | 'search_path' => 'public', 94 | 'sslmode' => 'prefer', 95 | ], 96 | 97 | 'sqlsrv' => [ 98 | 'driver' => 'sqlsrv', 99 | 'url' => env('DB_URL'), 100 | 'host' => env('DB_HOST', 'localhost'), 101 | 'port' => env('DB_PORT', '1433'), 102 | 'database' => env('DB_DATABASE', 'laravel'), 103 | 'username' => env('DB_USERNAME', 'root'), 104 | 'password' => env('DB_PASSWORD', ''), 105 | 'charset' => env('DB_CHARSET', 'utf8'), 106 | 'prefix' => '', 107 | 'prefix_indexes' => true, 108 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 109 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 110 | ], 111 | 112 | ], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Migration Repository Table 117 | |-------------------------------------------------------------------------- 118 | | 119 | | This table keeps track of all the migrations that have already run for 120 | | your application. Using this information, we can determine which of 121 | | the migrations on disk haven't actually been run on the database. 122 | | 123 | */ 124 | 125 | 'migrations' => [ 126 | 'table' => 'migrations', 127 | 'update_date_on_publish' => true, 128 | ], 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Redis Databases 133 | |-------------------------------------------------------------------------- 134 | | 135 | | Redis is an open source, fast, and advanced key-value store that also 136 | | provides a richer body of commands than a typical key-value system 137 | | such as Memcached. You may define your connection settings here. 138 | | 139 | */ 140 | 141 | 'redis' => [ 142 | 143 | 'client' => env('REDIS_CLIENT', 'phpredis'), 144 | 145 | 'options' => [ 146 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 147 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 148 | ], 149 | 150 | 'default' => [ 151 | 'url' => env('REDIS_URL'), 152 | 'host' => env('REDIS_HOST', '127.0.0.1'), 153 | 'username' => env('REDIS_USERNAME'), 154 | 'password' => env('REDIS_PASSWORD'), 155 | 'port' => env('REDIS_PORT', '6379'), 156 | 'database' => env('REDIS_DB', '0'), 157 | ], 158 | 159 | 'cache' => [ 160 | 'url' => env('REDIS_URL'), 161 | 'host' => env('REDIS_HOST', '127.0.0.1'), 162 | 'username' => env('REDIS_USERNAME'), 163 | 'password' => env('REDIS_PASSWORD'), 164 | 'port' => env('REDIS_PORT', '6379'), 165 | 'database' => env('REDIS_CACHE_DB', '1'), 166 | ], 167 | 168 | ], 169 | 170 | ]; 171 | -------------------------------------------------------------------------------- /laravel/config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'database'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to expire immediately when the browser is closed then you may 31 | | indicate that via the expire_on_close configuration option. 32 | | 33 | */ 34 | 35 | 'lifetime' => env('SESSION_LIFETIME', 120), 36 | 37 | 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Session Encryption 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This option allows you to easily specify that all of your session data 45 | | should be encrypted before it's stored. All encryption is performed 46 | | automatically by Laravel and you may use the session like normal. 47 | | 48 | */ 49 | 50 | 'encrypt' => env('SESSION_ENCRYPT', false), 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Session File Location 55 | |-------------------------------------------------------------------------- 56 | | 57 | | When utilizing the "file" session driver, the session files are placed 58 | | on disk. The default storage location is defined here; however, you 59 | | are free to provide another location where they should be stored. 60 | | 61 | */ 62 | 63 | 'files' => storage_path('framework/sessions'), 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Session Database Connection 68 | |-------------------------------------------------------------------------- 69 | | 70 | | When using the "database" or "redis" session drivers, you may specify a 71 | | connection that should be used to manage these sessions. This should 72 | | correspond to a connection in your database configuration options. 73 | | 74 | */ 75 | 76 | 'connection' => env('SESSION_CONNECTION'), 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Session Database Table 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When using the "database" session driver, you may specify the table to 84 | | be used to store sessions. Of course, a sensible default is defined 85 | | for you; however, you're welcome to change this to another table. 86 | | 87 | */ 88 | 89 | 'table' => env('SESSION_TABLE', 'sessions'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Session Cache Store 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using one of the framework's cache driven session backends, you may 97 | | define the cache store which should be used to store the session data 98 | | between requests. This must match one of your defined cache stores. 99 | | 100 | | Affects: "apc", "dynamodb", "memcached", "redis" 101 | | 102 | */ 103 | 104 | 'store' => env('SESSION_STORE'), 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Session Sweeping Lottery 109 | |-------------------------------------------------------------------------- 110 | | 111 | | Some session drivers must manually sweep their storage location to get 112 | | rid of old sessions from storage. Here are the chances that it will 113 | | happen on a given request. By default, the odds are 2 out of 100. 114 | | 115 | */ 116 | 117 | 'lottery' => [2, 100], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Session Cookie Name 122 | |-------------------------------------------------------------------------- 123 | | 124 | | Here you may change the name of the session cookie that is created by 125 | | the framework. Typically, you should not need to change this value 126 | | since doing so does not grant a meaningful security improvement. 127 | | 128 | */ 129 | 130 | 'cookie' => env( 131 | 'SESSION_COOKIE', 132 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 133 | ), 134 | 135 | /* 136 | |-------------------------------------------------------------------------- 137 | | Session Cookie Path 138 | |-------------------------------------------------------------------------- 139 | | 140 | | The session cookie path determines the path for which the cookie will 141 | | be regarded as available. Typically, this will be the root path of 142 | | your application, but you're free to change this when necessary. 143 | | 144 | */ 145 | 146 | 'path' => env('SESSION_PATH', '/'), 147 | 148 | /* 149 | |-------------------------------------------------------------------------- 150 | | Session Cookie Domain 151 | |-------------------------------------------------------------------------- 152 | | 153 | | This value determines the domain and subdomains the session cookie is 154 | | available to. By default, the cookie will be available to the root 155 | | domain and all subdomains. Typically, this shouldn't be changed. 156 | | 157 | */ 158 | 159 | 'domain' => env('SESSION_DOMAIN'), 160 | 161 | /* 162 | |-------------------------------------------------------------------------- 163 | | HTTPS Only Cookies 164 | |-------------------------------------------------------------------------- 165 | | 166 | | By setting this option to true, session cookies will only be sent back 167 | | to the server if the browser has a HTTPS connection. This will keep 168 | | the cookie from being sent to you when it can't be done securely. 169 | | 170 | */ 171 | 172 | 'secure' => env('SESSION_SECURE_COOKIE'), 173 | 174 | /* 175 | |-------------------------------------------------------------------------- 176 | | HTTP Access Only 177 | |-------------------------------------------------------------------------- 178 | | 179 | | Setting this value to true will prevent JavaScript from accessing the 180 | | value of the cookie and the cookie will only be accessible through 181 | | the HTTP protocol. It's unlikely you should disable this option. 182 | | 183 | */ 184 | 185 | 'http_only' => env('SESSION_HTTP_ONLY', true), 186 | 187 | /* 188 | |-------------------------------------------------------------------------- 189 | | Same-Site Cookies 190 | |-------------------------------------------------------------------------- 191 | | 192 | | This option determines how your cookies behave when cross-site requests 193 | | take place, and can be used to mitigate CSRF attacks. By default, we 194 | | will set this value to "lax" to permit secure cross-site requests. 195 | | 196 | | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value 197 | | 198 | | Supported: "lax", "strict", "none", null 199 | | 200 | */ 201 | 202 | 'same_site' => env('SESSION_SAME_SITE', 'lax'), 203 | 204 | /* 205 | |-------------------------------------------------------------------------- 206 | | Partitioned Cookies 207 | |-------------------------------------------------------------------------- 208 | | 209 | | Setting this value to true will tie the cookie to the top-level site for 210 | | a cross-site context. Partitioned cookies are accepted by the browser 211 | | when flagged "secure" and the Same-Site attribute is set to "none". 212 | | 213 | */ 214 | 215 | 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /laravel/resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 |
20 | 21 |
22 |
23 |
24 |
25 | 26 |
27 | @if (Route::has('login')) 28 | 54 | @endif 55 |
56 | 57 |
58 | 163 |
164 | 165 | 168 |
169 |
170 |
171 | 172 | 173 | --------------------------------------------------------------------------------