Replies: 4 comments 4 replies
-
Hi! Could you share your serverless.yml? (with sensitive parts redacted) Things we could check: memory size, which runtime you are using, etc. Also can you confirm that everything (serverless app + RDS) is running in the same AWS region? And could you detail how you measured those differences? From your machine? Do you account for cold starts? (which metric do you check: if you check the average then the cold stars might be messing up the average, look at p50 instead with a large number of requests) How do you connect to the database? SSL checks? |
Beta Was this translation helpful? Give feedback.
-
@mnapoli Yes, sure: service: my-test-project
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: us-east-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
environment:
APP_KEY: ${env:APP_KEY}
APP_ENV: ${env:APP_ENV}
APP_DEBUG: ${env:APP_DEBUG}
APP_URL: ${env:APP_URL}
FRONTEND_URL: ${env:FRONTEND_URL}
CORS_URLS: ${env:CORS_URLS}
DB_CONNECTION: ${env:DB_CONNECTION}
DATABASE_URL: ${env:DATABASE_URL}
package:
# Directories to exclude from deployment
patterns:
- '!node_modules/**'
- '!public/storage'
- '!resources/assets/**'
- '!storage/**'
- '!tests/**'
functions:
# This function runs the Laravel website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-81-fpm}
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-81} # PHP
- ${bref:layer.console} # The "console" layer
events:
- schedule:
description: Running the Laravel Scheduler (schedule:run) each minute
rate: rate(1 minute)
input:
cli: schedule:run
plugins:
# We need to include the Bref plugin
- ./vendor/bref/bref
Yes, it's in the same AWS region
Yes, from my machine, just looking for initial document response time. Most of the time is waiting time. I see a bit difference on download time due to Heroku gzips data, but wait time is almost twice bigger on Serverless anyway.
I run test repeatedly multiple times manually:
Not sure, just with a DATABASE_URL on a public url, configuration is the same on Heroku and Serverless. |
Beta Was this translation helpful? Give feedback.
-
I used I just tried to deploy with
I installed deps with --no-dev.
I tried from multiple VPNs, USA, Europe, and it's the same everywhere. Everywhere Serverless is slower 1.5-2 times. I also noticed significant delays in my frontend Nuxt app compared to deploying it directly on EC2 instance. Not sure why, but serveless in all cases have some additional latency. For example this app is deployed to Serverless, takes about 400-500ms to load: https://www.projectcredo.com/about |
Beta Was this translation helpful? Give feedback.
-
Since it seems like a Laravel app, you could try with the debug bar (https://github.com/barryvdh/laravel-debugbar) enabled and check the profile of your requests. My money is on I/O bound issues. If nothing stands out of you could still use APM tools to go deeper like blackfire or new relic. |
Beta Was this translation helpful? Give feedback.
-
I'm curious why response time might be slower, I tested my app (that is currently deployed on Heroku on the cheapest dyno) on serverless with bref, both apps use the same RDS.
When I do tests I see that serverless in average is twice slower, so requests that take around 400ms on Heroku, take 800ms on serverless. Endpoints that take 200ms on Heroku on Serverless take 400-500ms. This numbers are taken from my browser.
Is there any way to improve the performance, my laravel endpoints are quite database intense, but both deployments use exactly the same DRS, so database connection should not be a bottleneck, then something else is limiting performace on Serverless significantly.
Beta Was this translation helpful? Give feedback.
All reactions