M
M
Maxim Grekhov2014-06-19 14:57:12
Yii
Maxim Grekhov, 2014-06-19 14:57:12

What is the performance of yii2 and laravel?

Hello. Decided to study web programming. Since I am the owner of cubieboard2, I raised the lamp server and decided to study php. Wordpress renders a page on it in 3-5 seconds, so I decided to study something more lightweight.
At first I tried yii2, everything seems to be fine. Since lately cries about laravel have been heard from everywhere, I decided to try it. I liked it more, all sorts of goodies from the box. Yes, and there are more examples / ready-made solutions for him at the moment. I downloaded the starter project and ran it.
The performance really surprised me. Generating a simple page without accessing the database 1.5-2 seconds. Using this caching method, I got performance in the region of 1 second per request. Then I tried an empty project

composer create-project laravel/laravel your-project-name --prefer-dist
300 milliseconds to get an empty view. Caching by the same method gives no visible results at all. The server keeps around 12 requests per second.
I also tested yii2. About method request (text page) 200 milliseconds. With caching 50-100. Further the controller, I twist, models are received by generation. Without caching, we get 3 records and draw a table (reference to the index method) - in the region of 300-400 milliseconds. With caching, the time drops to 50-100 milliseconds. The server starts to withstand 40-50 requests per second.
I use caching in yii like this (for testing):
$key = 'ContentController-actionIndex';
        $value = Yii::$app->cache->get($key);
        if ($value === false)
        {
            $searchModel = new ContentSearch;
            $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

            $value = $this->render('index', [
                'dataProvider' => $dataProvider,
                'searchModel' => $searchModel,
            ]);
            Yii::$app->cache->set($key, $value, 1000);
        }
        return $value;

The question is what am I doing wrong with laravel? Is it possible to speed up yii2 even more?
Update 1: Used APC for caching.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
Maxim Grekhov, 2014-06-23
@Sterk

I will answer my problem. Maybe someone will come in handy.
Delivered in VirtualBox Ubuntu Server. I gave him 1 core of my i7 and 1 gigabyte of RAM.
The server calmly withstands 40 or more requests per second (I couldn’t do more because I couldn’t set up Apache for stable operation, every 30 seconds there was a delay peak and the return time graph went astray, which interfered with observation). As a result of a couple of days of testing, I came to the conclusion that yii2 incurs less overhead.
With 40 requests, yii2 for its basic template renders a page in 7.5-10 milliseconds (CPU usage jumps within 20-30%). An empty Laravel project with HomeController and 1 view renders a page in 10-15 milliseconds (CPU usage fluctuates within 30-40%). At the same time, even with caching and sessions configured (for not using hdd - apc driver), there is a use of hdd, which causes problems in the case of a Linux server on an SD card.
Lavarel requires 1.5-2 times more time to execute the simplest scenario - requesting 1 method with the return of the simplest view.
The resulting statistics are most likely completely unimportant for regular servers, but in my case it does not speak in favor of Laravel.

A
Alexander N++, 2014-06-19
@sanchezzzhak

Yii can speed up turning off log and setting up another cache adapter.
Laravel suffers from the same garbage, the log cache adapter. session on cookies to change should add speed.
I really love Yii2 and like it more with every commit, I use it in my personal projects.
I use Laravel at work and for a number of projects that need to be supported. + It is easier for the team when there is no zoo of frameworks.

A
Alexander Makarov, 2014-06-20
@SamDark

Here is another piece of the official guide on the topic: www.yiiframework.com/doc-2.0/guide-performance.html

P
Puma Thailand, 2014-06-20
@opium

Heh, you're funny
The fact that you can't cook something doesn't mean it's slow
www.webpagetest.org/result/140620_HV_E8S
the first byte after 141 milliseconds

D
Dmitry Mitselin, 2015-02-22
@Mycelin

141 milliseconds is monstrously slow for a simple page.
I chose laravel because it responds within 50ms.

N
nimda13, 2018-10-25
@nimda13

Made a simple page with default configs on my home slow server. My results
1.4 seki laravel
0.5 seki yii
0.03 native code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question