Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pawan.khade's avatar

Project API are taking too much load on server

Recently developed one project for company and in live testing of 2000 users we found that server is taking too much load. We investigated it and improved server configuration but still problem remains. Is it because there is problem with the approach of my coding?

I have used service classes approach for developing api in laravel. so my controllers are slim, models are also slim, but service classes are fat. and i have used passport for communication with React js front end.

I have used defferable providers for registering my service classes.

Ex: public function register() { $this->app->singleton(Admin::class, function ($app) { return new Admin(Auth::user()); }); }

I have also used Collection resources liberally to create resources in api. just wanted to ask is it a bad practice to follow if application is going to have too many hits in specific time interval?

0 likes
3 replies
RyanThePyro's avatar

Are you caching cacheable responses? Might consider a proxy cache for those cacheable endpoints that would skip the app entirely.

pawan.khade's avatar

No I am not using Caching. Its just a basic setup. Same application in core php is serving 2500 users without any server load on ec2 64GB server.

1kr1's avatar

Your fix might be a bit more complex than you think...

  • Deferable providers, if you have loads of them, do have a performance impact
  • I'm not sure about what this translates into exactly : 'I have also used Collection resources liberally to create resources in api', but you might do a bit of research on best practices
  • Caching improve loading time, on some of the requests

Now, have a look at the requests using laravel debugbar, do you have duplicate queries, n+1 problems, memory issues? How long does it takes, for example, a request that brings back the currently auth user? If that request by itself takes an unusual amount of time, then look into app bootstraping configuration, you probably have some issues there as well...

It's a matter of try/make/break really.

Please or to participate in this conversation.