Viewing 15 replies - 1 through 15 (of 17 total)
  • Same here, but it’s not just POST requests, the whole site is ~5 seconds slower because WP Insert, for some outrageous reason, is trying to get the country for each visitor’s IP address via a slow and apparently unreliable HTTP API. And I don’t even use WP Insert’s geotargeting feature.

    I ended up commenting out add_action(‘init’, ‘wp_insert_ip_to_country’); in /wp-content/plugins/wp-insert/includes/common/geotargeting.php, and the site is now much faster (more so now that I’ve upgraded to PHP 7).

    Thread Starter blindpet

    (@blindpet)

    Great tip robzy, I agree it is a poor decision to use geo ip when the user doesn’t even want it.

    php7 really all it’s cracked up to be? Are you using the dotdeb repo by any chance?

    Even if a user does want it, I think you should only ever use a local GeoIP database.

    PHP7 is great. CPU usage sliced in half, if not more, and all pages load much quicker — especially noticeable in the (uncached) admin area. That’s why I was so surprised to find it got so slow today, took me a while to notice WP Insert was the culprit.

    I’m on CentOS so I’m using the remi repo.

    Thread Starter blindpet

    (@blindpet)

    Great, I am planning a migration soon. How is RAM usage? Are you using nginx or Apache?

    Thread Starter blindpet

    (@blindpet)

    Just putting this clear for any body who stumbles upon it who don’t know how to comment out in php, use the file robzy says and go to the bottom, make it match this

    /* add_action('init', 'wp_insert_ip_to_country');
    function wp_insert_ip_to_country() {
    	global $wpInsertGeoLocation;
    	$userIp = $_SERVER["REMOTE_ADDR"];
    	delete_transient('wp_insert_ip_'.$userIp);
    	if($wpInsertGeoLocation != false) {
    		return $wpInsertGeoLocation;
    	} else {
    		$countryCode = get_transient('wp_insert_ip_'.$userIp);
    		if($countryCode === false) {
    			$response = wp_remote_get('https://api.hostip.info/country.php?ip='.$userIp, array('timeout' => 5));
    			if(!is_wp_error($response) && isset($response['response']['code']) && ($response['response']['code'] == 200) && isset($response['body']) && ($response['body'] != '') && ($response['body'] != 'XX')) {
    				$wpInsertGeoLocation = $response['body'];
    				set_transient('wp_insert_ip_'.$userIp, $wpInsertGeoLocation, WEEK_IN_SECONDS);
    			}
    		} else {
    			$wpInsertGeoLocation = $countryCode;
    		}
    	}
    }*/
    /* End Get Geo Targeted Ad Code */

    Right, you might as well comment out the function, too.

    RAM usage is down by about a 1/3 for me (overall). This is PHP-FPM behind NGINX.

    Plugin Author Namith Jawahar

    (@namithjawahar)

    The GeoIp is cached and should ideally create a performance hit or 0.5 seconds or less once every week for a user (unique IP is cached for 7 days). But since the service itself went down the caching was not happening and causing performance hit during each page load until the request timeout kicked in.

    I have temporarily disabled GeoIp service until a more reliable alternative is found as hostip.info seems to be having issues. Update to the latest version (2.1.3) to deactivate GeoIp until a long term solution is figured out.

    Thread Starter blindpet

    (@blindpet)

    Either way this is not ideal at all. GeoIP lookups should be local and file based. Secondly, unnecessary lookups that the user never asked for should not be performed.

    The solution is therefore not to find a new geoip server but instead to fix the plugin functionality.

    With 30,000+ active installs, a 500ms delay per visitor is a lot of wasted time. I never knew WP Insert was doing this until the API stopped working; now that I’ve disabled it, the site is much more responsive. If you keep this in the plug-in, I’d recommend making it optional, disabling it by default, and including a warning regarding the performance hit.

    (Especially because one of the “Features” of the WP Insert plug-in listed in its description is “Does not slow down your site”)

    Thread Starter blindpet

    (@blindpet)

    Definitely, and it slowed down my other POST requests too. My site has never been faster after disabling the unnecessary (for me) feature.

    Easyazon pro uses a local file for geo ip lookups, I recommend taking a look at that and implementing similar functionality.

    Robzy, thank you for your php7 experience, I will be running it with nginx too so I’m glad it provides such a boost.

    Was wondering why my site had been slow lately thanks god P3 – Plugin Performance Profiler pointed me to this plugin. The last version did however fix it for now.

    After reading this whole thread i agree with robzy. Making it optional would be nice.

    Wasn’t aware of that plug-in, thanks mbox99. I often use Blackfire.io myself.

    Thread Starter blindpet

    (@blindpet)

    That is one good thing that came out of this, I will permanently be leaving query monitor open and reporting performance issues to devs.

    Plugin Author Namith Jawahar

    (@namithjawahar)

    Non repository plugins can easily use Maxmind GeoIp database to locally leverage Geo IP detection. I used to do the same in Wp-Insert until www.ads-software.com removed the plugin from the repository for using a non GPL database in the product. There is no free alternative to maxmind Geoip database which is accurate and of sufficiently small size to be bundled with the plugin. The actual reason to rely on third party services.

    Regarding making the lookups optional, I agree it should ideally be optional. The reason to choose this method of do it once a week for every visitor was to avoid another performance ht that may result from checking if any ad slot is actually using Geo IP features (There can be an unlimited number of Ad slots).

    Since third party services proved to be unreliable I will keep the feature disabled until a permanent solution is found.

    Plugin Author Namith Jawahar

    (@namithjawahar)

    If anyone has any suggestion of a GPL database or service which I can utilize do help me out.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Option to disable Geo IP’ is closed to new replies.