Maxmind database file too large for AppEngine App

2019-09-07 06:53发布

问题:

I'm trying to deploy the MaxMind geoIP database as part of a Java app deployed in Google AppEngine. Things worked okay when we were using the free version, but upon upgrading to the paid-for (and larger) database, trying to deploy gives the error:

File /tmp/appcfg4412552511405829763.tmp/WEB-INF/GeoIPCity.dat is too large (limit 32000000 bytes)

As far as I can tell, I have jar splitting enabled, but that doesn't help because this isn't a jar (renaming it to .jar doesn't magically fix it either :). Is there any way to get a file this large (~48mb) deployed as part of an AppEngine app?

My fallback plan is to shove the file in Cloud Storage and grab it from there. Unfortunately, Maxmind's Java code really really wants a File - not a Stream, not a Reader, not a byte[], but a File - which is hard to come by in AppEngine. Before I end up re-writing a bunch of stuff, I figured I'd see if anyone had managed to solve this problem already.

回答1:

On GAE the max application file size is 32Mb.

AFAIK you can not work around that. It would be best if you could split that in smaller files.



回答2:

Why use a 3rd party geoip database file fór this information when you get geo point, country, region and city for free in the appengine request headers?

My advice is to use x-appengine-geopoint, -country, -region and -city headers respectively for this purpose.

This should work, but requires you to catch thor headers at request level and store in the datastore along with other user data.