2007.05.14
投稿のテスト(BlogPet)
うまく投稿できるかな?
*このエントリは、BlogPet(ブログペット)の「Pandy」がテスト投稿の為に書きました。
17:24 Permalink | Comments (0) | Email this
2007.05.01
PHP Idiosyncrasies
Three reasons to make sure you know your programming language:
function test($code) {
$result = @eval("return ({$code});");
print ($result ? 'true ' : 'false ') . "$coden";
}
test( "gettype(key(array('s' => ''))) == 'string'" );
test( "gettype(key(array('1' => ''))) == 'string'" );
test( "'s' == 0" );
test( "0 == 's'" );
test( "$x == $x++" );
test( "(int)$x == $x++" );
And here's the output:
false gettype(key(array('1' => ''))) == 'string'
true 's' == 0
true 0 == 's'
false $x == $x++
true (int)$x == $x++
In case you didn't catch what PHP is doing on the last pair, here's the equivalent processing in PHP code:
$x++;
($x == $y)
When casting $x with (int), PHP is no longer able to make use of the "let's just use a reference" over-optimization. Personally, I think it's a bug that the behaviour differs between the two.
Debuggers beware! ;)
18:50 Posted in General | Permalink | Comments (0) | Email this
2006.03.29
Blogs... the latest Internet virus
With only one (real) entry of my own and a few words via text chat, I've managed to convince my best mate to start a blog of his own. For those that aren't technically minded, while I do/will try to cater for you too, I'm sure you'll find a lot of more mind tingling thoughts over his way. Check it out at http://seanwilliams.blogspirit.com/.
00:40 Posted in General | Permalink | Comments (0) | Email this
2006.03.28
OpenBSD arpbalance'd firewalls - what's the secret?
As part of our moving to a new data centre, I get to set up everything from scratch in whatever way I think best. On the inside, I will be using OpenVZ on just about every machine. With a couple of patches and a little hack to get around OpenVZ's current lack of a MAC address per VE, I've been able to set up a fully load-balanced and highly available infrastructure on both the front servers and the back servers. On the front servers, I'm running LVS-DR on what OpenVZ calls the "hardware node". On the backend, I'm using MySQL's replication in a circular master/master fashion and using UCARP to designate which master the front servers should be accessing. The back end isn't exactly load balanced; each database is only served from one server but each server is actively serving multiple databases.
While most of the above was easy to set up out of the box and the patches were fairly easy to write when out-of-the-box didn't cut it, OpenBSD is a little bit more interesting. I've managed to set up an active/passive configuration fairly easily. Apparently, duplicating the CARP interfaces and then flicking on the arpbalance sysctl is meant to give an active/active configuration - it doesn't. In some cases, a client will access a server via firewall A and the server will send the response back through firewall B. Pfsync doesn't work synchronously (a glance through the code seems to indicate up to a one second delay) so firewall B mishandles the server's response and things break.
I've tried patching to make pfsync unbuffered. With an unbuffered pfsync, the initial state is synchronized correctly but is followed with many "stale state" messages and the connection ends up dying anyway. My patch also seems to have broken bulk updating but I've let that go for the time being. Purely for testing purposes, I've disabled the dropping of stale sync messages and now the connection doesn't break although there are a few "burps" here and there. There's a bunch of "BAD state" messages showing up on one of firewalls which are likely causing the burps.
Persuing fully synchronous firewalls seems like a worthwhile project for the future but what I don't understand is why almost nobody else is experiencing the same problems as I am. Conversely, I've been able to find many instances of people saying that it does work and working in production at that. My only question is "why?" From what I can tell, the only way it could work is if the arpbalance'd firewalls ensure that the packets between any client-server pair pass via the same firewall in both directions. I just can't see how this can be done with the set of available knobs. If somebody were to say that arpbalance is only intended for use with server load balancing, I'd be satisfied but that's not the case... What's the secret?
18:55 Posted in Work@ | Permalink | Comments (0) | Email this
2006.03.25
A new trend begins?
I've finally started a blog. This service does everything I want - categories, template editing, unicode...
ブログをやっと始めたよ〜。このブログスピリットはカテゴリー、テンプレート更新、ユニコードなどわたしがしたいことが全て出来ます。
10:20 Posted in General | Permalink | Comments (2) | Email this

