Problems with accurate geolocalization - ip-geolocation

After a DDoS attack on another server, I put a PHP script getting $_SERVER[REMOTE_ADDR] in a footer file, present in every page of my WordPress blog.
When I go to the blog with Google Chrome, the remote IP usually starts with 66.249... or 66.102 at least today when I test. (Not at all my actual IP. 66 are Google proxies, I believe.)
It doesn't differ so much when I use VPN and run over 4-5 different countries all over the world. Still starts in 66. Does this mean that geolocalization for visitors using Chrome is not so meaningful? They all run over Google proxy? (I use PIA for VPN.) VPN is not protecting me from the site, it is protecting me from Google.
Everything from Chrome will go over a proxy?
What also surprised me is that the WordPress statistics module sometimes indicate hits that my script will not find. My script is surely activated, as it is present in every page. (But usually it is the reverse. WP Statistics removes my own hits and many bots.)
In addition, I had an approx. 80% fall of the number of hits after starting my own recording. It could be an effect of less people reading the blog, when Christmas is over. But the fall was very dramatic. (As expressed by WP Statistics)
Sorry for not being able to give many details. Another site was attacked and I want to see what is happening to this blog. (But the two sites are on completely different servers.) I just run phone over poor connections, so my scripts are poor, but they ought to store every hit. Server load is low.

See SO Answer
Bottom line, try using:
$ipAddress = $_SERVER['REMOTE_ADDR'];
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
$ipAddress = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
}

Related

My website is slow and I don't know how to fix it

It's been 2 days and I think i might have to kill myself.
My website for some reason suddenly started taking way way wayyyy to long to load.
I have cloudflare enable on my domain to cache content so my site can load faster, I've tried turning it off, but my site is still taking forever to load.
I've used pingdom(http://tools.pingdom.com/fpt/#!/dFvagb/http://streamaton.com/) and according to the results it shows that the domain itself is taking to much time to load(whut?).
I've tried visiting other section of my site like my admin panel and the site loads up pretty fast.
I have no idea how to pin point the root of this problem.
it depends a bit on the circumstances:
Could the case be that you have much higher load than usually?
If not, did you perform any code changes that might be responsible for that change?
it could also be the case that the server your website is on is under unusual high load or in some weird half-dead state. Sending a mail to your ISP asking them to check your server might be a good idea in any case.

Very high page load times?

