Extremely slow initial connection to nginx on Vagrant? - nginx

I running an Ubuntu VM via Vagrant on a Windows 10 host. On the Vagrant machine I am running a fairly standard PHP/nginx app.
Whenever I try to access the web app, it takes forever to load. Chrome network inspector shows this:
Chrome network timeline
This huge latency is completely gone on subsequent requests, but whenever I pop back into the browser and try again after a while, it crops up yet again.
I am using NFS.
I have disabled firewalls on both guest and host machines.
I increased keepalive_timeout in nginx which helped hide the problem, as it increased the time window for latency-free subsequent requests.
This latency occurs even when accessing static files, so I don't think it's a PHP-FPM/MySQL problem.

I successfully figured out what my problem was!
After looking at my Windows hosts file, it looked like my vagrant-hostmanager plugin had not been properly clearing out older IP entries (i.e. I had three seperate IP entries for myapp.dev even though only one IP was active). Probably because I'd forgotten to properly vagrant halt before shutting down my PC a few times.
Windows was clearly spending ages trying to resolve the two older entries before successfully resolving the 'real' one.
It's weird: you'd think this problem would cause the latency to show up in the DNS Lookup portion of the Chrome network timeline, rather than Initial connection, but oh well!

Related

Waiting for available socket... (Chrome + Wordpress) [duplicate]

I am accessing my PHP/Apache website from Chrome. And Chrome refuses to load the page, saying "Waiting for available socket".
Other pages on this same virtual host also have the problem.
Other virtual hosts on the same server load perfectly fine.
Please advise how I can fix this.
According to various sources, Chrome opens a maximum of 6 simultaneous connections to the same server. Possible solutions include
Host data on different virtual hosts on the same machine.
Consolidate content to be loaded to require fewer connections (for example, put everything in a single .data file for Emscripten)
Make sure you don't have too many <video> or <audio> tags marked with the attribute preload="auto".
Adjust Chrome to permit up to 32 connections. Policy List
Related question:
Chrome hangs after certain amount of data transfered - waiting for available socket

Connection to website cannot be established (randomly)

We manage this website: http://elearning.uem.mz
It is from mozambique (hosted in Portugal), and we have a lot of complaints that the users can't connect to it.
It seems to be a problem with the connection from the user, but we can't pinpoint the exact problem.
What we know is:
It affects randomly (a computer works one day, the next it doesn't);
It seems based on time (a user won't be able to connect for 30 minutes to 2 hours);
Sometimes it gives a Privoxy 500 Error;
Sometimes it gives ERR_NAMES_NOT_RESOLVED;
It affects all browsers.
We created a small .bat script that has to be run as administrator:
ipconfig /flushdns
ipconfig /renew
ipconfig /registerdns
This seems to solve most times, but each issue has to handled individually.
Is there anything we could do to minimize this issue?
After a lot of time and testing, we found out that this was a problem happening to every other site in the respective country...
It seems to have been some problems/upgrades to the whole infra-structure that was, and still is, messing up most DNS.

Amazon EC2 Instance - only accepting single connections?

I'm having a lot of trouble with an EC2 instance and I can't figure out what's going on. We're using it as a web server and it seems to work fine for single connection stuff - loading a simple page, RDP connection, ping etc. But as soon as a single client computer has more than one connection active with the server (a good example is if I try to browse the web site while I'm also logged into the server via RDP) the whole connection becomes incredibly unstable.
The biggest most annoying consequence of this is that the ASP.NET site that we're running consistently fails to load some pages since those pages use more than one connection. This wasn't a problem up until a few days ago when we were forced to migrate to different hardware because our hardware was apparently being retired by Amazon. Ever since then it's been tricky like this. Is it possible that there's a kink in Amazon's network and that it could potentially be resolved by stopping and starting the instance (and thus getting a different server?)
It turns out the problem was an underlying issue on Amazon's end. They investigated the issue and found a problem that they're correcting. I hope I haven't wasted too much StackOverflow brainpower with this dead-end of a question!

VMWare Virtual Machine Ignores DCHP Lease

I have a VMWare Player (Workstation 9 )virtual machine on an Ubuntu 12.10 (13.10 Kernel) host running Ubuntu 12.04 using a bridged connection and set to replicate the physical network connection. Everything usually works properly in a variety of locations. But at one location that I often frequent, the ip address of the virtual machine changes roughly every 10 minutes -rendering the vm entirely useless as it is a postgresql server and thus needs a dedicated local ip. Not only that, but when I copied a database dump into a shared folder, the file ended up getting corrupted.
I can verify that the network caused this problem, as the actual on the vm was not corrupted. I managed to temporarily solve the problem by going into a local modem and setting a DHCP Mac Address. Everything was working and files were not getting corrupted. However, it only lasted temporarily, and another random address was assigned, breaking several running processes on my machine. Between the router/gateway, there is a redundant apple router involved in the network that is likely causing the issue -but I cannot just throw it away or deactivate it, as it is not my network
Furthermore, DHCP leases work just fine for every other machine on the network; so
I believe the root issue is with vmware.
I have no clue what could possibly cause something like this to occur, as IP address assignment is one of those things that normally "just works". I am thinking about just switching to VitualBox, as I have used it in the past and never had a problem (except with properly running Windows 8. However,I have never actually seen any article suggesting VirtualVox over WMWare, as the latter supposedly performs better and has more intuitive shared folder support. Obviously though, any benefit from a shared folder is negated if it just shares corrupt garbage.
So you manually set a MAC address on your VM? In the past, I've seen VM's change MACs quite often; generally only after a reboot or cold start. It shouldn't happen on the fly... You could install Wireshark and grab a few packet captures to see if anything in there points you in the direction of the root cause.

How to find where a connection is failing

I have a website running a basic ASP.NET application that is mostly used from a single location, which is my client's office. The server is at a high-class datacenter.
Whenever I've been testing or using my application from outside their office I have consistently good connections but from their office the connection seems inconsistent. Sometimes requests just don't seem to make it to the server from the browser. I'm not familiar with the network hardware in the office, but they do have a T1 connection which should always be on.
I've tried ping and tracert and everything looks normal. When running Firebug during a failed request the request shows up in the log, then just sits there without showing it is sending any data, eventually it times out.
My question is, what tools can I use to diagnose this connection problem and start to narrow it down to a specific cause so I can fix it? Its an intermittent problem so a long running tool would probably make more sense, if there is any available.
Thanks for any help.
All of your standard ping and traceroute tools are probably your best bet. I'm not understanding though, where is the site located?
If you open command prompt, run ping -t aspwebsiteurl.domain <- will show if there is packet loss.
From command prompt again, tracert aspwebsiteurl.domain <- will show you what route the packet is taking to get the site. May also show you if there is one particular hop that is giving you the hickup.
Is there a proxy between the office and the datacenter that could be causing issues?
Also you could try Wireshark to try to debug the problem in more detail.
Speed Test - Internet Network Connection Speed may be of some help with some links to test out the connection at the client's office to see how well it works.
Another question is how far away is the client and the datacenter? If one is in New York and the other in Los Angeles then the distance apart may be a factor. Also, have you examined any possible DNS issues?

Resources