[email protected] Posted June 12, 2009 Share Posted June 12, 2009 Hi, I'm admin-ing a Wordpress blog for my father, and it's gotten rather more popular than I (with my limited skills) would like, to the extent that I've had to extend it to using two web servers (both apache2, called www1 and www2) and one database server. I have implemented simple load balancing, by when- on www1 - a request comes in, a dice is thrown, and then 60% of requests are sent by client side redirects to www2. My PHP script simply reads the requested URL (of the format index.php/something), and then changes www1 to www2 and sends back an appropriated redirect. This works well except that when clients are redirected to www2 then certain environment variables are not passed. So, forms are not pre-filled in, etc. What I would like to do is 'collect' all the POST information, session information, etc., I can, and then pass it in some way in the redirect. Is this possible? And is my technique of using meta tags and refresh the right way to achieve my goal. Many thanks, Robert Link to comment https://forums.phpfreaks.com/topic/161943-using-php-to-load-balance-apache/ Share on other sites More sharing options...
Mark Baker Posted June 12, 2009 Share Posted June 12, 2009 better to do the load balancing before the request hits the web servers, or at least hits PHP; not redirect it via your PHP script. That's simply adding to the workload by making the request against www1, then redirecting it on to www2... one request is converted into two. Link to comment https://forums.phpfreaks.com/topic/161943-using-php-to-load-balance-apache/#findComment-854454 Share on other sites More sharing options...
[email protected] Posted June 12, 2009 Author Share Posted June 12, 2009 While that's almost certainly true, my way doesn't require any knowledge of how apache works! The bottleneck in the blog is that displaying 500 comment threads in Wordpress is *slow*. A few lines of php to redirect a certain proportion of the time is not slow. Server side redirects may be more sensible that using the HTTP refresh tag, but I'm quite happy with the performance. My issue is solely that I 'lose' POSTed data and other environment variables. Link to comment https://forums.phpfreaks.com/topic/161943-using-php-to-load-balance-apache/#findComment-854466 Share on other sites More sharing options...
Mark Baker Posted June 12, 2009 Share Posted June 12, 2009 While that's almost certainly true, my way doesn't require any knowledge of how apache works!Perhaps, except you're not redirecting with all the post values (no idea about sessions or cookies, but probably the same), so your way doesn't actually work The bottleneck in the blog is that displaying 500 comment threads in Wordpress is *slow*. A few lines of php to redirect a certain proportion of the time is not slow. One alternative option might be to look at what is slowing wordpress down. It's entirely possible that performance there could be improved. Server side redirects may be more sensible that using the HTTP refresh tag, but I'm quite happy with the performance. My issue is solely that I 'lose' POSTed data and other environment variables.Another alternative is to look at something like curl to make the request of www2 rather than a simple query redirect which can only pass on get parameters. Link to comment https://forums.phpfreaks.com/topic/161943-using-php-to-load-balance-apache/#findComment-854480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.