I have a Drupal site built on a shared host and I'm finding that the site is very slow to respond. I susepect it's the host and not my Drupal/database configurations but I don't know how to decipher the results from Pingdom.
I have also read Explanation of Pingdom Results but am unsure of how to resolve my problems.
Pingdom results show a Load Time of 60 seconds.
Performance Grade tab shows results of all items at or near 100.
According to the Page Analysis tab, most of the time is spent on the Wait state.
Does the above indicate a problem with my hosting or perhaps domain name provider or is there something that I can do to improve performance of my website?
I should also mention that I've used other tools like Google's Page Speed Chrome plugin and Firefox's Yslow plugin and both give an above average rating to my webpages which leads me to believe it's an issue with my host.
Drupal has this issues of abusing database queries especially if you use a lot of modules on one page and do not cache anything. That may slow down your site considerably. I use Pressflow Drupal`s profile to reduce some load times I also ad Varnish to server (you can look at Memcache too) I also add Boost module to the site itself. But the most important thing is to get query per page load number right. If have written some custom code optimize it. Look for ways to get same data without sending queries to the server maybe some data was already loaded to the page and you do not need tome queries.
In your particular case I think that some lose loop which does not end but has safety trigger which kills it after certain amount of time. I can bet that the reason is somewhere in your custom code or some underdeveloped module. Try to enable display of all the error.
P.S. Example of such page would be the best way determine what is wrong.

Magento 503 errors, intermittent, capacity problems?

I'm having intermittent 503 errors, out of the blue, on a Magento install. Occasionally the page will half load, without JS or CSS, or sometimes the images will not load, but the rest of it will.
I'm running 1.5 magento, and no settings have been changed before it started going awry.
My hosting guys (it's on shared hosting) have said:
Basically every time someone hits the site, you spawn about 10 - 20+
connections for every hit to:
/media/catalog/product/cache/1/....
For example:
/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/2/0/200_2_series-max.jpg
And this is maxing out the capacity. I've disabled cache, and the problem persists. Is there a way I can check why this is happening, or am I at the whim of my hosting chaps.
Thanks in advance.
Not the cache you've disabled, turn that back on as it only causes more severe system loading as everything that would normally be cached has to be recompiled on every request.
/media/catalog/product/cache/1/
This is the image cache. Your system is being overloaded serving out images to your customers. Therefore your server is probably suboptimal and not able to properly handle the loads being placed on it. Typical symptom on a shared hosting plan when attempting to run Magento, this typically causes your website to fall flat on its face the first time Bing, Yahoo and Google decide to simultaneously index your website.
The first thing to do when you start noticing the website to get boggy is to go into "Customer - Online Customers" and see how many Magento reports are online. Sort by IP and see who's hogging resources and take that ip over to Bots VS Browsers to see if it's a known web indexer. The next step is to get your Web Server Access log and start viewing what's being requested to make sure you don't have some script kiddie on your site trying to break it.
One way of eliminating your image loading problem is to go over to Amazon Web Services, sign up for CloudFront and serve your images out through this CDN. Basically it serves as a proxy system so your images only get requested on the initial view and then get served out through CloudFront. Your server still probably is going to have problems with overloading, but it won't be image serving that causes most of it.
Your "shared hosting guys" guys don't have the decency to tell you that they're not capable of hosting a Magento installation for you. This,
you spawn about 10 - 20+ connections for every hit to:
/media/catalog/product/cache/1/....
while I'm sure describes something they've uncovered, doesn't accurately describe it.
Whatever the specifics of the problem you're running into are, the servers your on right now are designed to host a different type of application. You'll continue to run into problems. Move to a host that supports Magento.

Please Help Me Troubleshoot Why My Site Is Loading So Slowly

My website is http://secretpassagesbooks.com/. It runs on the latest version of wordpress and is hosted via GoDaddy on a shared web server.
My website takes at anywhere from ten seconds to one minute to load, and I don't understand why. I have tested in IE, FireFox, and Chrome, and the page speed is the same. I performed several speed tests at various online speed test sites and have an average load time of 5 - 6 seconds. Yet when I click on a link to my URL or enter it directly it takes in excess of 30 seconds (sometimes more than a minute) to load the index page.
Here is what I have done so far to troubleshoot the issue:
I have the YSlow and Page Speed extensions installed in Firebug
Yslow test gives me a "Grade A -Overall performance score 90"
My Page Speed a score is 94/100
I have the W3Cache wordpress plugin installed and am using page, browser, and database object caching
I've tried minimizing as much CSS and JavaScript as possible
The site is using HTTP compression
Is there anything more I can do with this design, or is it case of my shared web server being overloaded? Thanks in advance for all your help.
YSlow, etc detect problems in the HTML, Javascript and CSS parts, and these are probably OK. It looks like your hosting is to blame.
If those plug-in results are correct (and I've no reason to doubt they are), then it's most likely a case of your virtual server simply being overloaded.
I presume you have no such issues running an identical site in a "local" production environment either, although you might want to try this to confirm if you've not already done this.
Incidentally, a tale-tell sign of an overloaded VPS/shared hosting solution is if the first page load is incredibly slow, but subsequent loads are "normal" - a common reason being that your "decicated" sandbox is being awoken from a sleep/low resource state. (This also seems to be the case as far as your site is concerned.) As such, it's possible (I don't know the details of this server, such as whether you have a "guaranteed" resource level for CPU, memory, etc.) that other sites on this particular server are using more than their fair share of bandwidth until your site kicks in.
Based on some tests from a tool that I built (The Performance Grader at JoomlaPerformance.com), wow is it bad...
Notice that the HTML took approximately 21.83 seconds to download (from the initial request, to the last object being downloaded). Not to mention that the page is nearly 300kb (which is fairly large for only having 7 images)...
This is where the issue is. Notice that the connection and DNS phases are fine, but the generation phase is really REALLY slow. That's where your problems are. It's server-side. So, you need to debug why it's slow. Some areas to look at are the SQL queries that are being executed (and if they are slow), any slow plugins, etc. Try disabling things one at a time to see if each makes a measurable difference or not.
My "hunch" is that your database is either overloaded, or your queries are very expensive. So in short, you can try another host to see if that helps (which is the solution more than you'd think)...
As most of you pointed out, the issue seemed to be with the server. I contacted GoDaddy and explained the situation. It turns out that my site was hosted on one of their legacy servers and was most likely overloaded. They switched me over to one of their grid servers (no cost) and now everything is loading quickly. Thanks for all the responses. I spent a lot of time tweaking the design, removing plugins one by one, reducing as many HTTP requests as possible, and generally went crazy trying figure out how to best optimize my site. After a few days and a lot of tests, I could not accept that the problem was client-side, especially after all the optimization test I ran showed my site was ok. So good to have it settled...for now, at least.
GoDaddy's webhosting is the bottleneck to your website, you should probably go for a VPS if you have got an advanced website with loads of lookups!

Web page with upload/download speed for a user

I want to make an URL that can be sent to the user. When he follows that URL, he'll get a page displaying upload/download speed for that user to the server the page is hosted on. Basically, I want to host my own speedtest. It'll be used for troubleshooting so fast to implement but dirty is better than neat and proper solution.
On the server I've got PHP, perl, python, apache and nginx and can use any of them. In what direction should I look?
I never like those speedtests, because they don't really represent your bandwidth accurately at all. Used to live in a university dorm with 100 MBit, and the pipe would indeed give me in excess of 90 MBit if properly utilized. But the speedtests would return no more than 15 MBit ever. Part of the problem is that web tests (a) don't do multiconnection tests, (b) run into various bottlenecks such as their own servers, their ISPs, or their TCP stacks, etc.
Ended up using speedtest. It allows to embed the speed tracker into your page.

Resources