开发者

Best Practice to Quickly GeoTarget using PHP / Apache / Ginx

My flow is currently like this:

Nginx (Proxy) -> Apache -> PHP

I need to somehow make the originating country available to php.

The most trouble free way would be if browsers reliably report the users country. Does anyone know if this is the case?

Beyond that, something like MaxMind GeoIP would also work, however I can't have it become a bottle-neck.

I could install the nginx geoip plugin, or the apache geoip plugin... But my concern here is stability. If this plugin crashes, it seems it could entirely kill nginx or apache respectively.

I think the best way would be to have php connect to an external process, using a sub-second time-out so as not to block the process if geo-ip-lookups aren't working.... But again here, I'm not sure how efficient it is to have PHP reach out to another process, or the best way to have it reach out.

I need to be able to handle 10 of these lookups per second...

The most scalable way to me would seem to be to load the geoip database into mysql, which is reliable enough that I would not be overly concerned about it bec开发者_如何学Pythonoming unavailable and knocking down the whole site with it.... Though my guess is that the MaxMind geoip format that is read by their c code is likely more efficient than this method.


The MaxMind plugin for Apache is pretty robust, I've run it on servers handling 10s of millions of uniques/day no problem. It's also pretty simple which helps. Building some extra system to handle the lookups and return back seems like added complexity for no benefit. Make sure you get the subscription for updates to the DB over time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