Cache and Eager Loading for Laravel framework [Benchmark of php frameworks v0.0.5]

in #utopian-io7 years ago (edited)

In Release 0.0.5 :
Add new tests for laravel:

  • Use Cache for load posts from DB in 'posts' most heavy page. But it doesn`t solve the problem
  • Use Eager Loading for load posts from DB in 'posts'. It is very fast.

More informations about changes.

This release is the next step in my road-map. As you remember, I planned to add query caching to reduce the loading time of the 'posts' page. I decide to start with Laravel framework.
I was very surprised by the results of the tests after adding caching. Time of generation was the same.
I began to dig deeper and found out that in addition to a large amount of data, there is still multiple access to the database for obtaining related data. For each entity from 3 to 10 queries.

  • $post->author->name
  • $post->postType->name
  • $post->categories : $category->name

For our 1000 records, we get about 10,000 requests.

So we need to see what the results will be when using Eager Loading.
And what will the results be if we use the Cache + Eager Loading.

frameworkrequests per secondrelativepeak memoryrelative
laravel-index9.93248.36.2114.2
laravel-posts-eager_load-cache9.10227.57.3716.9
laravel-posts-eager_load8.02200.57.3616.9
laravel-authors7.20180.07.3416.8
laravel-categories6.80170.07.5117.2
laravel-posts0.041.015.1334.7
laravel-posts-cache0.041.018.4642.3

As we can see in the case of laravel-posts and laravel-posts-cache, only the peak memory has increased.
But if we use Eager Loading (laravel-posts-eager_load-cache and laravel-posts-eager_load in table) then the peak memory is lower and requests per second is a lot more
005.png
http://php-frameworks.semasping.info/bm/result-releases/0.0.5/

Roadmap:

  • Try to use Cache for all frameworks (Done for laravel. Next step: Cache for Phalcon)
  • Implementing a test application and running tests on Symfony
  • Implementing a test application and running tests on Yii
  • Connection with https://blackfire.io/
  • Deal with the Docker and wrap it all up in it. To be able to quickly deploy to a more powerful server for comparison.

PS: More information about structure of test application

Part 1. Introduction. - Why i decide to do new bencmark of php frameworks.

Part 2. Database scheme and generating data for testing app. - Description of application, database structure and data.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

The @OriginalWorks bot has determined this post by @semasping to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Please note that this is a BETA version. Feel free to leave a reply if you feel this is an error to help improve accuracy.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Дрyзья, а дaвaйте в поддeржкy вырaзим дружнo наше отношение к этому пoсту...

Поддержала!

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.029
BTC 76535.07
ETH 2962.73
USDT 1.00
SBD 2.65