Could you point what must to be checked to make a Laravel app to runs quickly?

Eduardo Fuerte
Eduardo Fuerte used Ask the Experts™
on
Hi Experts

Could you point what must to be checked to make a Laravel app to run quickly?

I'm using php artisan serve, no errors are occuring, I changed execution time at PHP.INI (any other place is necessary when using Laravel?)

img001
Thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Code speed relates to how you've written your code, in most cases.

The problem above seems to relate to your database either being down or more likely slow.

Database speed/slowness is a function of your hosting. You really have little to no control over this, unless you're running on a bare metal (dedicated server) machine.

If you are running bare metal, you can easily review your logs to determine the problem + fix.

Normal first action is to run mysqltuner, addressing diagnostics which are meaningful for your specific database access pattern.
Eduardo FuerteDeveloper and Analyst

Author

Commented:
The same app runs quickly at other machines, it's a common Laravel project used by another programmers.

It's running locally at my PC.

I got elsewhere an opinion on increase the memory allocation by an Apache configuration and/ or MySQL configuration.

I changed PHP.INI
memory_limit=20000M

Any idea on how to configure it to increase MySQL memory in PHP.INI?
Eduardo FuerteDeveloper and Analyst

Author

Commented:
I found that the local station's MySQL data load script has too much duplicated lines, so when an "administrative profile" user (that I was logging in with) tries to log in, a lot of processing is done on this data in order to produce a dashboard to be presented, before the page open,  I only had this profile to login.

I got a workaround to access as a "regular profile" user and then there was no delay on the page presentation.

Then I droped the database recreated it and reinserted lines at DB without duplictions and everything get been normal.

Before I had created a virtual machine to be able to use Apache's larger configured memory (I don't know how to configure Laravel's internal server memory)  it seems that the process just got better too.
Developer and Analyst
Commented:
Accordingly with above, I found what is causing the slowness.
Eduardo FuerteDeveloper and Analyst

Author

Commented:
Thanks David!
David FavorFractional CTO
Distinguished Expert 2018

Commented:
You're welcome!

About MySQL performance enhancements.

1) Largest performance boost. Deinstall MySQL. Install MariaDB.

Since MariaDB is a... faster + more functional MySQL, same data files are used, so MariaDB is usually just a drop in replacement.

Normal performance testing I've done, shows a 30%-50%+ performance boost for the few minutes of work to install MariaDB.

2) If slowness relates to row count, this points to a schema deficiency (lack of UNIQUE constraints on indexes).

This problem is best fixed at the table level, else the same problem will likely reoccur in production.

Temporary fix will be to add a LIMIT clause to your SELECT statements.

3) Running mysqltuner each day, then implement tuning suggestions, till suggestions no longer emit... is a simple way to boost performance.

4) Tip: Likely best run on a machine with 64G-128G of RAM for best database flexibility tuning.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial