Wordpress Wp-Login Keeps Asking For Re-Authentication (Sessions Expire Fast)

December 26, 2014 4.4k views
WordPress Load Balancing


I am running one instance of Wordpress running on 2 VPS, load balanced via a separate HaProxy VPS. I'm using Layer 4 Roundrobin. In addition, I have 2 MySQL databases for Master and Slave connected via HyperDB.

The set-up is similar to this tutorial:

Image of Set-Up

All VPS are running on Ubuntu 14.04.

Wordpress is logging me out every few minutes of inactivity and in addition, I am receiving redirect loops at wp-login.php:

I have WP on debug and this are the errors that gets thrown:

Notice: Undefined variable: write in /storage-pool/ on line 557
Notice: Undefined variable: write in /storage-pool/ on line 592

Line 557: if ( !$use_master && !$write && !isset( $ignore_slave_lag )
Line 592: if ( !$use_master && !$write && !isset( $ignore_slave_lag )

Can anyone advise on how I can resolve this?

1 comment
  • I would wager it has something to do with the layer 4 load balancing. I believe wordpress uses _SESSION to store pertinent info on the individual server. With layer 4, will the request persistently seek out the same droplet, or will it grab whatever server is available from the load balancer? If it is the later, I would guess that it will boot your session every time it gets the server without the SESSION info written. [Please note: neither wordpress or load balancing is my strong suit]

Be the first one to answer this question.