CodeIgniter Forums
ion_auth's 1.2mb memory usage - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: ion_auth's 1.2mb memory usage (/thread-69555.html)



ion_auth's 1.2mb memory usage - ponzo - 12-13-2017

Hello,

I'm a happy user of Ben Edmunds ion_auth.

I was profiling my app, and ion_auth costs 1.2 mb memory on top of my exisiting app, for each pageload
Cant do a better job for the auth part of then ben's ion auth, but i think it's maybe a bit overdone for my application.

4 options to share
a) 1.2 mb isnt a problem at all!
b)  only use this library when a user go's for example to /login , and to check if a user is logged in, make a simple rewrite of
ion_auth->logged_in, so you can skip loading the whole ion_auth library
c) use another auth library below 1.2mb memory usage
d) use an external login API ( i recently only used Instagrams auth api and stored the session in my database)

Best !


RE: ion_auth's 1.2mb memory usage - qury - 12-14-2017

HI,

I'm not so familiar with your code, but profiling gives me the following result:

I've benchmarked Codeigniter 3.1.6's Welcome controller with the latest ion auth from git.

bare                                         499800 bytes
bare + session library                 522880 bytes
bare + session library + ion_auth 776272 bytes

So for me the difference is 253392 bytes (0.24 MB) with which i can live with.

Also this is on PHP 7.1.11 which has lower memory usage compared to PHP 5.x.x

I've also checked what happens if i just load the ion_auth_model and create a copy of the logged_in() function locally.

The memory usage in that case was:  758864 bytes (0.225 MB), so for me it is not worth it to create a custom lib for this.

PHP Code:
public function loggedin()
 {
 
$this->load->model('ion_auth_model');

 
$this->ion_auth_model->trigger_events('logged_in');

 
$recheck $this->ion_auth_model->recheck_session();

 
// auto-login the user if they are remembered
 
if (!$recheck && get_cookie($this->config->item('identity_cookie_name''ion_auth')) && get_cookie($this->config->item('remember_cookie_name''ion_auth')))
 {
 
$recheck $this->ion_auth_model->login_remembered_user();
 }

 return 
$recheck;
 } 



RE: ion_auth's 1.2mb memory usage - ponzo - 12-14-2017

Hi, tested only local on MAMP, php 7.15

Bare install, ion_auth in welcome.php controller and with enable_profiler

Without
1182440 bytes

With
2557176 bytes

Tested on two different machines (but both Mamp) 

And on production VPS
2 cores / 4.096 MB / CPanel 11.38 + CentOS 6.4

Without
1353664 bytes


With (php 7)
2544984 bytes

With (php 5.6)
3236072 bytes

http://auth.ponzo2.nl/welcome
http://auth.ponzo2.nl/authtest


RE: ion_auth's 1.2mb memory usage - qury - 12-14-2017

you must have a bunch of libraries and stuff auto-loaded, right?


RE: ion_auth's 1.2mb memory usage - ponzo - 12-14-2017

(12-14-2017, 02:55 PM)qury Wrote: you must have a bunch of libraries and stuff auto-loaded, right?

Hi Qury,

No, no autoloads, clean install, no other libraries except the ion_auth inside the controller  

Im not an cryptography expert, but the native PHP password hashing API in php > 7.0 
Is enough for safe password hashing (before storing into the database) and verify them when a user is loggin in
https://php.earth/docs/security/passwords

Best