maxmind / GeoIP2-php

PHP API for GeoIP2 webservice client and database reader
https://maxmind.github.io/GeoIP2-php/
Apache License 2.0
2.33k stars 276 forks source link

C Extension - optimalization questions #62

Closed 2ge closed 8 years ago

2ge commented 8 years ago

Hi,

I installed C extension, so in phpinfo() I see

maxminddb
Version 1.0.3

I am using also composer and geoip2/geoip2 (v2.3.3).

I am wondering, if C extension is actually used. When I uninstall PHP lib, it throws error. The thing is I need really optimise my IP lookups, do you have any suggestions ? Now I see it is really slow (slowest part of my website - sometimes it takes 5(!) seconds for 1 lookup, here is screenshot:

https://www.dropbox.com/s/r9r4pi0qqmg1koq/Screenshot%202015-11-24%2001.30.16.png?dl=0

I have on my servers YAC, Redis etc, so maybe freezing object into memory is possible ? I dont want to cache IP -> country into redis...

oschwald commented 8 years ago

I am not sure what the explanation is for your extremely slow lookup times is, but if the extension is loaded it should be used. The extension uses a couple of classes defined in pure PHP (e.g., the exception object). I guess you could try removing Reader.php if you want to confirm this yourself.

Your lookup times are definitely very abnormal; I assume there is something else going on.

2ge commented 8 years ago

thanks for fast answer. I turned on xdebug and restarted server, it always takes couple of minutes to perform "normally". When I check performance dumps I see in later dumps it was not a problem, so I guess, it was just temporary thing after restart (weird, but thats it).

I guess it would be good to find out for sure, if extension is used by calling some method in PHP lib.

oschwald commented 8 years ago

I am going to close this, but if the issue has recurred or you have more information, please let me know and I will re-open it.