Support the ongoing development of Laravel.io →
posted 10 months ago
API
Last updated by @nei 10 months ago.
0

Update: the api is being responsive for a few minutes and suddently it starts to slow down and timeout. I've already disabled the throttle provider.. any advices what else to check?

0
moderator

Hello @nei

Do you have the possibility to monitor your server? Is the load in PHP, apache/nginx or maybe your database?

What I did for a project is disable all providers that I don't use, see: https://gitlab.com/tjvb/placephant/-/blob/main/config/app.php?ref_type=heads#L157-197

Do you use any queued jobs? Because I see your queue is sync, that means it will be executed directly. Using the queue can create an improvement for some applications but not if you use the sync queue :)

But besides that you need to find out what is the slow part of your application. You can check the logs, process monitor, server load and more like that.

0

Thank you @tvbeek I will review those providers and see what I can disable.

I will try monitor the server to try figure out, yes maybe that is a server issue due to fact micro instance is single core I think that could be an issue.

Regarding queued jobs, not using it atm but I will look on how I can take advantage of it too.

Thanks

0

@tvbeek I see your sample app do not have api. what would be the best approach to setup two different app.conf based on the app you are deploying (website, api)

I would like to deploy api with very limited Providers (disabling pagination, bootstrap, some listeners, etc) but for web I want it fully.

Have you checked the overhead those providers adds?

0
moderator

@nei It is correct that it doesn't have an api :)

Do you mean that you deploy the same application twice? Once for the api and once for the frontend?
If that is true I should use a config that is filled from an .env variable to switch between the web and the api version.

Limiting the providers is a very small improvement, and has impact on what is available while developing your application. I advice to first monitor your bottle necks (and to be honest in my experience it is almost always the server and/or the database query)

nei liked this reply

1

Do you mean that you deploy the same application twice? Once for the api and once for the frontend? Yes. I deploy to two different destinations, the deployment make sure they have their own route provider so that routings from frontend do not show on the api application. I also have a custom .env for each of them.

my deployer.org script

// Shared files/dirs between deploys
add('shared_files', [
    '.env',
    'app/Providers/RouteServiceProvider.php'
]);
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Nei Santos nei Joined 15 Aug 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.