prdatur / phpminer

PHPMiner is a web interface for cgminer on linux machines
Other
34 stars 15 forks source link

Slow init of session #26

Closed sh1ny closed 10 years ago

sh1ny commented 10 years ago

When using filesystem to store sessions, sometimes initalizing session is slow sometimes. Only when using Access Management. More info here :

http://stackoverflow.com/questions/10385582/session-start-seems-to-be-very-slow-but-only-sometimes

There is 2 solutions :

  1. Use database to store sessions
  2. Use the following fix :
--- a/includes/Session.class.php
+++ b/includes/Session.class.php
@@ -97,6 +97,7 @@ class Session
                if (empty($tmp_sessid)) {
                        session_start();
                        $this->session_id = session_id();
+                       session_write_close();
                }
                else if (empty($this->session_id)) {
                        $this->session_id = $tmp_sessid;
@@ -112,4 +113,4 @@ class Session
                return $this->session_id;
        }

-}
\ No newline at end of file
+}
prdatur commented 10 years ago

Solution 2 is not possible, because then i can not write or delete to the session. And yes the session is only used when access management is active. In a normal env. it should not be such a problem with the session. I encountered this problem only on a real high cpu consume application on my dev life. So how much slower it is? And it is really worth the time? How often does it happen?

sh1ny commented 10 years ago

I was getting all the time for some reason. Most of the time, like after i open phpminer, spend some time there and just leave the tab open. After 7-10 minutes try to refresh or w/e and the page is stuck on loading. I am using nginx + php5-fpm and i enabled slow log on php5-fpm and it pointed me to the session_start(); line.

prdatur commented 10 years ago

How long have you wait then? is it worth to spend hours on it? because my time is limited :P

prdatur commented 10 years ago

I have added the session write close after the last (currently it is only at one position) session write finished. So this should speed up.