Laravel Session Vs Native PHP Session Performance Difference

I am building a laravel site and I just found out that laravel sessions do not extend to native php sessions.

At the moment, I see no difference in performance, but this site will receive full traffic. Is it best to stick to as many embedded PHP files as possible, or is the laravel implementation for sessions more efficient than php?

+5
source share
1 answer

If you use Laravel 4.0, it uses the built-in PHP session as its default session driver , so the difference is not significant.

Starting with Laravel 4.1, the new default session driver is called file , which stores session data in files on disk and according to their release 4.1 notes , their sessions are now โ€œfaster and fasterโ€:

Improved Session Engine

In this issue, we also introduce a completely new session engine. Like routing improvements, a new session layer is more compact and faster. We no longer use the processing capabilities of Symfony sessions (and therefore PHP), and use a custom solution that is simpler and easier to maintain.


Alternatively, you can use Redis or memcached to handle sessions - Laravel has drivers out of the box ( note: for something new, you should use Redis, not memcached ). You can consider this option if you have large session data (complex objects / data, rather than multiple rows or integers stored) and / or a huge number of concurrent users (10000 +).

These drivers will store session data mainly in memory, not on disk, so they will be faster and more efficient, although performance gains will be more likely than not to be negligible unless you encounter a performance bottleneck associated with the session. If you have such large session data that it causes performance problems, then it may be appropriate to consider this before attempting to reconfigure the session mechanism.

+4
source

All Articles