top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

PHP Webpage Persistence Load balancing problem

0 votes
329 views

I'm having a webpage Persistence problem, it is intermittent. I suspect it is caused by load-balancing. Specifically:
Users are connected to a webpage form to complete. Generally, everything is OK if they take a minute or even more to complete the form. However, sometimes they report to me, and I've seen it myself, the connection has been dropped by the server in a short time. They enter the data and Submit it to the server, and the page just reloads and their data is lost.

I have the PHP ignore_user_abort(true); etc. Is there anything I can do to fix this or is it a server issue that you must fix?

posted May 29, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Are you using sessions for persistence? If so, is your session storage in a location that is shared between servers behind the load balancer? (Shared network path, database, etc.)

answer May 29, 2013 by anonymous
0 votes

Well, either way, it would be up to you to fix it. We wouldn't have anything to do with the server (well, unless you were hosted with my company, but the PHP project itself isn't any way related to the corporate stuff). Of course, it could just be the ambiguity of the term "you" in the sentence throwing me off here.

That said, is this a standard HTML page displayed in a normal, modern-era browser, or is there a different frontend, such as Flash, a mobile client, an API, or something of the sort? And is the page being timed-out with JavaScript, or simply timing out with the sessions?

Lastly, if you suspect that it is the load-balancing, and the balancer isn't capable of persistence itself (such as if you're using round-robin), and sessions themselves are breaking, it's probably because you're relying on file-based sessions, which do not (by default) synchronize between servers. Instead, you'll need to centralize your sessions in a database, memcached, or similar option.

For some hints on session management and how you can manage it across server clusters, check out the session_set_save_handler() function http://php.net/session_set_save_handler

answer May 29, 2013 by anonymous
Similar Questions
+1 vote

I am trying to figure out if I can run my sessionpersistence script that I run with Apache to see if sessions persist between two tomcat sites on two separate servers. The load balancer has session persistence enabled but Iam unsure how to test it. My thought was that I would just add the following php script to check, but apparently I am doing something wrong. The script is this:

but it seems not to like it if I add it from the webapps directory or from inside a directory under that. Is there some special trick to running php from inside tomcat ? I have tomcat set up the same on both servers and am fronting it with Apache if that adds options for me.

0 votes

PHP:: Suppose I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, whats the problem?

+2 votes

I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by....

anyway I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:

exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04". So - where is the hour value of '07' coming from?? And how do I get this right?

...