This was the first implementation in PHP, it seaches directly in the file, so it doesn't consume a lot of memory.
Running on this server (VIA C3 1GHz, 512MB RAM), we get around 1000 lookups per second.
I thought that using Shared Memory would make it run SUPER fast. So I wrote a little tool to make it easier to work with shared memory, then implemented the solution - I was TERRIBLY mistaken, speed-wise. Using this version, on the C3 server, I get approximately 850 lookups per second. Very disappointing. Does anyone know why?
We thought that reading the entire datafile into memory, would enhance performace significantly. And not using Shared Memory should help a lot. Strangely, it improved only little over the file access version, but that may be because my server is pretty idle all the time ;) Using this version I squeezed out around 1100 lookups per second.
In the package, is included a small test application (index.php), the benchmarking applications, shared memory tool class, an ISO country array that converts our resulting two char country code to a full name, a geoip benchmark app. (you need the geoip.inc and the geoip.dat file from maxmind). Also it contains the benchmark application for our PHP module implementation (see below), and a version of the binary database.
Oh, and if you don't like the broken images in the test application then download the world.small.zip file from here, and place it in a world.small folder where index.php is...
world.small.zip flag collection - Download it if you don't like the broken images in the php example
ip2c-php-0.9.2.tar.bz2 - PHP Source code bzip2'ed (396 KB)
ip2c-php-0.9.2.zip - PHP Source code zipped (334 KB)
| Etomite encountered the following error while attempting to parse the requested resource: | |||
| « PHP Parse Error » | |||
| PHP error debug | |||
| Error: | mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) | ||
| Error type/ Nr.: | Warning - 2 | ||
| File: | /www/weirdsilence/weirdsilence.net/www/index.php | ||
| Line: | 118 | ||
| Line 118 source: | if(@!$this->rs = mysql_connect($this->dbConfig['host'], $this->dbConfig['user'], $this->dbConfig['pass'])) { | ||
| Parser timing | |||
| MySQL: | 0.0000 s s | (0 Requests) | |
| PHP: | 0.0315 s s | ||
| Total: | 0.0315 s s | ||