Question

I've been trying to find a proper GeoIP database for our application and as far as I can tell MaxMind City is probably the best (though if I'm wrong please let me know!). I'm currently trying out the free version which isn't really accurate in the UK, but it will do for testing purposes.

So getting back to the topic:

Our app is written in PHP and eventually we'll be having a lot of incoming traffic. The reason why we'll be using the GeoIP database is because we need to display the city, region, country on every page load as well as save the data for a specific visitor onto a mysql database. So I started thinking that loading the binary data on every page request will cause the server to consume a lot of RAM and will increase the processing speed. That's why I'm wondering if it's possible to cache it inside RAM and fecth it with PHP, because it's 26Mb (I know it might not seem to be a lot), but still when we start to get thousands of page requests per second this will result in performance decrease which we obviously want to avoid.

The server:

Processor: 16 GHz (8 x 2 GHz)

RAM: 16384 MB

HDD: 400 GB

Apache + Nginx + Varnish, PHP5.3, MySQL5.1

We're quite new to large-scale app development so if you have any suggestions how to improve performance in general, or have any other tips related to increasing performance for our case let me know.

Thanks!

Was it helpful?

Solution

We are using MaxMinds GeoIP City for an Adserver application (so there is really much traffic). Some tests based on test scripts from MaxMind which put the database into memory was not efficient enough for us. Because data was cached for every single PHP process. So we decided to put the two tables (ip2location and city) into MySQL (you have to download the CSV files), which will cache the tables in memory also, because they are really small. With a clustered index on ip2location table, we're able to query a loc_id for an IP in round about 10ms, so you just have to get the city data based on this loc_id, but this should be very fast also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top